watchdog: asm9260_wdt: Use watchdog core to install restart handler
Subsystems (4)
Guenter Roeck
maintainerPATCH v2 1/4 watchdog: asm9260_wdt: Use watchdog core to install restart handler
Use the infrastructure provided by the watchdog core to install the restart handler.
---
v2: Need to call watchdog_set_restart_priority()
drivers/watchdog/asm9260_wdt.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/watchdog/asm9260_wdt.c +7 -15
@@ -14,7 +14,6 @@#include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> -#include <linux/reboot.h> #include <linux/reset.h> #include <linux/watchdog.h>
@@ -59,7 +58,6 @@ struct asm9260_wdt_priv {struct clk *clk;struct clk *clk_ahb;struct reset_control *rst; -struct notifier_block restart_handler;void __iomem *iobase;int irq;
@@ -172,15 +170,14 @@ static irqreturn_t asm9260_wdt_irq(int irq, void *devid)return IRQ_HANDLED ; } -static int asm9260_restart_handler (struct notifier_block *this, -unsigned long mode,void *cmd) +static int asm9260_restart (struct watchdog_device *wdd,unsigned long action, +void *data) { -struct asm9260_wdt_priv *priv = - container_of(this, struct asm9260_wdt_priv, restart_handler); +struct asm9260_wdt_priv *priv =watchdog_get_drvdata (wdd);asm9260_wdt_sys_reset (priv); -return NOTIFY_DONE ; +return 0 ; }static const struct watchdog_info asm9260_wdt_ident = {
@@ -196,6 +193,7 @@ static struct watchdog_ops asm9260_wdt_ops = { .get_timeleft = asm9260_wdt_gettimeleft, .ping = asm9260_wdt_feed, .set_timeout = asm9260_wdt_settimeout, + .restart = asm9260_restart, };static int asm9260_wdt_get_dt_clks (struct asm9260_wdt_priv *priv)
@@ -335,18 +333,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev)dev_warn (&pdev->dev,"failed to request IRQ\n" ); } +watchdog_set_restart_priority (wdd,128 ); + ret =watchdog_register_device (wdd);if (ret) goto clk_off;platform_set_drvdata (pdev, priv); - priv->restart_handler.notifier_call = asm9260_restart_handler; - priv->restart_handler.priority =128 ; - ret =register_restart_handler (&priv->restart_handler); -if (ret) -dev_warn (&pdev->dev,"cannot register restart handler\n" ); -dev_info (&pdev->dev,"Watchdog enabled (timeout: %d sec, mode: %s)\n" , wdd->timeout, mode_name[priv->mode]);return 0 ;
@@ -370,8 +364,6 @@ static int asm9260_wdt_remove(struct platform_device *pdev)asm9260_wdt_disable (&priv->wdd); -unregister_restart_handler (&priv->restart_handler); -watchdog_unregister_device (&priv->wdd);clk_disable_unprepare (priv->clk);
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH v2 2/4 watchdog: bcm2835_wdt: Use watchdog core to install restart handler
Use the infrastructure provided by the watchdog core to install the restart handler.
---
v2: Need to call watchdog_set_restart_priority()
drivers/watchdog/bcm2835_wdt.c | 57 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 27 deletions(-)
drivers/watchdog/bcm2835_wdt.c +30 -27
@@ -14,7 +14,6 @@*/ #include <linux/delay.h> -#include <linux/reboot.h> #include <linux/types.h> #include <linux/module.h> #include <linux/io.h>
@@ -49,7 +48,6 @@struct bcm2835_wdt {void __iomem *base;spinlock_t lock; -struct notifier_block restart_handler; };static unsigned int heartbeat;
@@ -99,11 +97,37 @@ static unsigned int bcm2835_wdt_get_timeleft(struct watchdog_device *wdog)return WDOG_TICKS_TO_SECS (ret &PM_WDOG_TIME_SET ); } +static void __bcm2835_restart (struct bcm2835_wdt *wdt) +{ +u32 val; + +/* use a timeout of 10 ticks (~150us) */ +writel_relaxed (10 |PM_PASSWORD , wdt->base +PM_WDOG ); + val =readl_relaxed (wdt->base +PM_RSTC ); + val &=PM_RSTC_WRCFG_CLR ; + val |=PM_PASSWORD |PM_RSTC_WRCFG_FULL_RESET ; +writel_relaxed (val, wdt->base +PM_RSTC ); + +/* No sleeping, possibly atomic. */ +mdelay (1 ); +} + +static int bcm2835_restart (struct watchdog_device *wdog, +unsigned long action,void *data) +{ +struct bcm2835_wdt *wdt =watchdog_get_drvdata (wdog); + +__bcm2835_restart (wdt); + +return 0 ; +} +static const struct watchdog_ops bcm2835_wdt_ops = { .owner =THIS_MODULE , .start = bcm2835_wdt_start, .stop = bcm2835_wdt_stop, .get_timeleft = bcm2835_wdt_get_timeleft, + .restart = bcm2835_restart, };static const struct watchdog_info bcm2835_wdt_info = {
@@ -120,26 +144,6 @@ static struct watchdog_device bcm2835_wdt_wdd = { .timeout = WDOG_TICKS_TO_SECS(PM_WDOG_TIME_SET), }; -static int -bcm2835_restart (struct notifier_block *this,unsigned long mode,void *cmd) -{ - struct bcm2835_wdt *wdt = container_of(this, struct bcm2835_wdt, - restart_handler); -u32 val; - -/* use a timeout of 10 ticks (~150us) */ -writel_relaxed (10 |PM_PASSWORD , wdt->base +PM_WDOG ); - val =readl_relaxed (wdt->base +PM_RSTC ); - val &=PM_RSTC_WRCFG_CLR ; - val |=PM_PASSWORD |PM_RSTC_WRCFG_FULL_RESET ; -writel_relaxed (val, wdt->base +PM_RSTC ); - -/* No sleeping, possibly atomic. */ -mdelay (1 ); - -return 0 ; -} -/* * We can't really power off, but if we do the normal reset scheme, and * indicate to bootcode.bin not to reboot, then most of the chip will be
@@ -163,7 +167,7 @@ static void bcm2835_power_off(void)writel_relaxed (val, wdt->base +PM_RSTS );/* Continue with normal reset mechanism */ -bcm2835_restart (&wdt->restart_handler,REBOOT_HARD ,NULL ); +__bcm2835_restart (wdt); }static int bcm2835_wdt_probe (struct platform_device *pdev)
@@ -201,6 +205,9 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)*/ set_bit (WDOG_HW_RUNNING , &bcm2835_wdt_wdd.status); } + +watchdog_set_restart_priority (&bcm2835_wdt_wdd,128 ); + err =watchdog_register_device (&bcm2835_wdt_wdd);if (err) {dev_err (dev,"Failed to register watchdog device" );
@@ -208,9 +215,6 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)return err; } - wdt->restart_handler.notifier_call = bcm2835_restart; - wdt->restart_handler.priority =128 ; -register_restart_handler (&wdt->restart_handler);if (pm_power_off ==NULL ) pm_power_off = bcm2835_power_off;
@@ -222,7 +226,6 @@ static int bcm2835_wdt_remove(struct platform_device *pdev) {struct bcm2835_wdt *wdt =platform_get_drvdata (pdev); -unregister_restart_handler (&wdt->restart_handler);if (pm_power_off == bcm2835_power_off) pm_power_off =NULL ;watchdog_unregister_device (&bcm2835_wdt_wdd);
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH v2 3/4 watchdog: dw_wdt: Use watchdog core to install restart handler
In reply to Guenter RoeckUse the infrastructure provided by the watchdog core to install the restart handler.
---
v2: Need to call watchdog_set_restart_priority()
drivers/watchdog/dw_wdt.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/watchdog/dw_wdt.c +7 -16
@@ -26,11 +26,9 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/notifier.h> #include <linux/of.h> #include <linux/pm.h> #include <linux/platform_device.h> -#include <linux/reboot.h> #include <linux/watchdog.h> #define WDOG_CONTROL_REG_OFFSET 0x00
@@ -55,7 +53,6 @@ struct dw_wdt {void __iomem *regs;struct clk *clk;unsigned long rate; -struct notifier_block restart_handler;struct watchdog_device wdd; };
@@ -136,14 +133,12 @@ static int dw_wdt_start(struct watchdog_device *wdd)return 0 ; } -static int dw_wdt_restart_handle (struct notifier_block *this, -unsigned long mode,void *cmd) +static int dw_wdt_restart (struct watchdog_device *wdd, +unsigned long action,void *data) { -struct dw_wdt *dw_wdt; +struct dw_wdt *dw_wdt =to_dw_wdt (wdd);u32 val; - dw_wdt = container_of(this, struct dw_wdt, restart_handler); -writel (0 , dw_wdt->regs +WDOG_TIMEOUT_RANGE_REG_OFFSET ); val =readl (dw_wdt->regs +WDOG_CONTROL_REG_OFFSET );if (val &WDOG_CONTROL_REG_WDT_EN_MASK )
@@ -156,7 +151,7 @@ static int dw_wdt_restart_handle(struct notifier_block *this,/* wait for reset to assert... */ mdelay (500 ); -return NOTIFY_DONE ; +return 0 ; }static unsigned int dw_wdt_get_timeleft (struct watchdog_device *wdd)
@@ -179,6 +174,7 @@ static const struct watchdog_ops dw_wdt_ops = { .ping = dw_wdt_ping, .set_timeout = dw_wdt_set_timeout, .get_timeleft = dw_wdt_get_timeleft, + .restart = dw_wdt_restart, };#ifdef CONFIG_PM_SLEEP
@@ -265,16 +261,12 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dw_wdt); +watchdog_set_restart_priority (wdd,128 ); + ret =watchdog_register_device (wdd);if (ret) goto out_disable_clk; - dw_wdt->restart_handler.notifier_call = dw_wdt_restart_handle; - dw_wdt->restart_handler.priority =128 ; - ret =register_restart_handler (&dw_wdt->restart_handler); -if (ret) -pr_warn ("cannot register restart handler\n" ); -return 0 ; out_disable_clk:
@@ -286,7 +278,6 @@ static int dw_wdt_drv_remove(struct platform_device *pdev) {struct dw_wdt *dw_wdt =platform_get_drvdata (pdev); -unregister_restart_handler (&dw_wdt->restart_handler);watchdog_unregister_device (&dw_wdt->wdd);clk_disable_unprepare (dw_wdt->clk);
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH v2 4/4 watchdog: tangox: Use watchdog core to install restart handler
In reply to Guenter RoeckUse the infrastructure provided by the watchdog core to install the restart handler.
---
v2: Need to call watchdog_set_restart_priority()
drivers/watchdog/tangox_wdt.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-)
drivers/watchdog/tangox_wdt.c +13 -21
@@ -15,9 +15,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/notifier.h> #include <linux/platform_device.h> -#include <linux/reboot.h> #include <linux/watchdog.h> #define DEFAULT_TIMEOUT 30
@@ -47,7 +45,6 @@ struct tangox_wdt_device {void __iomem *base;unsigned long clk_rate;struct clk *clk; -struct notifier_block restart; }; static int tangox_wdt_set_timeout(struct watchdog_device *wdt,
@@ -96,24 +93,24 @@ static const struct watchdog_info tangox_wdt_info = { .identity = "tangox watchdog", }; +static int tangox_wdt_restart (struct watchdog_device *wdt, +unsigned long action,void *data) +{ +struct tangox_wdt_device *dev =watchdog_get_drvdata (wdt); + +writel (1 , dev->base +WD_COUNTER ); + +return 0 ; +} +static const struct watchdog_ops tangox_wdt_ops = { .start = tangox_wdt_start, .stop = tangox_wdt_stop, .set_timeout = tangox_wdt_set_timeout, .get_timeleft = tangox_wdt_get_timeleft, + .restart = tangox_wdt_restart, }; -static int tangox_wdt_restart (struct notifier_block *nb,unsigned long action, -void *data) -{ -struct tangox_wdt_device *dev = - container_of(nb, struct tangox_wdt_device, restart); - -writel (1 , dev->base +WD_COUNTER ); - -return NOTIFY_DONE ; -} -static int tangox_wdt_probe (struct platform_device *pdev) {struct tangox_wdt_device *dev;
@@ -174,18 +171,14 @@ static int tangox_wdt_probe(struct platform_device *pdev)tangox_wdt_start (&dev->wdt); } +watchdog_set_restart_priority (&dev->wdt,128 ); + err =watchdog_register_device (&dev->wdt);if (err) goto err;platform_set_drvdata (pdev, dev); - dev->restart.notifier_call = tangox_wdt_restart; - dev->restart.priority =128 ; - err =register_restart_handler (&dev->restart); -if (err) -dev_warn (&pdev->dev,"failed to register restart handler\n" ); -dev_info (&pdev->dev,"SMP86xx/SMP87xx watchdog registered\n" );return 0 ;
@@ -202,7 +195,6 @@ static int tangox_wdt_remove(struct platform_device *pdev)tangox_wdt_stop (&dev->wdt);clk_disable_unprepare (dev->clk); -unregister_restart_handler (&dev->restart);watchdog_unregister_device (&dev->wdt);return 0 ;
Signature · 1 line
2.7.4
Re: [PATCH v2 2/4] watchdog: bcm2835_wdt: Use watchdog core to install restart handler
In reply to Guenter RoeckQuoted 6 lines · Guenter Roeck
Use the infrastructure provided by the watchdog core to install the restart handler.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Need to callwatchdog_set_restart_priority()
Seems fine.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170106/394426ae/attachment.sig>