diff mbox

[10/11] max8907: use the common machine reset handling

Message ID 20131031063000.859976312@linux.com (mailing list archive)
State New, archived
Headers show

Commit Message

Domenico Andreoli Oct. 31, 2013, 6:27 a.m. UTC
From: Domenico Andreoli <domenico.andreoli@linux.com>

Proof of concept: max8907 as provider of reset hooks.

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
---
 drivers/mfd/Kconfig   |    1 +
 drivers/mfd/max8907.c |   13 ++++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
diff mbox

Patch

Index: b/drivers/mfd/Kconfig
===================================================================
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -339,6 +339,7 @@  config MFD_MAX8907
 	tristate "Maxim Semiconductor MAX8907 PMIC Support"
 	select MFD_CORE
 	depends on I2C=y
+	select MACHINE_RESET
 	select REGMAP_I2C
 	select REGMAP_IRQ
 	help
Index: b/drivers/mfd/max8907.c
===================================================================
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -20,6 +20,7 @@ 
 #include <linux/of_device.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/machine_reset.h>
 
 static struct mfd_cell max8907_cells[] = {
 	{ .name = "max8907-regulator", },
@@ -176,9 +177,9 @@  static const struct regmap_irq_chip max8
 	.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 *dev)
 {
+	struct max8907 *max8907_pm_off = dev;
 	regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG,
 			MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF);
 }
@@ -266,9 +267,11 @@  static int max8907_i2c_probe(struct i2c_
 		goto err_add_devices;
 	}
 
-	if (pm_off && !pm_power_off) {
-		max8907_pm_off = max8907;
-		pm_power_off = max8907_power_off;
+	if (pm_off) {
+		struct reset_hook hook;
+		reset_hook_init(&hook);
+		hook.power_off = max8907_power_off;
+		set_machine_reset(RESET_POWER_OFF, &hook, max8907);
 	}
 
 	return 0;