* [PATCH v2 37/45] mfd: tps65910: Use devm_register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_simple_power_off_handler() that replaces global
pm_power_off variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/tps65910.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 6e105cca27d4..8fab30dc84e5 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -16,6 +16,7 @@
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/mfd/core.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/mfd/tps65910.h>
#include <linux/of.h>
@@ -429,9 +430,9 @@ 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(void *data)
{
+ struct i2c_client *tps65910_i2c_client = data;
struct tps65910 *tps65910;
tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev);
@@ -503,9 +504,15 @@ 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) {
+ ret = devm_register_simple_power_off_handler(&i2c->dev,
+ tps65910_power_off,
+ i2c);
+ if (ret) {
+ dev_err(&i2c->dev,
+ "failed to register power-off handler: %d\n", ret);
+ return ret;
+ }
}
ret = devm_mfd_add_devices(tps65910->dev, -1,
--
2.33.1
^ permalink raw reply related
* [PATCH v2 36/45] mfd: tps6586x: Use devm_register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_simple_power_off_handler() that replaces global
pm_power_off variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/tps6586x.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index c9303d3d6602..9033ed936d1e 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -22,6 +22,7 @@
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/of.h>
@@ -461,9 +462,10 @@ 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(void *data)
{
+ struct device *tps6586x_dev = data;
+
if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
return;
@@ -540,6 +542,16 @@ static int tps6586x_i2c_probe(struct i2c_client *client,
return ret;
}
+ if (pdata->pm_off) {
+ ret = devm_register_simple_power_off_handler(&client->dev,
+ tps6586x_power_off,
+ &client->dev);
+ if (ret) {
+ dev_err(&client->dev,
+ "failed to register power-off handler: %d\n", ret);
+ return ret;
+ }
+ }
if (client->irq) {
ret = tps6586x_irq_init(tps6586x, client->irq,
@@ -564,11 +576,6 @@ 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;
- }
-
return 0;
err_add_devs:
--
2.33.1
^ permalink raw reply related
* [PATCH v2 35/45] mfd: max8907: Use devm_register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_simple_power_off_handler() that replaces global
pm_power_off variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/max8907.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c
index 41f566e6a096..58699510311b 100644
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/slab.h>
@@ -174,9 +175,10 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip = {
.num_irqs = ARRAY_SIZE(max8907_rtc_irqs),
};
-static struct max8907 *max8907_pm_off;
-static void max8907_power_off(void)
+static void max8907_power_off(void *data)
{
+ struct max8907 *max8907_pm_off = data;
+
regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG,
MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF);
}
@@ -214,6 +216,17 @@ static int max8907_i2c_probe(struct i2c_client *i2c,
goto err_regmap_gen;
}
+ if (pm_off) {
+ ret = devm_register_simple_power_off_handler(&i2c->dev,
+ max8907_power_off,
+ max8907);
+ if (ret) {
+ dev_err(&i2c->dev,
+ "failed to register power-off handler: %d\n", ret);
+ return ret;
+ }
+ }
+
max8907->i2c_rtc = i2c_new_dummy_device(i2c->adapter, MAX8907_RTC_I2C_ADDR);
if (IS_ERR(max8907->i2c_rtc)) {
ret = PTR_ERR(max8907->i2c_rtc);
@@ -260,11 +273,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c,
goto err_add_devices;
}
- if (pm_off && !pm_power_off) {
- max8907_pm_off = max8907;
- pm_power_off = max8907_power_off;
- }
-
return 0;
err_add_devices:
--
2.33.1
^ permalink raw reply related
* [PATCH v2 34/45] mfd: palmas: Use devm_register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_simple_power_off_handler() that replaces global
pm_power_off variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/palmas.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index f5b3fa973b13..c7d4d48d2fda 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -14,6 +14,7 @@
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/err.h>
#include <linux/mfd/core.h>
@@ -420,12 +421,12 @@ 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(void *data)
{
unsigned int addr;
int ret, slave;
u8 powerhold_mask;
+ struct palmas *palmas_dev = data;
struct device_node *np = palmas_dev->dev->of_node;
if (of_property_read_bool(np, "ti,palmas-override-powerhold")) {
@@ -680,12 +681,16 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
*/
if (node) {
ret = devm_of_platform_populate(&i2c->dev);
- if (ret < 0) {
+ if (ret < 0)
+ goto err_irq;
+ }
+
+ if (pdata->pm_off) {
+ ret = devm_register_simple_power_off_handler(&i2c->dev,
+ palmas_power_off,
+ palmas);
+ if (ret)
goto err_irq;
- } else if (pdata->pm_off && !pm_power_off) {
- palmas_dev = palmas;
- pm_power_off = palmas_power_off;
- }
}
return ret;
@@ -712,11 +717,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;
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 33/45] mfd: rk808: Use devm_register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_simple_power_off_handler() that replaces global
pm_power_off variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/rk808.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index b181fe401330..3bf369469053 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -18,6 +18,7 @@
#include <linux/mfd/core.h>
#include <linux/module.h>
#include <linux/of_device.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
struct rk808_reg_data {
@@ -526,12 +527,11 @@ static const struct regmap_irq_chip rk818_irq_chip = {
.init_ack_masked = true,
};
-static struct i2c_client *rk808_i2c_client;
-
-static void rk808_pm_power_off(void)
+static void rk808_pm_power_off(void *data)
{
int ret;
unsigned int reg, bit;
+ struct i2c_client *rk808_i2c_client = data;
struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
switch (rk808->variant) {
@@ -725,8 +725,14 @@ static int rk808_probe(struct i2c_client *client,
}
if (of_property_read_bool(np, "rockchip,system-power-controller")) {
- rk808_i2c_client = client;
- pm_power_off = rk808_pm_power_off;
+ ret = devm_register_simple_power_off_handler(&client->dev,
+ rk808_pm_power_off,
+ client);
+ if (ret) {
+ dev_err(&client->dev,
+ "failed to register power-off handler %d\n", ret);
+ goto err_irq;
+ }
}
return 0;
@@ -742,13 +748,6 @@ static int rk808_remove(struct i2c_client *client)
regmap_del_irq_chip(client->irq, rk808->irq_data);
- /**
- * pm_power_off may points to a function from another module.
- * Check if the pointer is set by us and only then overwrite it.
- */
- if (pm_power_off == rk808_pm_power_off)
- pm_power_off = NULL;
-
return 0;
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 32/45] mfd: retu: Use devm_register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_simple_power_off_handler() that replaces global
pm_power_off variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/retu-mfd.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
index c748fd29a220..d18f05c1f095 100644
--- a/drivers/mfd/retu-mfd.c
+++ b/drivers/mfd/retu-mfd.c
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/module.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/mfd/core.h>
#include <linux/mfd/retu.h>
@@ -81,9 +82,6 @@ static struct regmap_irq_chip retu_irq_chip = {
.ack_base = RETU_REG_IDR,
};
-/* Retu device registered for the power off. */
-static struct retu_dev *retu_pm_power_off;
-
static const struct resource tahvo_usb_res[] = {
{
.name = "tahvo-usb",
@@ -165,12 +163,12 @@ int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
}
EXPORT_SYMBOL_GPL(retu_write);
-static void retu_power_off(void)
+static void retu_power_off(void *data)
{
- struct retu_dev *rdev = retu_pm_power_off;
+ struct retu_dev *rdev = data;
int reg;
- mutex_lock(&retu_pm_power_off->mutex);
+ mutex_lock(&rdev->mutex);
/* Ignore power button state */
regmap_read(rdev->regmap, RETU_REG_CC1, ®);
@@ -183,7 +181,7 @@ static void retu_power_off(void)
for (;;)
cpu_relax();
- mutex_unlock(&retu_pm_power_off->mutex);
+ mutex_unlock(&rdev->mutex);
}
static int retu_regmap_read(void *context, const void *reg, size_t reg_size,
@@ -261,6 +259,17 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
(ret & RETU_REG_ASICR_VILMA) ? rdat->companion_name : "",
(ret >> 4) & 0x7, ret & 0xf);
+ if (i2c->addr == 1) {
+ ret = devm_register_simple_power_off_handler(&i2c->dev,
+ retu_power_off,
+ rdev);
+ if (ret) {
+ dev_err(rdev->dev,
+ "could not register power-off handler: %d\n", ret);
+ return ret;
+ }
+ }
+
/* Mask all interrupts. */
ret = retu_write(rdev, rdat->irq_chip->mask_base, 0xffff);
if (ret < 0)
@@ -279,10 +288,6 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
return ret;
}
- if (i2c->addr == 1 && !pm_power_off) {
- retu_pm_power_off = rdev;
- pm_power_off = retu_power_off;
- }
return 0;
}
@@ -291,10 +296,6 @@ static int retu_remove(struct i2c_client *i2c)
{
struct retu_dev *rdev = i2c_get_clientdata(i2c);
- if (retu_pm_power_off == rdev) {
- pm_power_off = NULL;
- retu_pm_power_off = NULL;
- }
mfd_remove_devices(rdev->dev);
regmap_del_irq_chip(i2c->irq, rdev->irq_data);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 31/45] mfd: axp20x: Use register_simple_power_off_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use register_simple_power_off_handler() that replaces global pm_power_off
variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/axp20x.c | 22 +++++++++++-----------
include/linux/mfd/axp20x.h | 1 +
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 8161a5dc68e8..db31fdb169e4 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
@@ -823,9 +824,10 @@ static const struct mfd_cell axp813_cells[] = {
},
};
-static struct axp20x_dev *axp20x_pm_power_off;
-static void axp20x_power_off(void)
+static void axp20x_power_off(void *data)
{
+ struct axp20x_dev *axp20x_pm_power_off = data;
+
if (axp20x_pm_power_off->variant == AXP288_ID)
return;
@@ -1000,10 +1002,12 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
return ret;
}
- if (!pm_power_off) {
- axp20x_pm_power_off = axp20x;
- pm_power_off = axp20x_power_off;
- }
+ axp20x->power_handler =
+ register_simple_power_off_handler(axp20x_power_off, axp20x);
+
+ if (IS_ERR(axp20x->power_handler))
+ dev_err(axp20x->dev, "failed to register power-off handler: %pe",
+ axp20x->power_handler);
dev_info(axp20x->dev, "AXP20X driver loaded\n");
@@ -1013,11 +1017,7 @@ EXPORT_SYMBOL(axp20x_device_probe);
void axp20x_device_remove(struct axp20x_dev *axp20x)
{
- if (axp20x == axp20x_pm_power_off) {
- axp20x_pm_power_off = NULL;
- pm_power_off = NULL;
- }
-
+ unregister_simple_power_off_handler(axp20x->power_handler);
mfd_remove_devices(axp20x->dev);
regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
}
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index 9ab0e2fca7ea..49319a0ac369 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -643,6 +643,7 @@ struct axp20x_dev {
const struct mfd_cell *cells;
const struct regmap_config *regmap_cfg;
const struct regmap_irq_chip *regmap_irq_chip;
+ struct power_handler *power_handler;
};
/* generic helper function for reading 9-16 bit wide regs */
--
2.33.1
^ permalink raw reply related
* [PATCH v2 30/45] mfd: ene-kb3930: Use devm_register_power_handler()
From: Dmitry Osipenko @ 2021-10-27 21:17 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_power_handler() that replaces global pm_power_off
variable and allows to register multiple power-off handlers. It also
provides restart-handler support, i.e. all in one API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/ene-kb3930.c | 45 ++++++++++++++--------------------------
1 file changed, 15 insertions(+), 30 deletions(-)
diff --git a/drivers/mfd/ene-kb3930.c b/drivers/mfd/ene-kb3930.c
index 1b73318d1f1f..6a3c5f48e5e1 100644
--- a/drivers/mfd/ene-kb3930.c
+++ b/drivers/mfd/ene-kb3930.c
@@ -31,10 +31,9 @@ struct kb3930 {
struct i2c_client *client;
struct regmap *ram_regmap;
struct gpio_descs *off_gpios;
+ struct power_handler power_handler;
};
-static struct kb3930 *kb3930_power_off;
-
#define EC_GPIO_WAVE 0
#define EC_GPIO_OFF_MODE 1
@@ -60,21 +59,19 @@ static void kb3930_off(struct kb3930 *ddata, int off_mode)
}
}
-static int kb3930_restart(struct notifier_block *this,
- unsigned long mode, void *cmd)
+static void kb3930_restart(struct restart_data *data)
{
- kb3930_off(kb3930_power_off, EC_OFF_MODE_REBOOT);
- return NOTIFY_DONE;
+ struct kb3930 *ddata = data->cb_data;
+
+ kb3930_off(ddata, EC_OFF_MODE_REBOOT);
}
-static void kb3930_pm_power_off(void)
+static void kb3930_power_off(struct power_off_data *data)
{
- kb3930_off(kb3930_power_off, EC_OFF_MODE_POWER);
-}
+ struct kb3930 *ddata = data->cb_data;
-static struct notifier_block kb3930_restart_nb = {
- .notifier_call = kb3930_restart,
-};
+ kb3930_off(ddata, EC_OFF_MODE_POWER);
+}
static const struct mfd_cell ariel_ec_cells[] = {
{ .name = "dell-wyse-ariel-led", },
@@ -131,7 +128,6 @@ static int kb3930_probe(struct i2c_client *client)
if (!ddata)
return -ENOMEM;
- kb3930_power_off = ddata;
ddata->client = client;
i2c_set_clientdata(client, ddata);
@@ -169,24 +165,14 @@ static int kb3930_probe(struct i2c_client *client)
}
if (ddata->off_gpios) {
- register_restart_handler(&kb3930_restart_nb);
- if (!pm_power_off)
- pm_power_off = kb3930_pm_power_off;
- }
+ ddata->power_handler.cb_data = ddata;
+ ddata->power_handler.restart_cb = kb3930_restart;
+ ddata->power_handler.power_off_cb = kb3930_power_off;
- return 0;
-}
-
-static int kb3930_remove(struct i2c_client *client)
-{
- struct kb3930 *ddata = i2c_get_clientdata(client);
-
- if (ddata->off_gpios) {
- if (pm_power_off == kb3930_pm_power_off)
- pm_power_off = NULL;
- unregister_restart_handler(&kb3930_restart_nb);
+ ret = devm_register_power_handler(dev, &ddata->power_handler);
+ if (ret)
+ return ret;
}
- kb3930_power_off = NULL;
return 0;
}
@@ -199,7 +185,6 @@ MODULE_DEVICE_TABLE(of, kb3930_dt_ids);
static struct i2c_driver kb3930_driver = {
.probe_new = kb3930_probe,
- .remove = kb3930_remove,
.driver = {
.name = "ene-kb3930",
.of_match_table = kb3930_dt_ids,
--
2.33.1
^ permalink raw reply related
* [PATCH v2 29/45] mfd: acer-a500: Use devm_register_power_handler()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_power_handler() that replaces global pm_power_off
variable and allows to register multiple power-off handlers. It also
provides restart-handler support, i.e. all in one API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/acer-ec-a500.c | 52 ++++++++++++++------------------------
1 file changed, 19 insertions(+), 33 deletions(-)
diff --git a/drivers/mfd/acer-ec-a500.c b/drivers/mfd/acer-ec-a500.c
index 80c2fdd14fc4..fc864abc0049 100644
--- a/drivers/mfd/acer-ec-a500.c
+++ b/drivers/mfd/acer-ec-a500.c
@@ -31,8 +31,6 @@ enum {
REG_COLD_REBOOT = 0x55,
};
-static struct i2c_client *a500_ec_client_pm_off;
-
static int a500_ec_read(void *context, const void *reg_buf, size_t reg_size,
void *val_buf, size_t val_sizel)
{
@@ -104,32 +102,35 @@ static const struct regmap_bus a500_ec_regmap_bus = {
.max_raw_read = 2,
};
-static void a500_ec_poweroff(void)
+static void a500_ec_power_off_handler(struct power_off_data *data)
{
- i2c_smbus_write_word_data(a500_ec_client_pm_off,
- REG_SHUTDOWN, CMD_SHUTDOWN);
+ struct i2c_client *client = data->cb_data;
+
+ i2c_smbus_write_word_data(client, REG_SHUTDOWN, CMD_SHUTDOWN);
mdelay(A500_EC_POWER_CMD_TIMEOUT);
}
-static int a500_ec_restart_notify(struct notifier_block *this,
- unsigned long reboot_mode, void *data)
+static void a500_ec_restart_handler(struct restart_data *data)
{
- if (reboot_mode == REBOOT_WARM)
- i2c_smbus_write_word_data(a500_ec_client_pm_off,
+ struct i2c_client *client = data->cb_data;
+
+ if (data->mode == REBOOT_WARM)
+ i2c_smbus_write_word_data(client,
REG_WARM_REBOOT, CMD_WARM_REBOOT);
else
- i2c_smbus_write_word_data(a500_ec_client_pm_off,
+ i2c_smbus_write_word_data(client,
REG_COLD_REBOOT, CMD_COLD_REBOOT);
mdelay(A500_EC_POWER_CMD_TIMEOUT);
-
- return NOTIFY_DONE;
}
-static struct notifier_block a500_ec_restart_handler = {
- .notifier_call = a500_ec_restart_notify,
- .priority = 200,
+static struct power_handler a500_ec_power_handler = {
+ .restart_cb = a500_ec_restart_handler,
+ .restart_priority = RESTART_PRIO_HIGH,
+
+ .power_off_cb = a500_ec_power_off_handler,
+ .power_off_priority = POWEROFF_PRIO_HIGH,
};
static const struct mfd_cell a500_ec_cells[] = {
@@ -156,26 +157,12 @@ static int a500_ec_probe(struct i2c_client *client)
}
if (of_device_is_system_power_controller(client->dev.of_node)) {
- a500_ec_client_pm_off = client;
+ a500_ec_power_handler.cb_data = client;
- err = register_restart_handler(&a500_ec_restart_handler);
+ err = devm_register_power_handler(&client->dev,
+ &a500_ec_power_handler);
if (err)
return err;
-
- if (!pm_power_off)
- pm_power_off = a500_ec_poweroff;
- }
-
- return 0;
-}
-
-static int a500_ec_remove(struct i2c_client *client)
-{
- if (of_device_is_system_power_controller(client->dev.of_node)) {
- if (pm_power_off == a500_ec_poweroff)
- pm_power_off = NULL;
-
- unregister_restart_handler(&a500_ec_restart_handler);
}
return 0;
@@ -193,7 +180,6 @@ static struct i2c_driver a500_ec_driver = {
.of_match_table = a500_ec_match,
},
.probe_new = a500_ec_probe,
- .remove = a500_ec_remove,
};
module_i2c_driver(a500_ec_driver);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 28/45] mfd: rn5t618: Use devm_register_power_handler()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_power_handler() that replaces global pm_power_off
variable and allows to register multiple power-off handlers. It also
provides restart-handler support, i.e. all in one API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/rn5t618.c | 56 ++++++++++++++++---------------------------
1 file changed, 21 insertions(+), 35 deletions(-)
diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c
index 384acb459427..12d7b2339bbe 100644
--- a/drivers/mfd/rn5t618.c
+++ b/drivers/mfd/rn5t618.c
@@ -84,9 +84,6 @@ static const struct regmap_irq_chip rc5t619_irq_chip = {
.mask_invert = true,
};
-static struct i2c_client *rn5t618_pm_power_off;
-static struct notifier_block rn5t618_restart_handler;
-
static int rn5t618_irq_init(struct rn5t618 *rn5t618)
{
const struct regmap_irq_chip *irq_chip = NULL;
@@ -115,7 +112,9 @@ static int rn5t618_irq_init(struct rn5t618 *rn5t618)
return ret;
}
-static void rn5t618_trigger_poweroff_sequence(bool repower)
+static void
+rn5t618_trigger_poweroff_sequence(struct i2c_client *rn5t618_pm_power_off,
+ bool repower)
{
int ret;
@@ -151,25 +150,31 @@ static void rn5t618_trigger_poweroff_sequence(bool repower)
dev_alert(&rn5t618_pm_power_off->dev, "Failed to shutdown (err = %d)\n", ret);
}
-static void rn5t618_power_off(void)
+static void rn5t618_power_off(struct power_off_data *data)
{
- rn5t618_trigger_poweroff_sequence(false);
+ struct i2c_client *client = data->cb_data;
+
+ rn5t618_trigger_poweroff_sequence(client, false);
}
-static int rn5t618_restart(struct notifier_block *this,
- unsigned long mode, void *cmd)
+static void rn5t618_restart(struct restart_data *data)
{
- rn5t618_trigger_poweroff_sequence(true);
+ struct i2c_client *client = data->cb_data;
+
+ rn5t618_trigger_poweroff_sequence(client, true);
/*
* Re-power factor detection on PMIC side is not instant. 1ms
* proved to be enough time until reset takes effect.
*/
mdelay(1);
-
- return NOTIFY_DONE;
}
+static struct power_handler rn5t618_power_handler = {
+ .restart_cb = rn5t618_restart,
+ .restart_priority = RESTART_PRIO_HIGH,
+};
+
static const struct of_device_id rn5t618_of_match[] = {
{ .compatible = "ricoh,rn5t567", .data = (void *)RN5T567 },
{ .compatible = "ricoh,rn5t618", .data = (void *)RN5T618 },
@@ -221,38 +226,20 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c)
return ret;
}
- rn5t618_pm_power_off = i2c;
- if (of_device_is_system_power_controller(i2c->dev.of_node)) {
- if (!pm_power_off)
- pm_power_off = rn5t618_power_off;
- else
- dev_warn(&i2c->dev, "Poweroff callback already assigned\n");
- }
+ if (of_device_is_system_power_controller(i2c->dev.of_node))
+ rn5t618_power_handler.power_off_cb = rn5t618_power_off;
- rn5t618_restart_handler.notifier_call = rn5t618_restart;
- rn5t618_restart_handler.priority = 192;
+ rn5t618_power_handler.cb_data = i2c;
- ret = register_restart_handler(&rn5t618_restart_handler);
+ ret = devm_register_power_handler(&i2c->dev, &rn5t618_power_handler);
if (ret) {
- dev_err(&i2c->dev, "cannot register restart handler, %d\n", ret);
+ dev_err(&i2c->dev, "failed to register power handler: %d\n", ret);
return ret;
}
return rn5t618_irq_init(priv);
}
-static int rn5t618_i2c_remove(struct i2c_client *i2c)
-{
- if (i2c == rn5t618_pm_power_off) {
- rn5t618_pm_power_off = NULL;
- pm_power_off = NULL;
- }
-
- unregister_restart_handler(&rn5t618_restart_handler);
-
- return 0;
-}
-
static int __maybe_unused rn5t618_i2c_suspend(struct device *dev)
{
struct rn5t618 *priv = dev_get_drvdata(dev);
@@ -284,7 +271,6 @@ static struct i2c_driver rn5t618_i2c_driver = {
.pm = &rn5t618_i2c_dev_pm_ops,
},
.probe_new = rn5t618_i2c_probe,
- .remove = rn5t618_i2c_remove,
};
module_i2c_driver(rn5t618_i2c_driver);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 27/45] mfd: ntxec: Use devm_register_power_handler()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_power_handler() that replaces global pm_power_off
variable and allows to register multiple power-off handlers. It also
provides restart-handler support, i.e. all in one API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/mfd/ntxec.c | 50 ++++++++++-----------------------------------
1 file changed, 11 insertions(+), 39 deletions(-)
diff --git a/drivers/mfd/ntxec.c b/drivers/mfd/ntxec.c
index b711e73eedcb..fd6410cbe153 100644
--- a/drivers/mfd/ntxec.c
+++ b/drivers/mfd/ntxec.c
@@ -32,12 +32,11 @@
#define NTXEC_POWERKEEP_VALUE 0x0800
#define NTXEC_RESET_VALUE 0xff00
-static struct i2c_client *poweroff_restart_client;
-
-static void ntxec_poweroff(void)
+static void ntxec_poweroff(struct power_off_data *data)
{
int res;
u8 buf[3] = { NTXEC_REG_POWEROFF };
+ struct i2c_client *poweroff_restart_client = data->cb_data;
struct i2c_msg msgs[] = {
{
.addr = poweroff_restart_client->addr,
@@ -62,8 +61,7 @@ static void ntxec_poweroff(void)
msleep(5000);
}
-static int ntxec_restart(struct notifier_block *nb,
- unsigned long action, void *data)
+static void ntxec_restart(struct restart_data *data)
{
int res;
u8 buf[3] = { NTXEC_REG_RESET };
@@ -72,6 +70,7 @@ static int ntxec_restart(struct notifier_block *nb,
* it causes an I2C error. (The reset handler in the downstream driver
* does send the full two-byte value, but doesn't check the result).
*/
+ struct i2c_client *poweroff_restart_client = data->cb_data;
struct i2c_msg msgs[] = {
{
.addr = poweroff_restart_client->addr,
@@ -87,13 +86,11 @@ static int ntxec_restart(struct notifier_block *nb,
if (res < 0)
dev_warn(&poweroff_restart_client->dev,
"Failed to restart (err = %d)\n", res);
-
- return NOTIFY_DONE;
}
-static struct notifier_block ntxec_restart_handler = {
- .notifier_call = ntxec_restart,
- .priority = 128,
+static struct power_handler ntxec_power_handler = {
+ .restart_cb = ntxec_restart,
+ .power_off_cb = ntxec_poweroff,
};
static int regmap_ignore_write(void *context,
@@ -208,25 +205,12 @@ static int ntxec_probe(struct i2c_client *client)
if (res < 0)
return res;
- if (poweroff_restart_client)
- /*
- * Another instance of the driver already took
- * poweroff/restart duties.
- */
- dev_err(ec->dev, "poweroff_restart_client already assigned\n");
- else
- poweroff_restart_client = client;
-
- if (pm_power_off)
- /* Another driver already registered a poweroff handler. */
- dev_err(ec->dev, "pm_power_off already assigned\n");
- else
- pm_power_off = ntxec_poweroff;
-
- res = register_restart_handler(&ntxec_restart_handler);
+ ntxec_power_handler.cb_data = client;
+
+ res = devm_register_power_handler(ec->dev, &ntxec_power_handler);
if (res)
dev_err(ec->dev,
- "Failed to register restart handler: %d\n", res);
+ "Failed to register power handler: %d\n", res);
}
i2c_set_clientdata(client, ec);
@@ -239,17 +223,6 @@ static int ntxec_probe(struct i2c_client *client)
return res;
}
-static int ntxec_remove(struct i2c_client *client)
-{
- if (client == poweroff_restart_client) {
- poweroff_restart_client = NULL;
- pm_power_off = NULL;
- unregister_restart_handler(&ntxec_restart_handler);
- }
-
- return 0;
-}
-
static const struct of_device_id of_ntxec_match_table[] = {
{ .compatible = "netronix,ntxec", },
{}
@@ -262,7 +235,6 @@ static struct i2c_driver ntxec_driver = {
.of_match_table = of_ntxec_match_table,
},
.probe_new = ntxec_probe,
- .remove = ntxec_remove,
};
module_i2c_driver(ntxec_driver);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 26/45] soc/tegra: pmc: Utilize power-handler API to power off Nexus 7 properly
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Nexus 7 Android tablet can be turned off using a special bootloader
command which is conveyed to bootloader by putting magic value into
specific scratch register and then rebooting normally. This power-off
method should be invoked if USB cable is connected. Bootloader then will
display battery status and power off the device. This behaviour is
borrowed from downstream kernel and matches user expectations, otherwise
it looks like device got hung during power-off and it may wake up on
USB disconnect.
Switch PMC driver to power-handler API, which provides drivers with
combined power-off+restart call chains functionality, replacing the
restart-only call chain API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/soc/tegra/pmc.c | 54 +++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 18 deletions(-)
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 575d6d5b4294..a01330099e1a 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -39,6 +39,7 @@
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/pm_opp.h>
+#include <linux/power_supply.h>
#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/reset.h>
@@ -107,6 +108,7 @@
#define PMC_USB_DEBOUNCE_DEL 0xec
#define PMC_USB_AO 0xf0
+#define PMC_SCRATCH37 0x130
#define PMC_SCRATCH41 0x140
#define PMC_WAKE2_MASK 0x160
@@ -1064,10 +1066,8 @@ int tegra_pmc_cpu_remove_clamping(unsigned int cpuid)
return tegra_powergate_remove_clamping(id);
}
-static int tegra_pmc_restart_notify(struct notifier_block *this,
- unsigned long action, void *data)
+static void tegra_pmc_restart(const char *cmd)
{
- const char *cmd = data;
u32 value;
value = tegra_pmc_scratch_readl(pmc, pmc->soc->regs->scratch0);
@@ -1090,13 +1090,33 @@ static int tegra_pmc_restart_notify(struct notifier_block *this,
value = tegra_pmc_readl(pmc, PMC_CNTRL);
value |= PMC_CNTRL_MAIN_RST;
tegra_pmc_writel(pmc, value, PMC_CNTRL);
+}
- return NOTIFY_DONE;
+static void tegra_pmc_restart_handler(struct restart_data *data)
+{
+ tegra_pmc_restart(data->cmd);
}
-static struct notifier_block tegra_pmc_restart_handler = {
- .notifier_call = tegra_pmc_restart_notify,
- .priority = 128,
+static void tegra_pmc_power_off_handler(struct power_off_data *data)
+{
+ /*
+ * Reboot Nexus 7 into special bootloader mode if USB cable is
+ * connected in order to display battery status and power off.
+ */
+ if (of_machine_is_compatible("asus,grouper") &&
+ power_supply_is_system_supplied()) {
+ const u32 go_to_charger_mode = 0xa5a55a5a;
+
+ tegra_pmc_writel(pmc, go_to_charger_mode, PMC_SCRATCH37);
+ tegra_pmc_restart(NULL);
+ }
+}
+
+static struct power_handler tegra_pmc_power_handler = {
+ .restart_cb = tegra_pmc_restart_handler,
+ .power_off_cb = tegra_pmc_power_off_handler,
+ .power_off_priority = POWEROFF_PRIO_FIRMWARE,
+ .power_off_chaining_allowed = true,
};
static int powergate_show(struct seq_file *s, void *data)
@@ -2859,6 +2879,13 @@ static int tegra_pmc_probe(struct platform_device *pdev)
pmc->clk = NULL;
}
+ err = devm_register_power_handler(&pdev->dev, &tegra_pmc_power_handler);
+ if (err) {
+ dev_err(&pdev->dev, "unable to register power handler, %d\n",
+ err);
+ return err;
+ }
+
/*
* PCLK clock rate can't be retrieved using CLK API because it
* causes lockup if CPU enters LP2 idle state from some other
@@ -2890,20 +2917,13 @@ static int tegra_pmc_probe(struct platform_device *pdev)
goto cleanup_sysfs;
}
- err = register_restart_handler(&tegra_pmc_restart_handler);
- if (err) {
- dev_err(&pdev->dev, "unable to register restart handler, %d\n",
- err);
- goto cleanup_debugfs;
- }
-
err = tegra_pmc_pinctrl_init(pmc);
if (err)
- goto cleanup_restart_handler;
+ goto cleanup_debugfs;
err = tegra_pmc_regmap_init(pmc);
if (err < 0)
- goto cleanup_restart_handler;
+ goto cleanup_debugfs;
err = tegra_powergate_init(pmc, pdev->dev.of_node);
if (err < 0)
@@ -2926,8 +2946,6 @@ static int tegra_pmc_probe(struct platform_device *pdev)
cleanup_powergates:
tegra_powergate_remove_all(pdev->dev.of_node);
-cleanup_restart_handler:
- unregister_restart_handler(&tegra_pmc_restart_handler);
cleanup_debugfs:
debugfs_remove(pmc->debugfs);
cleanup_sysfs:
--
2.33.1
^ permalink raw reply related
* [PATCH v2 25/45] reboot: Remove pm_power_off_prepare()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
All pm_power_off_prepare() users were converted to power-handler API.
Remove the obsolete callback.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/pm.h | 1 -
kernel/reboot.c | 11 -----------
2 files changed, 12 deletions(-)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 1d8209c09686..d9bf1426f81e 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -20,7 +20,6 @@
* Callbacks for platform drivers to implement.
*/
extern void (*pm_power_off)(void);
-extern void (*pm_power_off_prepare)(void);
struct device; /* we have a circular dep with device.h */
#ifdef CONFIG_VT_CONSOLE_SLEEP
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 779429726616..9895bb56cee4 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -48,13 +48,6 @@ int reboot_cpu;
enum reboot_type reboot_type = BOOT_ACPI;
int reboot_force;
-/*
- * If set, this is used for preparing the system to power off.
- */
-
-void (*pm_power_off_prepare)(void);
-EXPORT_SYMBOL_GPL(pm_power_off_prepare);
-
/**
* emergency_restart - reboot the system
*
@@ -866,10 +859,6 @@ void do_kernel_power_off(void)
static void do_kernel_power_off_prepare(void)
{
- /* legacy pm_power_off_prepare() is unchained and it has highest priority */
- if (pm_power_off_prepare)
- return pm_power_off_prepare();
-
blocking_notifier_call_chain(&power_off_handler_list, POWEROFF_PREPARE,
NULL);
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 24/45] regulator: pfuze100: Use devm_register_power_handler()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Use devm_register_power_handler() that replaces global pm_power_off_prepare
variable and allows to register multiple power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/regulator/pfuze100-regulator.c | 39 ++++++++++----------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index d60d7d1b7fa2..73d5baf9d3ea 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -10,6 +10,7 @@
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#include <linux/platform_device.h>
+#include <linux/reboot.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/pfuze100.h>
@@ -76,6 +77,7 @@ struct pfuze_chip {
struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR];
struct pfuze_regulator *pfuze_regulators;
+ struct power_handler power_handler;
};
static const int pfuze100_swbst[] = {
@@ -569,10 +571,10 @@ static inline struct device_node *match_of_node(int index)
return pfuze_matches[index].of_node;
}
-static struct pfuze_chip *syspm_pfuze_chip;
-
-static void pfuze_power_off_prepare(void)
+static void pfuze_power_off_prepare(struct power_off_prep_data *data)
{
+ struct pfuze_chip *syspm_pfuze_chip = data->cb_data;
+
dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off");
/* Switch from default mode: APS/APS to APS/Off */
@@ -611,24 +613,24 @@ static void pfuze_power_off_prepare(void)
static int pfuze_power_off_prepare_init(struct pfuze_chip *pfuze_chip)
{
+ int err;
+
if (pfuze_chip->chip_id != PFUZE100) {
dev_warn(pfuze_chip->dev, "Requested pm_power_off_prepare handler for not supported chip\n");
return -ENODEV;
}
- if (pm_power_off_prepare) {
- dev_warn(pfuze_chip->dev, "pm_power_off_prepare is already registered.\n");
- return -EBUSY;
- }
+ pfuze_chip->power_handler.power_off_prepare_cb = pfuze_power_off_prepare;
+ pfuze_chip->power_handler.cb_data = pfuze_chip;
- if (syspm_pfuze_chip) {
- dev_warn(pfuze_chip->dev, "syspm_pfuze_chip is already set.\n");
- return -EBUSY;
+ err = devm_register_power_handler(pfuze_chip->dev,
+ &pfuze_chip->power_handler);
+ if (err) {
+ dev_err(pfuze_chip->dev,
+ "failed to register power handler: %d\n", err);
+ return err;
}
- syspm_pfuze_chip = pfuze_chip;
- pm_power_off_prepare = pfuze_power_off_prepare;
-
return 0;
}
@@ -837,23 +839,12 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
return 0;
}
-static int pfuze100_regulator_remove(struct i2c_client *client)
-{
- if (syspm_pfuze_chip) {
- syspm_pfuze_chip = NULL;
- pm_power_off_prepare = NULL;
- }
-
- return 0;
-}
-
static struct i2c_driver pfuze_driver = {
.driver = {
.name = "pfuze100-regulator",
.of_match_table = pfuze_dt_ids,
},
.probe = pfuze100_regulator_probe,
- .remove = pfuze100_regulator_remove,
};
module_i2c_driver(pfuze_driver);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 23/45] ACPI: power: Switch to power-handler API
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Switch to power-handler API that replaces legacy pm_power_off callbacks.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/acpi/sleep.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 3023224515ab..41b3ea867f8f 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -47,19 +47,11 @@ static void acpi_sleep_tts_switch(u32 acpi_state)
}
}
-static int tts_notify_reboot(struct notifier_block *this,
- unsigned long code, void *x)
+static void tts_reboot_prepare(struct reboot_prep_data *data)
{
acpi_sleep_tts_switch(ACPI_STATE_S5);
- return NOTIFY_DONE;
}
-static struct notifier_block tts_notifier = {
- .notifier_call = tts_notify_reboot,
- .next = NULL,
- .priority = 0,
-};
-
static int acpi_sleep_prepare(u32 acpi_state)
{
#ifdef CONFIG_ACPI_SLEEP
@@ -1016,7 +1008,7 @@ static void acpi_sleep_hibernate_setup(void)
static inline void acpi_sleep_hibernate_setup(void) {}
#endif /* !CONFIG_HIBERNATION */
-static void acpi_power_off_prepare(void)
+static void acpi_power_off_prepare(struct power_off_prep_data *data)
{
/* Prepare to power off the system */
acpi_sleep_prepare(ACPI_STATE_S5);
@@ -1024,7 +1016,7 @@ static void acpi_power_off_prepare(void)
acpi_os_wait_events_complete();
}
-static void acpi_power_off(void)
+static void acpi_power_off(struct power_off_data *data)
{
/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
pr_debug("%s called\n", __func__);
@@ -1032,6 +1024,11 @@ static void acpi_power_off(void)
acpi_enter_sleep_state(ACPI_STATE_S5);
}
+static struct power_handler acpi_power_handler = {
+ .power_off_priority = POWEROFF_PRIO_FIRMWARE,
+ .reboot_prepare_cb = tts_reboot_prepare,
+};
+
int __init acpi_sleep_init(void)
{
char supported[ACPI_S_STATE_COUNT * 3 + 1];
@@ -1048,8 +1045,8 @@ int __init acpi_sleep_init(void)
if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
sleep_states[ACPI_STATE_S5] = 1;
- pm_power_off_prepare = acpi_power_off_prepare;
- pm_power_off = acpi_power_off;
+ acpi_power_handler.power_off_cb = acpi_power_off;
+ acpi_power_handler.power_off_prepare_cb = acpi_power_off_prepare;
} else {
acpi_no_s5 = true;
}
@@ -1065,6 +1062,6 @@ int __init acpi_sleep_init(void)
* Register the tts_notifier to reboot notifier list so that the _TTS
* object can also be evaluated when the system enters S5.
*/
- register_reboot_notifier(&tts_notifier);
+ register_power_handler(&acpi_power_handler);
return 0;
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 22/45] memory: emif: Use kernel_can_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Replace legacy pm_power_off with kernel_can_power_off() helper that
is aware about chained power-off handlers.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/memory/emif.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index 762d0c0f0716..cab10d5274a0 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -630,7 +630,7 @@ static irqreturn_t emif_threaded_isr(int irq, void *dev_id)
dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n");
/* If we have Power OFF ability, use it, else try restarting */
- if (pm_power_off) {
+ if (kernel_can_power_off()) {
kernel_power_off();
} else {
WARN(1, "FIXME: NO pm_power_off!!! trying restart\n");
--
2.33.1
^ permalink raw reply related
* [PATCH v2 21/45] m68k: Switch to new power-handler API
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use
register_power_off_handler() that registers power-off handlers and
do_kernel_power_off() that invokes chained power-off handlers. Legacy
pm_power_off() will be removed once all drivers will be converted to
the new power-off API.
Normally arch code should adopt only the do_kernel_power_off() at first,
but m68k is a special case because it uses pm_power_off() "inside out",
i.e. pm_power_off() invokes machine_power_off() [in fact it does nothing],
while it's machine_power_off() that should invoke the pm_power_off(), and
thus, we can't convert platforms to the new API separately. There are only
two platforms changed here, so it's not a big deal.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/m68k/emu/natfeat.c | 3 ++-
arch/m68k/include/asm/machdep.h | 1 -
arch/m68k/kernel/process.c | 5 ++---
arch/m68k/kernel/setup_mm.c | 1 -
arch/m68k/kernel/setup_no.c | 1 -
arch/m68k/mac/config.c | 4 +++-
6 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c
index 71b78ecee75c..b19dc00026d9 100644
--- a/arch/m68k/emu/natfeat.c
+++ b/arch/m68k/emu/natfeat.c
@@ -15,6 +15,7 @@
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/reboot.h>
#include <linux/io.h>
#include <asm/machdep.h>
#include <asm/natfeat.h>
@@ -90,5 +91,5 @@ void __init nf_init(void)
pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16,
version & 0xffff);
- mach_power_off = nf_poweroff;
+ register_platform_power_off(nf_poweroff);
}
diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h
index 8fd80ef1b77e..8d8c3ee2069f 100644
--- a/arch/m68k/include/asm/machdep.h
+++ b/arch/m68k/include/asm/machdep.h
@@ -24,7 +24,6 @@ extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
extern void (*mach_reset)( void );
extern void (*mach_halt)( void );
-extern void (*mach_power_off)( void );
extern unsigned long (*mach_hd_init) (unsigned long, unsigned long);
extern void (*mach_hd_setup)(char *, int *);
extern void (*mach_heartbeat) (int);
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index a6030dbaa089..e160a7c57bd3 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -67,12 +67,11 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (mach_power_off)
- mach_power_off();
+ do_kernel_power_off();
for (;;);
}
-void (*pm_power_off)(void) = machine_power_off;
+void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);
void show_regs(struct pt_regs * regs)
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index 4b51bfd38e5f..50f4f120a4ff 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -98,7 +98,6 @@ EXPORT_SYMBOL(mach_get_rtc_pll);
EXPORT_SYMBOL(mach_set_rtc_pll);
void (*mach_reset)( void );
void (*mach_halt)( void );
-void (*mach_power_off)( void );
#ifdef CONFIG_HEARTBEAT
void (*mach_heartbeat) (int);
EXPORT_SYMBOL(mach_heartbeat);
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index 5e4104f07a44..00bf82258233 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -55,7 +55,6 @@ int (*mach_hwclk) (int, struct rtc_time*);
/* machine dependent reboot functions */
void (*mach_reset)(void);
void (*mach_halt)(void);
-void (*mach_power_off)(void);
#ifdef CONFIG_M68000
#if defined(CONFIG_M68328)
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 5d16f9b47aa9..727320dedf08 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -12,6 +12,7 @@
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/reboot.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/tty.h>
@@ -139,7 +140,6 @@ void __init config_mac(void)
mach_hwclk = mac_hwclk;
mach_reset = mac_reset;
mach_halt = mac_poweroff;
- mach_power_off = mac_poweroff;
#if IS_ENABLED(CONFIG_INPUT_M68K_BEEP)
mach_beep = mac_mksound;
#endif
@@ -159,6 +159,8 @@ void __init config_mac(void)
if (macintosh_config->ident == MAC_MODEL_IICI)
mach_l2_flush = via_l2_flush;
+
+ register_platform_power_off(mac_poweroff);
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 20/45] x86: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/x86/kernel/reboot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 0a40df66a40d..cd7d9416d81a 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -747,10 +747,10 @@ static void native_machine_halt(void)
static void native_machine_power_off(void)
{
- if (pm_power_off) {
+ if (kernel_can_power_off()) {
if (!reboot_force)
machine_shutdown();
- pm_power_off();
+ do_kernel_power_off();
}
/* A fallback in case there is no PM info available */
tboot_shutdown(TB_SHUTDOWN_HALT);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 19/45] sh: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/sh/kernel/reboot.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c
index 5c33f036418b..e8eeedc9b182 100644
--- a/arch/sh/kernel/reboot.c
+++ b/arch/sh/kernel/reboot.c
@@ -46,8 +46,7 @@ static void native_machine_shutdown(void)
static void native_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
static void native_machine_halt(void)
--
2.33.1
^ permalink raw reply related
* [PATCH v2 18/45] riscv: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/riscv/kernel/reset.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
index 9c842c41684a..912288572226 100644
--- a/arch/riscv/kernel/reset.c
+++ b/arch/riscv/kernel/reset.c
@@ -23,16 +23,12 @@ void machine_restart(char *cmd)
void machine_halt(void)
{
- if (pm_power_off != NULL)
- pm_power_off();
- else
- default_power_off();
+ do_kernel_power_off();
+ default_power_off();
}
void machine_power_off(void)
{
- if (pm_power_off != NULL)
- pm_power_off();
- else
- default_power_off();
+ do_kernel_power_off();
+ default_power_off();
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 17/45] powerpc: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/powerpc/kernel/setup-common.c | 4 +---
arch/powerpc/xmon/xmon.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 4f1322b65760..71c4ccd9bbb1 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -161,9 +161,7 @@ void machine_restart(char *cmd)
void machine_power_off(void)
{
machine_shutdown();
- if (pm_power_off)
- pm_power_off();
-
+ do_kernel_power_off();
smp_send_stop();
machine_hang();
}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index dd8241c009e5..9d835807d645 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1243,8 +1243,7 @@ static void bootcmds(void)
} else if (cmd == 'h') {
ppc_md.halt();
} else if (cmd == 'p') {
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
}
--
2.33.1
^ permalink raw reply related
* [PATCH v2 16/45] parisc: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/parisc/kernel/process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index ea3d83b6fb62..928201b1f58f 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/personality.h>
#include <linux/ptrace.h>
+#include <linux/reboot.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/task.h>
@@ -114,8 +115,7 @@ void machine_power_off(void)
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
/* ipmi_poweroff may have been installed. */
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
/* It seems we have no way to power the system off via
* software. The user has to press the button himself. */
--
2.33.1
^ permalink raw reply related
* [PATCH v2 15/45] nds32: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/nds32/kernel/process.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/nds32/kernel/process.c b/arch/nds32/kernel/process.c
index 49fab9e39cbf..0936dcd7db1b 100644
--- a/arch/nds32/kernel/process.c
+++ b/arch/nds32/kernel/process.c
@@ -54,8 +54,7 @@ EXPORT_SYMBOL(machine_halt);
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
EXPORT_SYMBOL(machine_power_off);
--
2.33.1
^ permalink raw reply related
* [PATCH v2 14/45] mips: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/mips/kernel/reset.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/mips/kernel/reset.c b/arch/mips/kernel/reset.c
index 6288780b779e..e7ce07b3e79b 100644
--- a/arch/mips/kernel/reset.c
+++ b/arch/mips/kernel/reset.c
@@ -114,8 +114,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
#ifdef CONFIG_SMP
preempt_disable();
--
2.33.1
^ permalink raw reply related
* [PATCH v2 13/45] ia64: Use do_kernel_power_off()
From: Dmitry Osipenko @ 2021-10-27 21:16 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Lee Jones, Rafael J . Wysocki,
Mark Brown, Andrew Morton, Guenter Roeck, Russell King,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson
Cc: Rich Felker, linux-ia64, Tomer Maimon, Santosh Shilimkar,
linux-sh, Boris Ostrovsky, Linus Walleij, Dave Hansen, linux-acpi,
Tali Perry, James E.J. Bottomley, Paul Mackerras, Pavel Machek,
H. Peter Anvin, linux-riscv, Vincent Chen, Will Deacon,
Greg Ungerer, Stefano Stabellini, Benjamin Fair, Yoshinori Sato,
Krzysztof Kozlowski, Helge Deller, x86, linux-csky, Tony Lindgren,
Chen-Yu Tsai, Ingo Molnar, Geert Uytterhoeven, Catalin Marinas,
xen-devel, linux-mips, Len Brown, Albert Ou, linux-pm,
Jonathan Neuschäfer, Vladimir Zapolskiy, linux-m68k,
Borislav Petkov, Greentime Hu, Paul Walmsley, linux-tegra,
Thomas Gleixner, linux-omap, Nancy Yuen, linux-arm-kernel,
Juergen Gross, Thomas Bogendoerfer, linux-parisc, Nick Hu,
Avi Fishman, Patrick Venture, Liam Girdwood, linux-kernel,
Palmer Dabbelt, Philipp Zabel, Guo Ren, linuxppc-dev, openbmc,
Joshua Thompson
In-Reply-To: <20211027211715.12671-1-digetx@gmail.com>
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/ia64/kernel/process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 834df24a88f1..cee4d7db2143 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/personality.h>
+#include <linux/reboot.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/hotplug.h>
@@ -599,8 +600,7 @@ machine_halt (void)
void
machine_power_off (void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
machine_halt();
}
--
2.33.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox