diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-09-30 13:48:32 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2014-11-16 21:07:09 -0500 |
commit | 8f57f2310f6b5f787a29e4eb440afd8b3f6b2554 (patch) | |
tree | 3798effb74187f9c7814525b73bd406e08d5c618 | |
parent | 745e19764a0cff55a55010cfabe7e9ff77fa72a5 (diff) |
power/reset: xgene: Register with kernel restart handler
Register with kernel restart handler instead of setting arm_pm_restart directly.
This patch also addresses the following compile warning.
drivers/power/reset/xgene-reboot.c: In function 'xgene_reboot_probe':
drivers/power/reset/xgene-reboot.c:77:17: warning:
assignment from incompatible pointer type [enabled by default]
The warning was due to a mismatch between the type of arm_pm_restart
and the restart function.
Cc: Loc Ho <lho@apm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/power/reset/xgene-reboot.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c index 9da341d11caf..b0e5002f8deb 100644 --- a/drivers/power/reset/xgene-reboot.c +++ b/drivers/power/reset/xgene-reboot.c | |||
@@ -26,38 +26,43 @@ | |||
26 | */ | 26 | */ |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/notifier.h> | ||
29 | #include <linux/of_device.h> | 30 | #include <linux/of_device.h> |
30 | #include <linux/of_address.h> | 31 | #include <linux/of_address.h> |
31 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
33 | #include <linux/reboot.h> | ||
32 | #include <linux/stat.h> | 34 | #include <linux/stat.h> |
33 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
34 | #include <asm/system_misc.h> | ||
35 | 36 | ||
36 | struct xgene_reboot_context { | 37 | struct xgene_reboot_context { |
37 | struct device *dev; | 38 | struct device *dev; |
38 | void *csr; | 39 | void *csr; |
39 | u32 mask; | 40 | u32 mask; |
41 | struct notifier_block restart_handler; | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | static struct xgene_reboot_context *xgene_restart_ctx; | 44 | static int xgene_restart_handler(struct notifier_block *this, |
43 | 45 | unsigned long mode, void *cmd) | |
44 | static void xgene_restart(enum reboot_mode mode, const char *cmd) | ||
45 | { | 46 | { |
46 | struct xgene_reboot_context *ctx = xgene_restart_ctx; | 47 | struct xgene_reboot_context *ctx = |
48 | container_of(this, struct xgene_reboot_context, | ||
49 | restart_handler); | ||
47 | 50 | ||
48 | /* Issue the reboot */ | 51 | /* Issue the reboot */ |
49 | if (ctx) | 52 | writel(ctx->mask, ctx->csr); |
50 | writel(ctx->mask, ctx->csr); | ||
51 | 53 | ||
52 | mdelay(1000); | 54 | mdelay(1000); |
53 | 55 | ||
54 | dev_emerg(ctx->dev, "Unable to restart system\n"); | 56 | dev_emerg(ctx->dev, "Unable to restart system\n"); |
57 | |||
58 | return NOTIFY_DONE; | ||
55 | } | 59 | } |
56 | 60 | ||
57 | static int xgene_reboot_probe(struct platform_device *pdev) | 61 | static int xgene_reboot_probe(struct platform_device *pdev) |
58 | { | 62 | { |
59 | struct xgene_reboot_context *ctx; | 63 | struct xgene_reboot_context *ctx; |
60 | struct device *dev = &pdev->dev; | 64 | struct device *dev = &pdev->dev; |
65 | int err; | ||
61 | 66 | ||
62 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); | 67 | ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); |
63 | if (!ctx) | 68 | if (!ctx) |
@@ -73,10 +78,13 @@ static int xgene_reboot_probe(struct platform_device *pdev) | |||
73 | ctx->mask = 0xFFFFFFFF; | 78 | ctx->mask = 0xFFFFFFFF; |
74 | 79 | ||
75 | ctx->dev = dev; | 80 | ctx->dev = dev; |
76 | arm_pm_restart = xgene_restart; | 81 | ctx->restart_handler.notifier_call = xgene_restart_handler; |
77 | xgene_restart_ctx = ctx; | 82 | ctx->restart_handler.priority = 128; |
83 | err = register_restart_handler(&ctx->restart_handler); | ||
84 | if (err) | ||
85 | dev_err(dev, "cannot register restart handler (err=%d)\n", err); | ||
78 | 86 | ||
79 | return 0; | 87 | return err; |
80 | } | 88 | } |
81 | 89 | ||
82 | static struct of_device_id xgene_reboot_of_match[] = { | 90 | static struct of_device_id xgene_reboot_of_match[] = { |