diff options
author | Joachim Eastwood <manabian@gmail.com> | 2016-02-20 14:06:49 -0500 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2016-03-30 09:42:07 -0400 |
commit | 773fe72630c8aca874ec8a07ebacace4ae305a02 (patch) | |
tree | e9dd74a807df1e5aa97f246d5367531c4b6a5b57 | |
parent | 0b52297f2288ca239e598afe6c92db83d8d2bfcd (diff) |
reset: lpc18xx: get rid of global variables for restart notifier
Moving the notifier_block into the drivers priv struct allows us
to retrive the priv struct with container_of and remove the
global variables.
Signed-off-by: Joachim Eastwood <manabian@gmail.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r-- | drivers/reset/reset-lpc18xx.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/reset/reset-lpc18xx.c b/drivers/reset/reset-lpc18xx.c index 3b8a4f5a1ff6..54cca0055171 100644 --- a/drivers/reset/reset-lpc18xx.c +++ b/drivers/reset/reset-lpc18xx.c | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | struct lpc18xx_rgu_data { | 36 | struct lpc18xx_rgu_data { |
37 | struct reset_controller_dev rcdev; | 37 | struct reset_controller_dev rcdev; |
38 | struct notifier_block restart_nb; | ||
38 | struct clk *clk_delay; | 39 | struct clk *clk_delay; |
39 | struct clk *clk_reg; | 40 | struct clk *clk_reg; |
40 | void __iomem *base; | 41 | void __iomem *base; |
@@ -44,12 +45,13 @@ struct lpc18xx_rgu_data { | |||
44 | 45 | ||
45 | #define to_rgu_data(p) container_of(p, struct lpc18xx_rgu_data, rcdev) | 46 | #define to_rgu_data(p) container_of(p, struct lpc18xx_rgu_data, rcdev) |
46 | 47 | ||
47 | static void __iomem *rgu_base; | 48 | static int lpc18xx_rgu_restart(struct notifier_block *nb, unsigned long mode, |
48 | |||
49 | static int lpc18xx_rgu_restart(struct notifier_block *this, unsigned long mode, | ||
50 | void *cmd) | 49 | void *cmd) |
51 | { | 50 | { |
52 | writel(BIT(LPC18XX_RGU_CORE_RST), rgu_base + LPC18XX_RGU_CTRL0); | 51 | struct lpc18xx_rgu_data *rc = container_of(nb, struct lpc18xx_rgu_data, |
52 | restart_nb); | ||
53 | |||
54 | writel(BIT(LPC18XX_RGU_CORE_RST), rc->base + LPC18XX_RGU_CTRL0); | ||
53 | mdelay(2000); | 55 | mdelay(2000); |
54 | 56 | ||
55 | pr_emerg("%s: unable to restart system\n", __func__); | 57 | pr_emerg("%s: unable to restart system\n", __func__); |
@@ -57,11 +59,6 @@ static int lpc18xx_rgu_restart(struct notifier_block *this, unsigned long mode, | |||
57 | return NOTIFY_DONE; | 59 | return NOTIFY_DONE; |
58 | } | 60 | } |
59 | 61 | ||
60 | static struct notifier_block lpc18xx_rgu_restart_nb = { | ||
61 | .notifier_call = lpc18xx_rgu_restart, | ||
62 | .priority = 192, | ||
63 | }; | ||
64 | |||
65 | /* | 62 | /* |
66 | * The LPC18xx RGU has mostly self-deasserting resets except for the | 63 | * The LPC18xx RGU has mostly self-deasserting resets except for the |
67 | * two reset lines going to the internal Cortex-M0 cores. | 64 | * two reset lines going to the internal Cortex-M0 cores. |
@@ -205,8 +202,9 @@ static int lpc18xx_rgu_probe(struct platform_device *pdev) | |||
205 | goto dis_clks; | 202 | goto dis_clks; |
206 | } | 203 | } |
207 | 204 | ||
208 | rgu_base = rc->base; | 205 | rc->restart_nb.priority = 192, |
209 | ret = register_restart_handler(&lpc18xx_rgu_restart_nb); | 206 | rc->restart_nb.notifier_call = lpc18xx_rgu_restart, |
207 | ret = register_restart_handler(&rc->restart_nb); | ||
210 | if (ret) | 208 | if (ret) |
211 | dev_warn(&pdev->dev, "failed to register restart handler\n"); | 209 | dev_warn(&pdev->dev, "failed to register restart handler\n"); |
212 | 210 | ||
@@ -225,7 +223,7 @@ static int lpc18xx_rgu_remove(struct platform_device *pdev) | |||
225 | struct lpc18xx_rgu_data *rc = platform_get_drvdata(pdev); | 223 | struct lpc18xx_rgu_data *rc = platform_get_drvdata(pdev); |
226 | int ret; | 224 | int ret; |
227 | 225 | ||
228 | ret = unregister_restart_handler(&lpc18xx_rgu_restart_nb); | 226 | ret = unregister_restart_handler(&rc->restart_nb); |
229 | if (ret) | 227 | if (ret) |
230 | dev_warn(&pdev->dev, "failed to unregister restart handler\n"); | 228 | dev_warn(&pdev->dev, "failed to unregister restart handler\n"); |
231 | 229 | ||