Re: [PATCH v5 20/48] mfd: rn5t618: Register power-off handler with kernel power-off handler

2014-11-07 Thread Guenter Roeck

On 11/07/2014 01:00 PM, Beniamino Galvani wrote:

On Thu, Nov 06, 2014 at 08:43:04AM -0800, Guenter Roeck wrote:

Register with kernel power-off handler instead of setting pm_power_off
directly. Register with low priority to reflect that the original code
only sets pm_power_off if it was not already set.

Cc: Beniamino Galvani 
Acked-by: Lee Jones 
Signed-off-by: Guenter Roeck 
---
v5:
- Rebase to v3.18-rc3
v4:
- Do not use notifiers but internal functions and data structures to manage
   the list of power-off handlers. Drop unused parameters from callbacks, and
   make the power-off function type void
v3:
- Replace poweroff in all newly introduced variables and in text
   with power_off or power-off as appropriate
- Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx
v2:
- New patch

  drivers/mfd/rn5t618.c   | 28 
  include/linux/mfd/rn5t618.h |  2 ++
  2 files changed, 14 insertions(+), 16 deletions(-)


Tested-by: Beniamino Galvani 


Thanks!

Guenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 20/48] mfd: rn5t618: Register power-off handler with kernel power-off handler

2014-11-07 Thread Beniamino Galvani
On Thu, Nov 06, 2014 at 08:43:04AM -0800, Guenter Roeck wrote:
> Register with kernel power-off handler instead of setting pm_power_off
> directly. Register with low priority to reflect that the original code
> only sets pm_power_off if it was not already set.
> 
> Cc: Beniamino Galvani 
> Acked-by: Lee Jones 
> Signed-off-by: Guenter Roeck 
> ---
> v5:
> - Rebase to v3.18-rc3
> v4:
> - Do not use notifiers but internal functions and data structures to manage
>   the list of power-off handlers. Drop unused parameters from callbacks, and
>   make the power-off function type void
> v3:
> - Replace poweroff in all newly introduced variables and in text
>   with power_off or power-off as appropriate
> - Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx
> v2:
> - New patch
> 
>  drivers/mfd/rn5t618.c   | 28 
>  include/linux/mfd/rn5t618.h |  2 ++
>  2 files changed, 14 insertions(+), 16 deletions(-)

Tested-by: Beniamino Galvani 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 20/48] mfd: rn5t618: Register power-off handler with kernel power-off handler

2014-11-07 Thread Beniamino Galvani
On Thu, Nov 06, 2014 at 08:43:04AM -0800, Guenter Roeck wrote:
 Register with kernel power-off handler instead of setting pm_power_off
 directly. Register with low priority to reflect that the original code
 only sets pm_power_off if it was not already set.
 
 Cc: Beniamino Galvani b.galv...@gmail.com
 Acked-by: Lee Jones lee.jo...@linaro.org
 Signed-off-by: Guenter Roeck li...@roeck-us.net
 ---
 v5:
 - Rebase to v3.18-rc3
 v4:
 - Do not use notifiers but internal functions and data structures to manage
   the list of power-off handlers. Drop unused parameters from callbacks, and
   make the power-off function type void
 v3:
 - Replace poweroff in all newly introduced variables and in text
   with power_off or power-off as appropriate
 - Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx
 v2:
 - New patch
 
  drivers/mfd/rn5t618.c   | 28 
  include/linux/mfd/rn5t618.h |  2 ++
  2 files changed, 14 insertions(+), 16 deletions(-)

Tested-by: Beniamino Galvani b.galv...@gmail.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 20/48] mfd: rn5t618: Register power-off handler with kernel power-off handler

2014-11-07 Thread Guenter Roeck

On 11/07/2014 01:00 PM, Beniamino Galvani wrote:

On Thu, Nov 06, 2014 at 08:43:04AM -0800, Guenter Roeck wrote:

Register with kernel power-off handler instead of setting pm_power_off
directly. Register with low priority to reflect that the original code
only sets pm_power_off if it was not already set.

Cc: Beniamino Galvani b.galv...@gmail.com
Acked-by: Lee Jones lee.jo...@linaro.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v5:
- Rebase to v3.18-rc3
v4:
- Do not use notifiers but internal functions and data structures to manage
   the list of power-off handlers. Drop unused parameters from callbacks, and
   make the power-off function type void
v3:
- Replace poweroff in all newly introduced variables and in text
   with power_off or power-off as appropriate
- Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx
v2:
- New patch

  drivers/mfd/rn5t618.c   | 28 
  include/linux/mfd/rn5t618.h |  2 ++
  2 files changed, 14 insertions(+), 16 deletions(-)


Tested-by: Beniamino Galvani b.galv...@gmail.com


Thanks!

Guenter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 20/48] mfd: rn5t618: Register power-off handler with kernel power-off handler

2014-11-06 Thread Guenter Roeck
Register with kernel power-off handler instead of setting pm_power_off
directly. Register with low priority to reflect that the original code
only sets pm_power_off if it was not already set.

Cc: Beniamino Galvani 
Acked-by: Lee Jones 
Signed-off-by: Guenter Roeck 
---
v5:
- Rebase to v3.18-rc3
v4:
- Do not use notifiers but internal functions and data structures to manage
  the list of power-off handlers. Drop unused parameters from callbacks, and
  make the power-off function type void
v3:
- Replace poweroff in all newly introduced variables and in text
  with power_off or power-off as appropriate
- Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx
v2:
- New patch

 drivers/mfd/rn5t618.c   | 28 
 include/linux/mfd/rn5t618.h |  2 ++
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c
index 6668571..1492025 100644
--- a/drivers/mfd/rn5t618.c
+++ b/drivers/mfd/rn5t618.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static const struct mfd_cell rn5t618_cells[] = {
@@ -47,15 +48,16 @@ static const struct regmap_config rn5t618_regmap_config = {
.cache_type = REGCACHE_RBTREE,
 };
 
-static struct rn5t618 *rn5t618_pm_power_off;
-
-static void rn5t618_power_off(void)
+static void rn5t618_power_off(struct power_off_handler_block *this)
 {
+   struct rn5t618 *rn5t618 = container_of(this, struct rn5t618,
+  power_off_hb);
+
/* disable automatic repower-on */
-   regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_REPCNT,
+   regmap_update_bits(rn5t618->regmap, RN5T618_REPCNT,
   RN5T618_REPCNT_REPWRON, 0);
/* start power-off sequence */
-   regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_SLPCNT,
+   regmap_update_bits(rn5t618->regmap, RN5T618_SLPCNT,
   RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF);
 }
 
@@ -85,23 +87,17 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,
return ret;
}
 
-   if (!pm_power_off) {
-   rn5t618_pm_power_off = priv;
-   pm_power_off = rn5t618_power_off;
-   }
+   priv->power_off_hb.handler = rn5t618_power_off;
+   priv->power_off_hb.priority = POWER_OFF_PRIORITY_LOW;
+   ret = devm_register_power_off_handler(>dev, >power_off_hb);
+   if (ret)
+   dev_warn(>dev, "Failed to register power-off handler\n");
 
return 0;
 }
 
 static int rn5t618_i2c_remove(struct i2c_client *i2c)
 {
-   struct rn5t618 *priv = i2c_get_clientdata(i2c);
-
-   if (priv == rn5t618_pm_power_off) {
-   rn5t618_pm_power_off = NULL;
-   pm_power_off = NULL;
-   }
-
mfd_remove_devices(>dev);
return 0;
 }
diff --git a/include/linux/mfd/rn5t618.h b/include/linux/mfd/rn5t618.h
index c72d534..87e34b3 100644
--- a/include/linux/mfd/rn5t618.h
+++ b/include/linux/mfd/rn5t618.h
@@ -14,6 +14,7 @@
 #ifndef __LINUX_MFD_RN5T618_H
 #define __LINUX_MFD_RN5T618_H
 
+#include 
 #include 
 
 #define RN5T618_LSIVER 0x00
@@ -223,6 +224,7 @@ enum {
 
 struct rn5t618 {
struct regmap *regmap;
+   struct power_off_handler_block power_off_hb;
 };
 
 #endif /* __LINUX_MFD_RN5T618_H */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 20/48] mfd: rn5t618: Register power-off handler with kernel power-off handler

2014-11-06 Thread Guenter Roeck
Register with kernel power-off handler instead of setting pm_power_off
directly. Register with low priority to reflect that the original code
only sets pm_power_off if it was not already set.

Cc: Beniamino Galvani b.galv...@gmail.com
Acked-by: Lee Jones lee.jo...@linaro.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v5:
- Rebase to v3.18-rc3
v4:
- Do not use notifiers but internal functions and data structures to manage
  the list of power-off handlers. Drop unused parameters from callbacks, and
  make the power-off function type void
v3:
- Replace poweroff in all newly introduced variables and in text
  with power_off or power-off as appropriate
- Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx
v2:
- New patch

 drivers/mfd/rn5t618.c   | 28 
 include/linux/mfd/rn5t618.h |  2 ++
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c
index 6668571..1492025 100644
--- a/drivers/mfd/rn5t618.c
+++ b/drivers/mfd/rn5t618.c
@@ -15,6 +15,7 @@
 #include linux/mfd/core.h
 #include linux/mfd/rn5t618.h
 #include linux/module.h
+#include linux/pm.h
 #include linux/regmap.h
 
 static const struct mfd_cell rn5t618_cells[] = {
@@ -47,15 +48,16 @@ static const struct regmap_config rn5t618_regmap_config = {
.cache_type = REGCACHE_RBTREE,
 };
 
-static struct rn5t618 *rn5t618_pm_power_off;
-
-static void rn5t618_power_off(void)
+static void rn5t618_power_off(struct power_off_handler_block *this)
 {
+   struct rn5t618 *rn5t618 = container_of(this, struct rn5t618,
+  power_off_hb);
+
/* disable automatic repower-on */
-   regmap_update_bits(rn5t618_pm_power_off-regmap, RN5T618_REPCNT,
+   regmap_update_bits(rn5t618-regmap, RN5T618_REPCNT,
   RN5T618_REPCNT_REPWRON, 0);
/* start power-off sequence */
-   regmap_update_bits(rn5t618_pm_power_off-regmap, RN5T618_SLPCNT,
+   regmap_update_bits(rn5t618-regmap, RN5T618_SLPCNT,
   RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF);
 }
 
@@ -85,23 +87,17 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,
return ret;
}
 
-   if (!pm_power_off) {
-   rn5t618_pm_power_off = priv;
-   pm_power_off = rn5t618_power_off;
-   }
+   priv-power_off_hb.handler = rn5t618_power_off;
+   priv-power_off_hb.priority = POWER_OFF_PRIORITY_LOW;
+   ret = devm_register_power_off_handler(i2c-dev, priv-power_off_hb);
+   if (ret)
+   dev_warn(i2c-dev, Failed to register power-off handler\n);
 
return 0;
 }
 
 static int rn5t618_i2c_remove(struct i2c_client *i2c)
 {
-   struct rn5t618 *priv = i2c_get_clientdata(i2c);
-
-   if (priv == rn5t618_pm_power_off) {
-   rn5t618_pm_power_off = NULL;
-   pm_power_off = NULL;
-   }
-
mfd_remove_devices(i2c-dev);
return 0;
 }
diff --git a/include/linux/mfd/rn5t618.h b/include/linux/mfd/rn5t618.h
index c72d534..87e34b3 100644
--- a/include/linux/mfd/rn5t618.h
+++ b/include/linux/mfd/rn5t618.h
@@ -14,6 +14,7 @@
 #ifndef __LINUX_MFD_RN5T618_H
 #define __LINUX_MFD_RN5T618_H
 
+#include linux/pm.h
 #include linux/regmap.h
 
 #define RN5T618_LSIVER 0x00
@@ -223,6 +224,7 @@ enum {
 
 struct rn5t618 {
struct regmap *regmap;
+   struct power_off_handler_block power_off_hb;
 };
 
 #endif /* __LINUX_MFD_RN5T618_H */
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/