[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 31/45] mfd: axp20x: Use register_simple_power_off_handler()
- To: Thierry Reding <thierry.reding@xxxxxxxxx>, Jonathan Hunter <jonathanh@xxxxxxxxxx>, Lee Jones <lee.jones@xxxxxxxxxx>, "Rafael J . Wysocki" <rafael@xxxxxxxxxx>, Mark Brown <broonie@xxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Guenter Roeck <linux@xxxxxxxxxxxx>, Russell King <linux@xxxxxxxxxxxxxxx>, Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>, Ulf Hansson <ulf.hansson@xxxxxxxxxx>
- From: Dmitry Osipenko <digetx@xxxxxxxxx>
- Date: Thu, 28 Oct 2021 00:17:01 +0300
- Cc: Catalin Marinas <catalin.marinas@xxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Guo Ren <guoren@xxxxxxxxxx>, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>, Greg Ungerer <gerg@xxxxxxxxxxxxxx>, Joshua Thompson <funaho@xxxxxxxxx>, Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>, Nick Hu <nickhu@xxxxxxxxxxxxx>, Greentime Hu <green.hu@xxxxxxxxx>, Vincent Chen <deanbo422@xxxxxxxxx>, "James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>, Helge Deller <deller@xxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>, Paul Mackerras <paulus@xxxxxxxxx>, Paul Walmsley <paul.walmsley@xxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Albert Ou <aou@xxxxxxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Rich Felker <dalias@xxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, "H. Peter Anvin" <hpa@xxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Len Brown <lenb@xxxxxxxxxx>, Santosh Shilimkar <ssantosh@xxxxxxxxxx>, Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxx>, Linus Walleij <linus.walleij@xxxxxxxxxx>, Chen-Yu Tsai <wens@xxxxxxxx>, Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>, Tony Lindgren <tony@xxxxxxxxxxx>, Liam Girdwood <lgirdwood@xxxxxxxxx>, Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>, Vladimir Zapolskiy <vz@xxxxxxxxx>, Avi Fishman <avifishman70@xxxxxxxxx>, Tomer Maimon <tmaimon77@xxxxxxxxx>, Tali Perry <tali.perry1@xxxxxxxxx>, Patrick Venture <venture@xxxxxxxxxx>, Nancy Yuen <yuenn@xxxxxxxxxx>, Benjamin Fair <benjaminfair@xxxxxxxxxx>, Pavel Machek <pavel@xxxxxx>, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-csky@xxxxxxxxxxxxxxx, linux-ia64@xxxxxxxxxxxxxxx, linux-m68k@xxxxxxxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-parisc@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-riscv@xxxxxxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx, linux-omap@xxxxxxxxxxxxxxx, openbmc@xxxxxxxxxxxxxxxx, linux-tegra@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx
- Delivery-date: Wed, 27 Oct 2021 21:28:46 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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@xxxxxxxxx>
---
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
|