Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joachim Eastwood and committed by
Philipp Zabel
773fe726 0b52297f

+10 -12
+10 -12
drivers/reset/reset-lpc18xx.c
··· 35 35 36 36 struct lpc18xx_rgu_data { 37 37 struct reset_controller_dev rcdev; 38 + struct notifier_block restart_nb; 38 39 struct clk *clk_delay; 39 40 struct clk *clk_reg; 40 41 void __iomem *base; ··· 45 44 46 45 #define to_rgu_data(p) container_of(p, struct lpc18xx_rgu_data, rcdev) 47 46 48 - static void __iomem *rgu_base; 49 - 50 - static int lpc18xx_rgu_restart(struct notifier_block *this, unsigned long mode, 47 + static int lpc18xx_rgu_restart(struct notifier_block *nb, unsigned long mode, 51 48 void *cmd) 52 49 { 53 - writel(BIT(LPC18XX_RGU_CORE_RST), rgu_base + LPC18XX_RGU_CTRL0); 50 + struct lpc18xx_rgu_data *rc = container_of(nb, struct lpc18xx_rgu_data, 51 + restart_nb); 52 + 53 + writel(BIT(LPC18XX_RGU_CORE_RST), rc->base + LPC18XX_RGU_CTRL0); 54 54 mdelay(2000); 55 55 56 56 pr_emerg("%s: unable to restart system\n", __func__); 57 57 58 58 return NOTIFY_DONE; 59 59 } 60 - 61 - static struct notifier_block lpc18xx_rgu_restart_nb = { 62 - .notifier_call = lpc18xx_rgu_restart, 63 - .priority = 192, 64 - }; 65 60 66 61 /* 67 62 * The LPC18xx RGU has mostly self-deasserting resets except for the ··· 202 205 goto dis_clks; 203 206 } 204 207 205 - rgu_base = rc->base; 206 - ret = register_restart_handler(&lpc18xx_rgu_restart_nb); 208 + rc->restart_nb.priority = 192, 209 + rc->restart_nb.notifier_call = lpc18xx_rgu_restart, 210 + ret = register_restart_handler(&rc->restart_nb); 207 211 if (ret) 208 212 dev_warn(&pdev->dev, "failed to register restart handler\n"); 209 213 ··· 223 225 struct lpc18xx_rgu_data *rc = platform_get_drvdata(pdev); 224 226 int ret; 225 227 226 - ret = unregister_restart_handler(&lpc18xx_rgu_restart_nb); 228 + ret = unregister_restart_handler(&rc->restart_nb); 227 229 if (ret) 228 230 dev_warn(&pdev->dev, "failed to unregister restart handler\n"); 229 231