* [PATCH v5 09/48] mfd: palmas: Register with kernel power-off handler
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
@ 2014-11-06 16:42 ` Guenter Roeck
2014-11-06 16:42 ` [PATCH v5 14/48] mfd: tps80031: " Guenter Roeck
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2014-11-06 16:42 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-pm, Guenter Roeck, Samuel Ortiz, Lee Jones, linux-omap
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: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-omap@vger.kernel.org
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Guenter Roeck <linux@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:
- Use define to specify poweroff handler priority
- Use devm_register_power_off_handler
- Use dev_warn instead of dev_err
drivers/mfd/palmas.c | 28 ++++++++++++++--------------
include/linux/mfd/palmas.h | 3 +++
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 28cb048..60f81ed 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -19,6 +19,7 @@
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/err.h>
#include <linux/mfd/core.h>
@@ -425,20 +426,17 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
"ti,system-power-controller");
}
-static struct palmas *palmas_dev;
-static void palmas_power_off(void)
+static void palmas_power_off(struct power_off_handler_block *this)
{
+ struct palmas *palmas = container_of(this, struct palmas, power_off_hb);
unsigned int addr;
int ret, slave;
- if (!palmas_dev)
- return;
-
slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL);
ret = regmap_update_bits(
- palmas_dev->regmap[slave],
+ palmas->regmap[slave],
addr,
PALMAS_DEV_CTRL_DEV_ON,
0);
@@ -668,9 +666,16 @@ no_irq:
ret = of_platform_populate(node, NULL, NULL, &i2c->dev);
if (ret < 0) {
goto err_irq;
- } else if (pdata->pm_off && !pm_power_off) {
- palmas_dev = palmas;
- pm_power_off = palmas_power_off;
+ } else if (pdata->pm_off) {
+ int ret2;
+
+ palmas->power_off_hb.handler = palmas_power_off;
+ palmas->power_off_hb.priority = POWER_OFF_PRIORITY_LOW;
+ ret2 = devm_register_power_off_handler(palmas->dev,
+ &palmas->power_off_hb);
+ if (ret2)
+ dev_warn(palmas->dev,
+ "Failed to register power-off handler");
}
}
@@ -698,11 +703,6 @@ static int palmas_i2c_remove(struct i2c_client *i2c)
i2c_unregister_device(palmas->i2c_clients[i]);
}
- if (palmas == palmas_dev) {
- pm_power_off = NULL;
- palmas_dev = NULL;
- }
-
return 0;
}
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index fb0390a..7a43f7b 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -18,6 +18,7 @@
#include <linux/usb/otg.h>
#include <linux/leds.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/extcon.h>
@@ -68,6 +69,8 @@ struct palmas {
struct i2c_client *i2c_clients[PALMAS_NUM_CLIENTS];
struct regmap *regmap[PALMAS_NUM_CLIENTS];
+ struct power_off_handler_block power_off_hb;
+
/* Stored chip id */
int id;
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 14/48] mfd: tps80031: Register with kernel power-off handler
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
2014-11-06 16:42 ` [PATCH v5 09/48] mfd: palmas: Register with kernel power-off handler Guenter Roeck
@ 2014-11-06 16:42 ` Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 16/48] mfd: tps6586x: " Guenter Roeck
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2014-11-06 16:42 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-pm, Guenter Roeck, Samuel Ortiz, Lee Jones, linux-omap
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: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-omap@vger.kernel.org
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Guenter Roeck <linux@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:
- Use define to specify poweroff handler priority
- Use dev_warn instead of dev_err
drivers/mfd/tps80031.c | 27 +++++++++++++++------------
include/linux/mfd/tps80031.h | 2 ++
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/mfd/tps80031.c b/drivers/mfd/tps80031.c
index ed6c5b0..996fd7c 100644
--- a/drivers/mfd/tps80031.c
+++ b/drivers/mfd/tps80031.c
@@ -147,7 +147,6 @@ static const struct tps80031_pupd_data tps80031_pupds[] = {
[TPS80031_CTLI2C_SCL] = PUPD_DATA(4, 0, BIT(2)),
[TPS80031_CTLI2C_SDA] = PUPD_DATA(4, 0, BIT(3)),
};
-static struct tps80031 *tps80031_power_off_dev;
int tps80031_ext_power_req_config(struct device *dev,
unsigned long ext_ctrl_flag, int preq_bit,
@@ -209,11 +208,14 @@ int tps80031_ext_power_req_config(struct device *dev,
}
EXPORT_SYMBOL_GPL(tps80031_ext_power_req_config);
-static void tps80031_power_off(void)
+static void tps80031_power_off(struct power_off_handler_block *this)
{
- dev_info(tps80031_power_off_dev->dev, "switching off PMU\n");
- tps80031_write(tps80031_power_off_dev->dev, TPS80031_SLAVE_ID1,
- TPS80031_PHOENIX_DEV_ON, TPS80031_DEVOFF);
+ struct tps80031 *tps80031 = container_of(this, struct tps80031,
+ power_off_hb);
+
+ dev_info(tps80031->dev, "switching off PMU\n");
+ tps80031_write(tps80031->dev, TPS80031_SLAVE_ID1,
+ TPS80031_PHOENIX_DEV_ON, TPS80031_DEVOFF);
}
static void tps80031_pupd_init(struct tps80031 *tps80031,
@@ -501,9 +503,13 @@ static int tps80031_probe(struct i2c_client *client,
goto fail_mfd_add;
}
- if (pdata->use_power_off && !pm_power_off) {
- tps80031_power_off_dev = tps80031;
- pm_power_off = tps80031_power_off;
+ if (pdata->use_power_off) {
+ tps80031->power_off_hb.handler = tps80031_power_off;
+ tps80031->power_off_hb.priority = POWER_OFF_PRIORITY_LOW;
+ ret = register_power_off_handler(&tps80031->power_off_hb);
+ if (ret)
+ dev_warn(&client->dev,
+ "Failed to register power-off handler\n");
}
return 0;
@@ -523,10 +529,7 @@ static int tps80031_remove(struct i2c_client *client)
struct tps80031 *tps80031 = i2c_get_clientdata(client);
int i;
- if (tps80031_power_off_dev == tps80031) {
- tps80031_power_off_dev = NULL;
- pm_power_off = NULL;
- }
+ unregister_power_off_handler(&tps80031->power_off_hb);
mfd_remove_devices(tps80031->dev);
diff --git a/include/linux/mfd/tps80031.h b/include/linux/mfd/tps80031.h
index 2c75c9c..5716077 100644
--- a/include/linux/mfd/tps80031.h
+++ b/include/linux/mfd/tps80031.h
@@ -24,6 +24,7 @@
#define __LINUX_MFD_TPS80031_H
#include <linux/device.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
/* Pull-ups/Pull-downs */
@@ -513,6 +514,7 @@ struct tps80031 {
struct i2c_client *clients[TPS80031_NUM_SLAVES];
struct regmap *regmap[TPS80031_NUM_SLAVES];
struct regmap_irq_chip_data *irq_data;
+ struct power_off_handler_block power_off_hb;
};
struct tps80031_pupd_init_data {
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 16/48] mfd: tps6586x: Register with kernel power-off handler
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
2014-11-06 16:42 ` [PATCH v5 09/48] mfd: palmas: Register with kernel power-off handler Guenter Roeck
2014-11-06 16:42 ` [PATCH v5 14/48] mfd: tps80031: " Guenter Roeck
@ 2014-11-06 16:43 ` Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 17/48] mfd: tps65910: " Guenter Roeck
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2014-11-06 16:43 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-pm, Guenter Roeck, Samuel Ortiz, Lee Jones, linux-omap
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: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-omap@vger.kernel.org
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Guenter Roeck <linux@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:
- Use define to specify poweroff handler priority
- Use dev_warn instead of dev_err
drivers/mfd/tps6586x.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 8e1dbc4..f11165f 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -25,6 +25,7 @@
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/of.h>
@@ -133,6 +134,8 @@ struct tps6586x {
u32 irq_en;
u8 mask_reg[5];
struct irq_domain *irq_domain;
+
+ struct power_off_handler_block power_off_hb;
};
static inline struct tps6586x *dev_to_tps6586x(struct device *dev)
@@ -472,13 +475,15 @@ static const struct regmap_config tps6586x_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
-static struct device *tps6586x_dev;
-static void tps6586x_power_off(void)
+static void tps6586x_power_off(struct power_off_handler_block *this)
{
- if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
+ struct tps6586x *tps6586x = container_of(this, struct tps6586x,
+ power_off_hb);
+
+ if (tps6586x_clr_bits(tps6586x->dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
return;
- tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
+ tps6586x_set_bits(tps6586x->dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
}
static void tps6586x_print_version(struct i2c_client *client, int version)
@@ -575,9 +580,13 @@ static int tps6586x_i2c_probe(struct i2c_client *client,
goto err_add_devs;
}
- if (pdata->pm_off && !pm_power_off) {
- tps6586x_dev = &client->dev;
- pm_power_off = tps6586x_power_off;
+ if (pdata->pm_off) {
+ tps6586x->power_off_hb.handler = tps6586x_power_off;
+ tps6586x->power_off_hb.priority = POWER_OFF_PRIORITY_LOW;
+ ret = register_power_off_handler(&tps6586x->power_off_hb);
+ if (ret)
+ dev_warn(&client->dev,
+ "failed to register power-off handler\n");
}
return 0;
@@ -594,6 +603,8 @@ static int tps6586x_i2c_remove(struct i2c_client *client)
{
struct tps6586x *tps6586x = i2c_get_clientdata(client);
+ unregister_power_off_handler(&tps6586x->power_off_hb);
+
tps6586x_remove_subdevs(tps6586x);
mfd_remove_devices(tps6586x->dev);
if (client->irq)
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 17/48] mfd: tps65910: Register with kernel power-off handler
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
` (2 preceding siblings ...)
2014-11-06 16:43 ` [PATCH v5 16/48] mfd: tps6586x: " Guenter Roeck
@ 2014-11-06 16:43 ` Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 18/48] mfd: twl4030-power: " Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 35/48] arm: " Guenter Roeck
5 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2014-11-06 16:43 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-pm, Guenter Roeck, Samuel Ortiz, Lee Jones, linux-omap
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: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-omap@vger.kernel.org
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Guenter Roeck <linux@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:
- Use define to specify poweroff handler priority
- Use dev_warn instead of dev_err
drivers/mfd/tps65910.c | 21 +++++++++++++--------
include/linux/mfd/tps65910.h | 4 ++++
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 7612d89..b312b92 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -23,6 +23,7 @@
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/mfd/core.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/mfd/tps65910.h>
#include <linux/of.h>
@@ -437,12 +438,10 @@ struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
}
#endif
-static struct i2c_client *tps65910_i2c_client;
-static void tps65910_power_off(void)
+static void tps65910_power_off(struct power_off_handler_block *this)
{
- struct tps65910 *tps65910;
-
- tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev);
+ struct tps65910 *tps65910 = container_of(this, struct tps65910,
+ power_off_hb);
if (tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL,
DEVCTRL_PWR_OFF_MASK) < 0)
@@ -505,9 +504,13 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
tps65910_ck32k_init(tps65910, pmic_plat_data);
tps65910_sleepinit(tps65910, pmic_plat_data);
- if (pmic_plat_data->pm_off && !pm_power_off) {
- tps65910_i2c_client = i2c;
- pm_power_off = tps65910_power_off;
+ if (pmic_plat_data->pm_off) {
+ tps65910->power_off_hb.handler = tps65910_power_off;
+ tps65910->power_off_hb.priority = POWER_OFF_PRIORITY_LOW;
+ ret = register_power_off_handler(&tps65910->power_off_hb);
+ if (ret)
+ dev_warn(&i2c->dev,
+ "failed to register power-off handler\n");
}
ret = mfd_add_devices(tps65910->dev, -1,
@@ -527,6 +530,8 @@ static int tps65910_i2c_remove(struct i2c_client *i2c)
{
struct tps65910 *tps65910 = i2c_get_clientdata(i2c);
+ unregister_power_off_handler(&tps65910->power_off_hb);
+
tps65910_irq_exit(tps65910);
mfd_remove_devices(tps65910->dev);
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
index 6483a6f..a85ad0f 100644
--- a/include/linux/mfd/tps65910.h
+++ b/include/linux/mfd/tps65910.h
@@ -18,6 +18,7 @@
#define __LINUX_MFD_TPS65910_H
#include <linux/gpio.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
/* TPS chip id list */
@@ -905,6 +906,9 @@ struct tps65910 {
/* IRQ Handling */
int chip_irq;
struct regmap_irq_chip_data *irq_data;
+
+ /* Power-off handling */
+ struct power_off_handler_block power_off_hb;
};
struct tps65910_platform_data {
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 18/48] mfd: twl4030-power: Register with kernel power-off handler
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
` (3 preceding siblings ...)
2014-11-06 16:43 ` [PATCH v5 17/48] mfd: tps65910: " Guenter Roeck
@ 2014-11-06 16:43 ` Guenter Roeck
2014-11-10 8:46 ` Pavel Machek
2014-11-06 16:43 ` [PATCH v5 35/48] arm: " Guenter Roeck
5 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-11-06 16:43 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-pm, Guenter Roeck, Samuel Ortiz, Lee Jones, linux-omap
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.
Make twl4030_power_off static as it is only called from the twl4030-power
driver. Drop remove function as it is no longer needed.
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: linux-omap@vger.kernel.org
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Guenter Roeck <linux@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:
- Use define to specify poweroff handler priority
- Use dev_warn instead of dev_err
- Use devm_register_power_off_handler
- Drop remove function as it is no longer needed.
drivers/mfd/twl4030-power.c | 25 +++++++++++++++----------
include/linux/i2c/twl.h | 1 -
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index cf92a6d..88fd33c 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -25,9 +25,9 @@
*/
#include <linux/module.h>
-#include <linux/pm.h>
#include <linux/i2c/twl.h>
#include <linux/platform_device.h>
+#include <linux/pm.h>
#include <linux/of.h>
#include <linux/of_device.h>
@@ -611,7 +611,7 @@ twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
* After a successful execution, TWL shuts down the power to the SoC
* and all peripherals connected to it.
*/
-void twl4030_power_off(void)
+static void twl4030_power_off(struct power_off_handler_block *this)
{
int err;
@@ -621,6 +621,11 @@ void twl4030_power_off(void)
pr_err("TWL4030 Unable to power off\n");
}
+static struct power_off_handler_block twl4030_power_off_hb = {
+ .handler = twl4030_power_off,
+ .priority = POWER_OFF_PRIORITY_LOW,
+};
+
static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
struct device_node *node)
{
@@ -839,7 +844,9 @@ static int twl4030_power_probe(struct platform_device *pdev)
}
/* Board has to be wired properly to use this feature */
- if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) {
+ if (twl4030_power_use_poweroff(pdata, node)) {
+ int ret;
+
/* Default for SEQ_OFFSYNC is set, lets ensure this */
err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
TWL4030_PM_MASTER_CFG_P123_TRANSITION);
@@ -856,7 +863,11 @@ static int twl4030_power_probe(struct platform_device *pdev)
}
}
- pm_power_off = twl4030_power_off;
+ ret = devm_register_power_off_handler(&pdev->dev,
+ &twl4030_power_off_hb);
+ if (ret)
+ dev_warn(&pdev->dev,
+ "Failed to register power-off handler\n");
}
relock:
@@ -870,11 +881,6 @@ relock:
return err;
}
-static int twl4030_power_remove(struct platform_device *pdev)
-{
- return 0;
-}
-
static struct platform_driver twl4030_power_driver = {
.driver = {
.name = "twl4030_power",
@@ -882,7 +888,6 @@ static struct platform_driver twl4030_power_driver = {
.of_match_table = of_match_ptr(twl4030_power_of_match),
},
.probe = twl4030_power_probe,
- .remove = twl4030_power_remove,
};
module_platform_driver(twl4030_power_driver);
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 8cfb50f..f8544f1 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -680,7 +680,6 @@ struct twl4030_power_data {
};
extern int twl4030_remove_script(u8 flags);
-extern void twl4030_power_off(void);
struct twl4030_codec_data {
unsigned int digimic_delay; /* in ms */
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v5 35/48] arm: Register with kernel power-off handler
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
` (4 preceding siblings ...)
2014-11-06 16:43 ` [PATCH v5 18/48] mfd: twl4030-power: " Guenter Roeck
@ 2014-11-06 16:43 ` Guenter Roeck
5 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2014-11-06 16:43 UTC (permalink / raw)
To: linux-kernel
Cc: linux-pm, Guenter Roeck, Russell King, bcm-kernel-feedback-list,
linux-arm-kernel, linux-omap, linux-rpi-kernel, linux-samsung-soc,
xen-devel
Register with kernel power-off handler instead of setting pm_power_off
directly. Always use register_power_off_handler_simple as there is no
indication that more than one power-off handler is registered.
If the power-off handler only resets the system or puts the CPU in sleep mode,
select the fallback priority to indicate that the power-off handler is one
of last resort. If the power-off handler powers off the system, select the
default priority.
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v5:
- Rebase to v3.18-rc3
v4:
- No change
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:
- Use defines to specify poweroff handler priorities
- Drop changes in arch/arm/mach-at91/setup.c (file removed upstream)
arch/arm/kernel/psci.c | 3 ++-
arch/arm/mach-at91/board-gsia18s.c | 3 ++-
arch/arm/mach-bcm/board_bcm2835.c | 3 ++-
arch/arm/mach-cns3xxx/cns3420vb.c | 3 ++-
arch/arm/mach-cns3xxx/core.c | 3 ++-
arch/arm/mach-highbank/highbank.c | 3 ++-
arch/arm/mach-imx/mach-mx31moboard.c | 3 ++-
arch/arm/mach-iop32x/em7210.c | 3 ++-
arch/arm/mach-iop32x/glantank.c | 3 ++-
arch/arm/mach-iop32x/iq31244.c | 3 ++-
arch/arm/mach-iop32x/n2100.c | 3 ++-
arch/arm/mach-ixp4xx/dsmg600-setup.c | 3 ++-
arch/arm/mach-ixp4xx/nas100d-setup.c | 3 ++-
arch/arm/mach-ixp4xx/nslu2-setup.c | 3 ++-
arch/arm/mach-omap2/board-omap3touchbook.c | 3 ++-
arch/arm/mach-orion5x/board-mss2.c | 3 ++-
arch/arm/mach-orion5x/dns323-setup.c | 9 ++++++---
arch/arm/mach-orion5x/kurobox_pro-setup.c | 3 ++-
arch/arm/mach-orion5x/ls-chl-setup.c | 3 ++-
arch/arm/mach-orion5x/ls_hgl-setup.c | 3 ++-
arch/arm/mach-orion5x/lsmini-setup.c | 3 ++-
arch/arm/mach-orion5x/mv2120-setup.c | 3 ++-
arch/arm/mach-orion5x/net2big-setup.c | 3 ++-
arch/arm/mach-orion5x/terastation_pro2-setup.c | 3 ++-
arch/arm/mach-orion5x/ts209-setup.c | 3 ++-
arch/arm/mach-orion5x/ts409-setup.c | 3 ++-
arch/arm/mach-pxa/corgi.c | 3 ++-
arch/arm/mach-pxa/mioa701.c | 3 ++-
arch/arm/mach-pxa/poodle.c | 3 ++-
arch/arm/mach-pxa/spitz.c | 3 ++-
arch/arm/mach-pxa/tosa.c | 3 ++-
arch/arm/mach-pxa/viper.c | 3 ++-
arch/arm/mach-pxa/z2.c | 7 ++++---
arch/arm/mach-pxa/zeus.c | 7 ++++---
arch/arm/mach-s3c24xx/mach-gta02.c | 3 ++-
arch/arm/mach-s3c24xx/mach-jive.c | 3 ++-
arch/arm/mach-s3c24xx/mach-vr1000.c | 3 ++-
arch/arm/mach-s3c64xx/mach-smartq.c | 3 ++-
arch/arm/mach-sa1100/generic.c | 3 ++-
arch/arm/mach-sa1100/simpad.c | 3 ++-
arch/arm/mach-u300/regulator.c | 3 ++-
arch/arm/mach-vt8500/vt8500.c | 3 ++-
arch/arm/xen/enlighten.c | 3 ++-
43 files changed, 94 insertions(+), 49 deletions(-)
diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
index f73891b..a7a2b4a 100644
--- a/arch/arm/kernel/psci.c
+++ b/arch/arm/kernel/psci.c
@@ -264,7 +264,8 @@ static int psci_0_2_init(struct device_node *np)
arm_pm_restart = psci_sys_reset;
- pm_power_off = psci_sys_poweroff;
+ register_power_off_handler_simple(psci_sys_poweroff,
+ POWER_OFF_PRIORITY_DEFAULT);
out_put_node:
of_node_put(np);
diff --git a/arch/arm/mach-at91/board-gsia18s.c b/arch/arm/mach-at91/board-gsia18s.c
index bf5cc55..e628c4a 100644
--- a/arch/arm/mach-at91/board-gsia18s.c
+++ b/arch/arm/mach-at91/board-gsia18s.c
@@ -521,7 +521,8 @@ static void gsia18s_power_off(void)
static int __init gsia18s_power_off_init(void)
{
- pm_power_off = gsia18s_power_off;
+ register_power_off_handler_simple(gsia18s_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
return 0;
}
diff --git a/arch/arm/mach-bcm/board_bcm2835.c b/arch/arm/mach-bcm/board_bcm2835.c
index 70f2f39..1d75c76 100644
--- a/arch/arm/mach-bcm/board_bcm2835.c
+++ b/arch/arm/mach-bcm/board_bcm2835.c
@@ -111,7 +111,8 @@ static void __init bcm2835_init(void)
bcm2835_setup_restart();
if (wdt_regs)
- pm_power_off = bcm2835_power_off;
+ register_power_off_handler_simple(bcm2835_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
bcm2835_init_clocks();
diff --git a/arch/arm/mach-cns3xxx/cns3420vb.c b/arch/arm/mach-cns3xxx/cns3420vb.c
index 6428bcc7..5c50461 100644
--- a/arch/arm/mach-cns3xxx/cns3420vb.c
+++ b/arch/arm/mach-cns3xxx/cns3420vb.c
@@ -224,7 +224,8 @@ static void __init cns3420_init(void)
cns3xxx_ahci_init();
cns3xxx_sdhci_init();
- pm_power_off = cns3xxx_power_off;
+ register_power_off_handler_simple(cns3xxx_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
static struct map_desc cns3420_io_desc[] __initdata = {
diff --git a/arch/arm/mach-cns3xxx/core.c b/arch/arm/mach-cns3xxx/core.c
index 4e9837d..9c214cf 100644
--- a/arch/arm/mach-cns3xxx/core.c
+++ b/arch/arm/mach-cns3xxx/core.c
@@ -386,7 +386,8 @@ static void __init cns3xxx_init(void)
cns3xxx_pwr_soft_rst(CNS3XXX_PWR_SOFTWARE_RST(SDIO));
}
- pm_power_off = cns3xxx_power_off;
+ register_power_off_handler_simple(cns3xxx_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
of_platform_populate(NULL, of_default_bus_match_table,
cns3xxx_auxdata, NULL);
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 07a0957..6fbdc01 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -155,7 +155,8 @@ static void __init highbank_init(void)
sregs_base = of_iomap(np, 0);
WARN_ON(!sregs_base);
- pm_power_off = highbank_power_off;
+ register_power_off_handler_simple(highbank_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
highbank_pm_init();
bus_register_notifier(&platform_bus_type, &highbank_platform_nb);
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index bb6f8a5..3001b14 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -559,7 +559,8 @@ static void __init mx31moboard_init(void)
imx_add_platform_device("imx_mc13783", 0, NULL, 0, NULL, 0);
- pm_power_off = mx31moboard_poweroff;
+ register_power_off_handler_simple(mx31moboard_poweroff,
+ POWER_OFF_PRIORITY_DEFAULT);
switch (mx31moboard_baseboard) {
case MX31NOBOARD:
diff --git a/arch/arm/mach-iop32x/em7210.c b/arch/arm/mach-iop32x/em7210.c
index 77e1ff0..fd3ad09 100644
--- a/arch/arm/mach-iop32x/em7210.c
+++ b/arch/arm/mach-iop32x/em7210.c
@@ -201,7 +201,8 @@ static int __init em7210_request_gpios(void)
return 0;
}
- pm_power_off = em7210_power_off;
+ register_power_off_handler_simple(em7210_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
return 0;
}
diff --git a/arch/arm/mach-iop32x/glantank.c b/arch/arm/mach-iop32x/glantank.c
index 547b234..9298ea0 100644
--- a/arch/arm/mach-iop32x/glantank.c
+++ b/arch/arm/mach-iop32x/glantank.c
@@ -199,7 +199,8 @@ static void __init glantank_init_machine(void)
i2c_register_board_info(0, glantank_i2c_devices,
ARRAY_SIZE(glantank_i2c_devices));
- pm_power_off = glantank_power_off;
+ register_power_off_handler_simple(glantank_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
MACHINE_START(GLANTANK, "GLAN Tank")
diff --git a/arch/arm/mach-iop32x/iq31244.c b/arch/arm/mach-iop32x/iq31244.c
index 0e1392b..50ba54b 100644
--- a/arch/arm/mach-iop32x/iq31244.c
+++ b/arch/arm/mach-iop32x/iq31244.c
@@ -293,7 +293,8 @@ static void __init iq31244_init_machine(void)
platform_device_register(&iop3xx_dma_1_channel);
if (is_ep80219())
- pm_power_off = ep80219_power_off;
+ register_power_off_handler_simple(ep80219_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
if (!is_80219())
platform_device_register(&iop3xx_aau_channel);
diff --git a/arch/arm/mach-iop32x/n2100.c b/arch/arm/mach-iop32x/n2100.c
index c1cd80e..734a092 100644
--- a/arch/arm/mach-iop32x/n2100.c
+++ b/arch/arm/mach-iop32x/n2100.c
@@ -356,7 +356,8 @@ static void __init n2100_init_machine(void)
i2c_register_board_info(0, n2100_i2c_devices,
ARRAY_SIZE(n2100_i2c_devices));
- pm_power_off = n2100_power_off;
+ register_power_off_handler_simple(n2100_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
MACHINE_START(N2100, "Thecus N2100")
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c
index 43ee06d..f34564d 100644
--- a/arch/arm/mach-ixp4xx/dsmg600-setup.c
+++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c
@@ -281,7 +281,8 @@ static void __init dsmg600_init(void)
platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
- pm_power_off = dsmg600_power_off;
+ register_power_off_handler_simple(dsmg600_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
index 4e0f762..43a9333 100644
--- a/arch/arm/mach-ixp4xx/nas100d-setup.c
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -292,7 +292,8 @@ static void __init nas100d_init(void)
platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
- pm_power_off = nas100d_power_off;
+ register_power_off_handler_simple(nas100d_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
IRQF_TRIGGER_LOW, "NAS100D reset button", NULL) < 0) {
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
index 88c025f..e094d5f 100644
--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
+++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
@@ -262,7 +262,8 @@ static void __init nslu2_init(void)
platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
- pm_power_off = nslu2_power_off;
+ register_power_off_handler_simple(nslu2_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
IRQF_TRIGGER_LOW, "NSLU2 reset button", NULL) < 0) {
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index a01993e..8abce2c 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -344,7 +344,8 @@ static void __init omap3_touchbook_init(void)
{
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
- pm_power_off = omap3_touchbook_poweroff;
+ register_power_off_handler_simple(omap3_touchbook_poweroff,
+ POWER_OFF_PRIORITY_DEFAULT);
if (system_rev >= 0x20 && system_rev <= 0x34301000) {
omap_mux_init_gpio(23, OMAP_PIN_INPUT);
diff --git a/arch/arm/mach-orion5x/board-mss2.c b/arch/arm/mach-orion5x/board-mss2.c
index 66f9c3b..cac2793 100644
--- a/arch/arm/mach-orion5x/board-mss2.c
+++ b/arch/arm/mach-orion5x/board-mss2.c
@@ -86,5 +86,6 @@ static void mss2_power_off(void)
void __init mss2_init(void)
{
/* register mss2 specific power-off method */
- pm_power_off = mss2_power_off;
+ register_power_off_handler_simple(mss2_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
}
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c
index 09d2a26..9876509 100644
--- a/arch/arm/mach-orion5x/dns323-setup.c
+++ b/arch/arm/mach-orion5x/dns323-setup.c
@@ -669,7 +669,8 @@ static void __init dns323_init(void)
if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
pr_err("DNS-323: failed to setup power-off GPIO\n");
- pm_power_off = dns323a_power_off;
+ register_power_off_handler_simple(dns323a_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
break;
case DNS323_REV_B1:
/* 5182 built-in SATA init */
@@ -686,7 +687,8 @@ static void __init dns323_init(void)
if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
pr_err("DNS-323: failed to setup power-off GPIO\n");
- pm_power_off = dns323b_power_off;
+ register_power_off_handler_simple(dns323b_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
break;
case DNS323_REV_C1:
/* 5182 built-in SATA init */
@@ -696,7 +698,8 @@ static void __init dns323_init(void)
if (gpio_request(DNS323C_GPIO_POWER_OFF, "POWEROFF") != 0 ||
gpio_direction_output(DNS323C_GPIO_POWER_OFF, 0) != 0)
pr_err("DNS-323: failed to setup power-off GPIO\n");
- pm_power_off = dns323c_power_off;
+ register_power_off_handler_simple(dns323c_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
/* Now, -this- should theorically be done by the sata_mv driver
* once I figure out what's going on there. Maybe the behaviour
diff --git a/arch/arm/mach-orion5x/kurobox_pro-setup.c b/arch/arm/mach-orion5x/kurobox_pro-setup.c
index fe6a48a..872d4fe 100644
--- a/arch/arm/mach-orion5x/kurobox_pro-setup.c
+++ b/arch/arm/mach-orion5x/kurobox_pro-setup.c
@@ -376,7 +376,8 @@ static void __init kurobox_pro_init(void)
i2c_register_board_info(0, &kurobox_pro_i2c_rtc, 1);
/* register Kurobox Pro specific power-off method */
- pm_power_off = kurobox_pro_power_off;
+ register_power_off_handler_simple(kurobox_pro_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
#ifdef CONFIG_MACH_KUROBOX_PRO
diff --git a/arch/arm/mach-orion5x/ls-chl-setup.c b/arch/arm/mach-orion5x/ls-chl-setup.c
index 028ea03..3f540d1 100644
--- a/arch/arm/mach-orion5x/ls-chl-setup.c
+++ b/arch/arm/mach-orion5x/ls-chl-setup.c
@@ -312,7 +312,8 @@ static void __init lschl_init(void)
gpio_set_value(LSCHL_GPIO_USB_POWER, 1);
/* register power-off method */
- pm_power_off = lschl_power_off;
+ register_power_off_handler_simple(lschl_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
pr_info("%s: finished\n", __func__);
}
diff --git a/arch/arm/mach-orion5x/ls_hgl-setup.c b/arch/arm/mach-orion5x/ls_hgl-setup.c
index 32b7129..699a5a1 100644
--- a/arch/arm/mach-orion5x/ls_hgl-setup.c
+++ b/arch/arm/mach-orion5x/ls_hgl-setup.c
@@ -259,7 +259,8 @@ static void __init ls_hgl_init(void)
gpio_set_value(LS_HGL_GPIO_USB_POWER, 1);
/* register power-off method */
- pm_power_off = ls_hgl_power_off;
+ register_power_off_handler_simple(ls_hgl_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
pr_info("%s: finished\n", __func__);
}
diff --git a/arch/arm/mach-orion5x/lsmini-setup.c b/arch/arm/mach-orion5x/lsmini-setup.c
index a6493e7..c5712ff 100644
--- a/arch/arm/mach-orion5x/lsmini-setup.c
+++ b/arch/arm/mach-orion5x/lsmini-setup.c
@@ -260,7 +260,8 @@ static void __init lsmini_init(void)
gpio_set_value(LSMINI_GPIO_USB_POWER, 1);
/* register power-off method */
- pm_power_off = lsmini_power_off;
+ register_power_off_handler_simple(lsmini_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
pr_info("%s: finished\n", __func__);
}
diff --git a/arch/arm/mach-orion5x/mv2120-setup.c b/arch/arm/mach-orion5x/mv2120-setup.c
index e032f01..13efbec 100644
--- a/arch/arm/mach-orion5x/mv2120-setup.c
+++ b/arch/arm/mach-orion5x/mv2120-setup.c
@@ -225,7 +225,8 @@ static void __init mv2120_init(void)
if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
pr_err("mv2120: failed to setup power-off GPIO\n");
- pm_power_off = mv2120_power_off;
+ register_power_off_handler_simple(mv2120_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
/* Warning: HP uses a wrong mach-type (=526) in their bootloader */
diff --git a/arch/arm/mach-orion5x/net2big-setup.c b/arch/arm/mach-orion5x/net2big-setup.c
index ba73dc7..c7648f0 100644
--- a/arch/arm/mach-orion5x/net2big-setup.c
+++ b/arch/arm/mach-orion5x/net2big-setup.c
@@ -413,7 +413,8 @@ static void __init net2big_init(void)
if (gpio_request(NET2BIG_GPIO_POWER_OFF, "power-off") == 0 &&
gpio_direction_output(NET2BIG_GPIO_POWER_OFF, 0) == 0)
- pm_power_off = net2big_power_off;
+ register_power_off_handler_simple(net2big_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
else
pr_err("net2big: failed to configure power-off GPIO\n");
diff --git a/arch/arm/mach-orion5x/terastation_pro2-setup.c b/arch/arm/mach-orion5x/terastation_pro2-setup.c
index 1208674..227ae91 100644
--- a/arch/arm/mach-orion5x/terastation_pro2-setup.c
+++ b/arch/arm/mach-orion5x/terastation_pro2-setup.c
@@ -353,7 +353,8 @@ static void __init tsp2_init(void)
i2c_register_board_info(0, &tsp2_i2c_rtc, 1);
/* register Terastation Pro II specific power-off method */
- pm_power_off = tsp2_power_off;
+ register_power_off_handler_simple(tsp2_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
MACHINE_START(TERASTATION_PRO2, "Buffalo Terastation Pro II/Live")
diff --git a/arch/arm/mach-orion5x/ts209-setup.c b/arch/arm/mach-orion5x/ts209-setup.c
index c725b7c..540e3f3 100644
--- a/arch/arm/mach-orion5x/ts209-setup.c
+++ b/arch/arm/mach-orion5x/ts209-setup.c
@@ -318,7 +318,8 @@ static void __init qnap_ts209_init(void)
i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1);
/* register tsx09 specific power-off method */
- pm_power_off = qnap_tsx09_power_off;
+ register_power_off_handler_simple(qnap_tsx09_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
MACHINE_START(TS209, "QNAP TS-109/TS-209")
diff --git a/arch/arm/mach-orion5x/ts409-setup.c b/arch/arm/mach-orion5x/ts409-setup.c
index cf2ab53..40cbdd7 100644
--- a/arch/arm/mach-orion5x/ts409-setup.c
+++ b/arch/arm/mach-orion5x/ts409-setup.c
@@ -307,7 +307,8 @@ static void __init qnap_ts409_init(void)
platform_device_register(&ts409_leds);
/* register tsx09 specific power-off method */
- pm_power_off = qnap_tsx09_power_off;
+ register_power_off_handler_simple(qnap_tsx09_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
}
MACHINE_START(TS409, "QNAP TS-409")
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 06022b2..93b73a1 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -718,7 +718,8 @@ static void corgi_restart(enum reboot_mode mode, const char *cmd)
static void __init corgi_init(void)
{
- pm_power_off = corgi_poweroff;
+ register_power_off_handler_simple(corgi_poweroff,
+ POWER_OFF_PRIORITY_FALLBACK);
/* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
PCFR |= PCFR_OPDE;
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 29997bd..5d318d4 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -750,7 +750,8 @@ static void __init mioa701_machine_init(void)
pxa_set_keypad_info(&mioa701_keypad_info);
pxa_set_udc_info(&mioa701_udc_info);
pxa_set_ac97_info(&mioa701_ac97_info);
- pm_power_off = mioa701_poweroff;
+ register_power_off_handler_simple(mioa701_poweroff,
+ POWER_OFF_PRIORITY_FALLBACK);
platform_add_devices(devices, ARRAY_SIZE(devices));
gsm_init();
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 1319916..749d2af 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -432,7 +432,8 @@ static void __init poodle_init(void)
{
int ret = 0;
- pm_power_off = poodle_poweroff;
+ register_power_off_handler_simple(poodle_poweroff,
+ POWER_OFF_PRIORITY_FALLBACK);
PCFR |= PCFR_OPDE;
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 840c3a4..ab25b6c 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -944,7 +944,8 @@ static void spitz_restart(enum reboot_mode mode, const char *cmd)
static void __init spitz_init(void)
{
init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
- pm_power_off = spitz_poweroff;
+ register_power_off_handler_simple(spitz_poweroff,
+ POWER_OFF_PRIORITY_FALLBACK);
PMCR = 0x00;
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index c158a6e..8823448 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -940,7 +940,8 @@ static void __init tosa_init(void)
init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
- pm_power_off = tosa_poweroff;
+ register_power_off_handler_simple(tosa_poweroff,
+ POWER_OFF_PRIORITY_FALLBACK);
PCFR |= PCFR_OPDE;
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index de3b080..6bb4de3 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -919,7 +919,8 @@ static void __init viper_init(void)
{
u8 version;
- pm_power_off = viper_power_off;
+ register_power_off_handler_simple(viper_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
pxa2xx_mfp_config(ARRAY_AND_SIZE(viper_pin_config));
diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c
index e1a121b..0d0a6ae 100644
--- a/arch/arm/mach-pxa/z2.c
+++ b/arch/arm/mach-pxa/z2.c
@@ -693,8 +693,6 @@ static void z2_power_off(void)
pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
pxa27x_cpu_pm_enter(PM_SUSPEND_MEM);
}
-#else
-#define z2_power_off NULL
#endif
/******************************************************************************
@@ -719,7 +717,10 @@ static void __init z2_init(void)
z2_keys_init();
z2_pmic_init();
- pm_power_off = z2_power_off;
+#ifdef CONFIG_PM
+ register_power_off_handler_simple(z2_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
+#endif
}
MACHINE_START(ZIPIT2, "Zipit Z2")
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index 205f9bf..457eed1 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -690,8 +690,6 @@ static void zeus_power_off(void)
local_irq_disable();
cpu_suspend(PWRMODE_DEEPSLEEP, pxa27x_finish_suspend);
}
-#else
-#define zeus_power_off NULL
#endif
#ifdef CONFIG_APM_EMULATION
@@ -847,7 +845,10 @@ static void __init zeus_init(void)
__raw_writel(msc0, MSC0);
__raw_writel(msc1, MSC1);
- pm_power_off = zeus_power_off;
+#ifdef CONFIG_PM
+ register_power_off_handler_simple(zeus_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
+#endif
zeus_setup_apm();
pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config));
diff --git a/arch/arm/mach-s3c24xx/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c
index 6d1e0b9..8366b3e 100644
--- a/arch/arm/mach-s3c24xx/mach-gta02.c
+++ b/arch/arm/mach-s3c24xx/mach-gta02.c
@@ -579,7 +579,8 @@ static void __init gta02_machine_init(void)
i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs));
platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
- pm_power_off = gta02_poweroff;
+ register_power_off_handler_simple(gta02_poweroff,
+ POWER_OFF_PRIORITY_DEFAULT);
regulator_has_full_constraints();
}
diff --git a/arch/arm/mach-s3c24xx/mach-jive.c b/arch/arm/mach-s3c24xx/mach-jive.c
index 7d99fe8..20beb39 100644
--- a/arch/arm/mach-s3c24xx/mach-jive.c
+++ b/arch/arm/mach-s3c24xx/mach-jive.c
@@ -657,7 +657,8 @@ static void __init jive_machine_init(void)
s3c_i2c0_set_platdata(&jive_i2c_cfg);
i2c_register_board_info(0, jive_i2c_devs, ARRAY_SIZE(jive_i2c_devs));
- pm_power_off = jive_power_off;
+ register_power_off_handler_simple(jive_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
platform_add_devices(jive_devices, ARRAY_SIZE(jive_devices));
}
diff --git a/arch/arm/mach-s3c24xx/mach-vr1000.c b/arch/arm/mach-s3c24xx/mach-vr1000.c
index 89f32bd..1f32ba7 100644
--- a/arch/arm/mach-s3c24xx/mach-vr1000.c
+++ b/arch/arm/mach-s3c24xx/mach-vr1000.c
@@ -306,7 +306,8 @@ static void vr1000_power_off(void)
static void __init vr1000_map_io(void)
{
- pm_power_off = vr1000_power_off;
+ register_power_off_handler_simple(vr1000_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c
index b3d1353..b30906f 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -291,7 +291,8 @@ static int __init smartq_power_off_init(void)
/* leave power on */
gpio_direction_output(S3C64XX_GPK(15), 0);
- pm_power_off = smartq_power_off;
+ register_power_off_handler_simple(smartq_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
return ret;
}
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index d4ea142..371bffe 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -311,7 +311,8 @@ static struct platform_device *sa11x0_devices[] __initdata = {
static int __init sa1100_init(void)
{
- pm_power_off = sa1100_power_off;
+ register_power_off_handler_simple(sa1100_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices));
}
diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
index 41e476e..fb85730 100644
--- a/arch/arm/mach-sa1100/simpad.c
+++ b/arch/arm/mach-sa1100/simpad.c
@@ -373,7 +373,8 @@ static int __init simpad_init(void)
if (ret)
printk(KERN_WARNING "simpad: Unable to register cs3 GPIO device");
- pm_power_off = simpad_power_off;
+ register_power_off_handler_simple(simpad_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
sa11x0_ppc_configure_mcp();
sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources,
diff --git a/arch/arm/mach-u300/regulator.c b/arch/arm/mach-u300/regulator.c
index 0493a84..4ff09b0 100644
--- a/arch/arm/mach-u300/regulator.c
+++ b/arch/arm/mach-u300/regulator.c
@@ -98,7 +98,8 @@ static int __init __u300_init_boardpower(struct platform_device *pdev)
U300_SYSCON_PMCR_DCON_ENABLE, 0);
/* Register globally exported PM poweroff hook */
- pm_power_off = u300_pm_poweroff;
+ register_power_off_handler_simple(u300_pm_poweroff,
+ POWER_OFF_PRIORITY_DEFAULT);
return 0;
}
diff --git a/arch/arm/mach-vt8500/vt8500.c b/arch/arm/mach-vt8500/vt8500.c
index 3bc0dc9..48e4fbf 100644
--- a/arch/arm/mach-vt8500/vt8500.c
+++ b/arch/arm/mach-vt8500/vt8500.c
@@ -155,7 +155,8 @@ static void __init vt8500_init(void)
pr_err("%s:ioremap(power_off) failed\n", __func__);
}
if (pmc_base)
- pm_power_off = &vt8500_power_off;
+ register_power_off_handler_simple(vt8500_power_off,
+ POWER_OFF_PRIORITY_FALLBACK);
else
pr_err("%s: PMC Hibernation register could not be remapped, not enabling power off!\n", __func__);
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 0e15f01..1c8bce0 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -336,7 +336,8 @@ static int __init xen_pm_init(void)
if (!xen_domain())
return -ENODEV;
- pm_power_off = xen_power_off;
+ register_power_off_handler_simple(xen_power_off,
+ POWER_OFF_PRIORITY_DEFAULT);
arm_pm_restart = xen_restart;
return 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v5 18/48] mfd: twl4030-power: Register with kernel power-off handler
2014-11-06 16:43 ` [PATCH v5 18/48] mfd: twl4030-power: " Guenter Roeck
@ 2014-11-10 8:46 ` Pavel Machek
2014-11-10 14:09 ` Guenter Roeck
0 siblings, 1 reply; 9+ messages in thread
From: Pavel Machek @ 2014-11-10 8:46 UTC (permalink / raw)
To: Guenter Roeck; +Cc: linux-kernel, linux-pm, Samuel Ortiz, Lee Jones, linux-omap
Hi!
> @@ -611,7 +611,7 @@ twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
> * After a successful execution, TWL shuts down the power to the SoC
> * and all peripherals connected to it.
> */
> -void twl4030_power_off(void)
> +static void twl4030_power_off(struct power_off_handler_block *this)
> {
> int err;
>
> @@ -621,6 +621,11 @@ void twl4030_power_off(void)
> pr_err("TWL4030 Unable to power off\n");
> }
>
> +static struct power_off_handler_block twl4030_power_off_hb = {
> + .handler = twl4030_power_off,
> + .priority = POWER_OFF_PRIORITY_LOW,
> +};
> +
> static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
> struct device_node *node)
> {
> @@ -839,7 +844,9 @@ static int twl4030_power_probe(struct platform_device *pdev)
> }
>
> /* Board has to be wired properly to use this feature */
> - if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) {
> + if (twl4030_power_use_poweroff(pdata, node)) {
> + int ret;
> +
> /* Default for SEQ_OFFSYNC is set, lets ensure this */
> err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
> TWL4030_PM_MASTER_CFG_P123_TRANSITION);
> @@ -856,7 +863,11 @@ static int twl4030_power_probe(struct platform_device *pdev)
> }
> }
>
> - pm_power_off = twl4030_power_off;
> + ret = devm_register_power_off_handler(&pdev->dev,
> + &twl4030_power_off_hb);
> + if (ret)
> + dev_warn(&pdev->dev,
> + "Failed to register power-off handler\n");
> }
>
Could we get rid of the "struct power_off_handler_block" and guarantee
that register_power_off never fails (or print message from the
register_power_off...)? That way, your patch would be an cleanup.
You could then add priorities if they turn out to be really
neccessary, later...
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 18/48] mfd: twl4030-power: Register with kernel power-off handler
2014-11-10 8:46 ` Pavel Machek
@ 2014-11-10 14:09 ` Guenter Roeck
2014-11-10 14:49 ` Guenter Roeck
0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2014-11-10 14:09 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-kernel, linux-pm, Samuel Ortiz, Lee Jones, linux-omap
On 11/10/2014 12:46 AM, Pavel Machek wrote:
> Hi!
>
>> @@ -611,7 +611,7 @@ twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
>> * After a successful execution, TWL shuts down the power to the SoC
>> * and all peripherals connected to it.
>> */
>> -void twl4030_power_off(void)
>> +static void twl4030_power_off(struct power_off_handler_block *this)
>> {
>> int err;
>>
>> @@ -621,6 +621,11 @@ void twl4030_power_off(void)
>> pr_err("TWL4030 Unable to power off\n");
>> }
>>
>> +static struct power_off_handler_block twl4030_power_off_hb = {
>> + .handler = twl4030_power_off,
>> + .priority = POWER_OFF_PRIORITY_LOW,
>> +};
>> +
>> static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
>> struct device_node *node)
>> {
>> @@ -839,7 +844,9 @@ static int twl4030_power_probe(struct platform_device *pdev)
>> }
>>
>> /* Board has to be wired properly to use this feature */
>> - if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) {
>> + if (twl4030_power_use_poweroff(pdata, node)) {
>> + int ret;
>> +
>> /* Default for SEQ_OFFSYNC is set, lets ensure this */
>> err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
>> TWL4030_PM_MASTER_CFG_P123_TRANSITION);
>> @@ -856,7 +863,11 @@ static int twl4030_power_probe(struct platform_device *pdev)
>> }
>> }
>>
>> - pm_power_off = twl4030_power_off;
>> + ret = devm_register_power_off_handler(&pdev->dev,
>> + &twl4030_power_off_hb);
>> + if (ret)
>> + dev_warn(&pdev->dev,
>> + "Failed to register power-off handler\n");
>> }
>>
>
> Could we get rid of the "struct power_off_handler_block" and guarantee
> that register_power_off never fails (or print message from the
> register_power_off...)? That way, your patch would be an cleanup.
>
> You could then add priorities if they turn out to be really
> neccessary, later...
Priorities are necessary. We had _that_ discussion before.
Priorities solve the problem where multiple handlers are installed,
either conditionally or unconditionally. If I take priorities away,
a substantial part of the patch set's value gets lost, and I might
as well drop it.
Guenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 18/48] mfd: twl4030-power: Register with kernel power-off handler
2014-11-10 14:09 ` Guenter Roeck
@ 2014-11-10 14:49 ` Guenter Roeck
0 siblings, 0 replies; 9+ messages in thread
From: Guenter Roeck @ 2014-11-10 14:49 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-kernel, linux-pm, Samuel Ortiz, Lee Jones, linux-omap
On 11/10/2014 06:09 AM, Guenter Roeck wrote:
> On 11/10/2014 12:46 AM, Pavel Machek wrote:
>> Hi!
>>
>>> @@ -611,7 +611,7 @@ twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
>>> * After a successful execution, TWL shuts down the power to the SoC
>>> * and all peripherals connected to it.
>>> */
>>> -void twl4030_power_off(void)
>>> +static void twl4030_power_off(struct power_off_handler_block *this)
>>> {
>>> int err;
>>>
>>> @@ -621,6 +621,11 @@ void twl4030_power_off(void)
>>> pr_err("TWL4030 Unable to power off\n");
>>> }
>>>
>>> +static struct power_off_handler_block twl4030_power_off_hb = {
>>> + .handler = twl4030_power_off,
>>> + .priority = POWER_OFF_PRIORITY_LOW,
>>> +};
>>> +
>>> static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
>>> struct device_node *node)
>>> {
>>> @@ -839,7 +844,9 @@ static int twl4030_power_probe(struct platform_device *pdev)
>>> }
>>>
>>> /* Board has to be wired properly to use this feature */
>>> - if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) {
>>> + if (twl4030_power_use_poweroff(pdata, node)) {
>>> + int ret;
>>> +
>>> /* Default for SEQ_OFFSYNC is set, lets ensure this */
>>> err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val,
>>> TWL4030_PM_MASTER_CFG_P123_TRANSITION);
>>> @@ -856,7 +863,11 @@ static int twl4030_power_probe(struct platform_device *pdev)
>>> }
>>> }
>>>
>>> - pm_power_off = twl4030_power_off;
>>> + ret = devm_register_power_off_handler(&pdev->dev,
>>> + &twl4030_power_off_hb);
>>> + if (ret)
>>> + dev_warn(&pdev->dev,
>>> + "Failed to register power-off handler\n");
>>> }
>>>
>>
>> Could we get rid of the "struct power_off_handler_block" and guarantee
>> that register_power_off never fails (or print message from the
>> register_power_off...)? That way, your patch would be an cleanup.
>>
>> You could then add priorities if they turn out to be really
>> neccessary, later...
>
> Priorities are necessary. We had _that_ discussion before.
> Priorities solve the problem where multiple handlers are installed,
> either conditionally or unconditionally. If I take priorities away,
> a substantial part of the patch set's value gets lost, and I might
> as well drop it.
>
I have an idea: Instead of dropping the priority, drop
power_off_handler_block and add two parameters to register_power_off_handler
and devm_register_power_off_handler instead: the priority and a context.
At the same time, declare that those two functions must be called
with the memory subsystem initialized (register_power_off_handler_simple
must be used otherwise).
With this change, the registration functions can still fail due to memory
allocation errors, but we can get rid of the data structure and simplify
the calling code while retaining functionality. I'll explore that for v7.
Guenter
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-11-10 14:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1415292213-28652-1-git-send-email-linux@roeck-us.net>
2014-11-06 16:42 ` [PATCH v5 09/48] mfd: palmas: Register with kernel power-off handler Guenter Roeck
2014-11-06 16:42 ` [PATCH v5 14/48] mfd: tps80031: " Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 16/48] mfd: tps6586x: " Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 17/48] mfd: tps65910: " Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 18/48] mfd: twl4030-power: " Guenter Roeck
2014-11-10 8:46 ` Pavel Machek
2014-11-10 14:09 ` Guenter Roeck
2014-11-10 14:49 ` Guenter Roeck
2014-11-06 16:43 ` [PATCH v5 35/48] arm: " Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).