diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-09-30 13:48:27 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2014-11-16 21:07:08 -0500 |
commit | 46c99ac66222aed719f26835eae4946d72880cbe (patch) | |
tree | fbb0ea8bd982e2d8c1c92d35af4f94fb4ecbb16d /drivers/power/reset/vexpress-poweroff.c | |
parent | b8e64eea41ea71b58e61e35ee347464efd60ca21 (diff) |
power/reset: vexpress: Register with kernel restart handler
Use the kernel restart handler instead of setting arm_pm_restart directly.
This allows for more than one restart handler in the system.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/power/reset/vexpress-poweroff.c')
-rw-r--r-- | drivers/power/reset/vexpress-poweroff.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c index 4dc102e2b230..9dfc9cee3232 100644 --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c | |||
@@ -12,14 +12,14 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/notifier.h> | ||
15 | #include <linux/of.h> | 16 | #include <linux/of.h> |
16 | #include <linux/of_device.h> | 17 | #include <linux/of_device.h> |
17 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/reboot.h> | ||
18 | #include <linux/stat.h> | 20 | #include <linux/stat.h> |
19 | #include <linux/vexpress.h> | 21 | #include <linux/vexpress.h> |
20 | 22 | ||
21 | #include <asm/system_misc.h> | ||
22 | |||
23 | static void vexpress_reset_do(struct device *dev, const char *what) | 23 | static void vexpress_reset_do(struct device *dev, const char *what) |
24 | { | 24 | { |
25 | int err = -ENOENT; | 25 | int err = -ENOENT; |
@@ -43,11 +43,19 @@ static void vexpress_power_off(void) | |||
43 | 43 | ||
44 | static struct device *vexpress_restart_device; | 44 | static struct device *vexpress_restart_device; |
45 | 45 | ||
46 | static void vexpress_restart(enum reboot_mode reboot_mode, const char *cmd) | 46 | static int vexpress_restart(struct notifier_block *this, unsigned long mode, |
47 | void *cmd) | ||
47 | { | 48 | { |
48 | vexpress_reset_do(vexpress_restart_device, "restart"); | 49 | vexpress_reset_do(vexpress_restart_device, "restart"); |
50 | |||
51 | return NOTIFY_DONE; | ||
49 | } | 52 | } |
50 | 53 | ||
54 | static struct notifier_block vexpress_restart_nb = { | ||
55 | .notifier_call = vexpress_restart, | ||
56 | .priority = 128, | ||
57 | }; | ||
58 | |||
51 | static ssize_t vexpress_reset_active_show(struct device *dev, | 59 | static ssize_t vexpress_reset_active_show(struct device *dev, |
52 | struct device_attribute *attr, char *buf) | 60 | struct device_attribute *attr, char *buf) |
53 | { | 61 | { |
@@ -86,12 +94,28 @@ static struct of_device_id vexpress_reset_of_match[] = { | |||
86 | {} | 94 | {} |
87 | }; | 95 | }; |
88 | 96 | ||
97 | static int _vexpress_register_restart_handler(struct device *dev) | ||
98 | { | ||
99 | int err; | ||
100 | |||
101 | vexpress_restart_device = dev; | ||
102 | err = register_restart_handler(&vexpress_restart_nb); | ||
103 | if (err) { | ||
104 | dev_err(dev, "cannot register restart handler (err=%d)\n", err); | ||
105 | return err; | ||
106 | } | ||
107 | device_create_file(dev, &dev_attr_active); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
89 | static int vexpress_reset_probe(struct platform_device *pdev) | 112 | static int vexpress_reset_probe(struct platform_device *pdev) |
90 | { | 113 | { |
91 | enum vexpress_reset_func func; | 114 | enum vexpress_reset_func func; |
92 | const struct of_device_id *match = | 115 | const struct of_device_id *match = |
93 | of_match_device(vexpress_reset_of_match, &pdev->dev); | 116 | of_match_device(vexpress_reset_of_match, &pdev->dev); |
94 | struct regmap *regmap; | 117 | struct regmap *regmap; |
118 | int ret = 0; | ||
95 | 119 | ||
96 | if (match) | 120 | if (match) |
97 | func = (enum vexpress_reset_func)match->data; | 121 | func = (enum vexpress_reset_func)match->data; |
@@ -110,18 +134,14 @@ static int vexpress_reset_probe(struct platform_device *pdev) | |||
110 | break; | 134 | break; |
111 | case FUNC_RESET: | 135 | case FUNC_RESET: |
112 | if (!vexpress_restart_device) | 136 | if (!vexpress_restart_device) |
113 | vexpress_restart_device = &pdev->dev; | 137 | ret = _vexpress_register_restart_handler(&pdev->dev); |
114 | arm_pm_restart = vexpress_restart; | ||
115 | device_create_file(&pdev->dev, &dev_attr_active); | ||
116 | break; | 138 | break; |
117 | case FUNC_REBOOT: | 139 | case FUNC_REBOOT: |
118 | vexpress_restart_device = &pdev->dev; | 140 | ret = _vexpress_register_restart_handler(&pdev->dev); |
119 | arm_pm_restart = vexpress_restart; | ||
120 | device_create_file(&pdev->dev, &dev_attr_active); | ||
121 | break; | 141 | break; |
122 | }; | 142 | }; |
123 | 143 | ||
124 | return 0; | 144 | return ret; |
125 | } | 145 | } |
126 | 146 | ||
127 | static const struct platform_device_id vexpress_reset_id_table[] = { | 147 | static const struct platform_device_id vexpress_reset_id_table[] = { |