watchdog: asm9260_wdt: Use watchdog core to install restart handler
Subsystems (4)
Guenter Roeck
maintainerPATCH 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.
--- drivers/watchdog/asm9260_wdt.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
drivers/watchdog/asm9260_wdt.c +5 -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)
@@ -341,12 +339,6 @@ static int asm9260_wdt_probe(struct platform_device *pdev)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 +362,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 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.
--- drivers/watchdog/bcm2835_wdt.c | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/watchdog/bcm2835_wdt.c +27 -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)
@@ -208,9 +212,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 +223,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 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.
--- drivers/watchdog/dw_wdt.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/watchdog/dw_wdt.c +5 -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
@@ -269,12 +265,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)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 +276,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 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.
--- drivers/watchdog/tangox_wdt.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)
drivers/watchdog/tangox_wdt.c +11 -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;
@@ -180,12 +177,6 @@ static int tangox_wdt_probe(struct platform_device *pdev)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 +193,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 4/4] watchdog: tangox: Use watchdog core to install restart handler
[ Adding Mans ]
Guenter, patch c7ef68c32265 states "Fixes: a3e376d26ace". Is that true? I mean, they seem quite orthogonal; then again I know nothing of this framework.
Regards.
Quoted 88 lines · Guenter Roeck
Use the infrastructure provided by the watchdog core to install the restart handler.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/watchdog/tangox_wdt.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)drivers/watchdog/tangox_wdt.c +11
-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;@@ -180,12 +177,6 @@ static int tangox_wdt_probe(struct platform_device *pdev)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 +193,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 ;
Re: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
Quoted 5 lines · Marc Gonzalez
[ Adding Mans ]
Guenter, patch
c7ef68c32265states "Fixes:a3e376d26ace". Is that true? I mean, they seem quite orthogonal; then again I know nothing of this framework.
I don't see the relation of either of those to this patch.
Quoted 89 lines · Guenter Roeck
Quoted 88 lines
Use the infrastructure provided by the watchdog core to install the restart handler.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/watchdog/tangox_wdt.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)drivers/watchdog/tangox_wdt.c +11
-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;@@ -180,12 +177,6 @@ static int tangox_wdt_probe(struct platform_device *pdev)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 +193,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
M?ns Rullg?rd
Re: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
Quoted 7 lines · M?ns Rullg?rd
Quoted 3 lines · Marc Gonzalez
Guenter, patch
c7ef68c32265states "Fixes:a3e376d26ace". Is that true? I mean, they seem quite orthogonal; then again I know nothing of this framework.I don't see the relation of either of those to this patch.
There is none. I just happened to git log the file because of this proposed patch.
Guenter Roeck
maintainerRe: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
In reply to Marc GonzalezQuoted 6 lines · Marc Gonzalez
[ Adding Mans ]
Guenter, patch
c7ef68c32265states "Fixes:a3e376d26ace". Is that true? I mean, they seem quite orthogonal; then again I know nothing of this framework.
max_hw_heartbeat_ms must be set for WDOG_HW_RUNNING to work.
Guenter
Quoted 92 lines
Regards.
Quoted 88 lines · Guenter Roeck
Use the infrastructure provided by the watchdog core to install the restart handler.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/watchdog/tangox_wdt.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-)drivers/watchdog/tangox_wdt.c +11
-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;@@ -180,12 +177,6 @@ static int tangox_wdt_probe(struct platform_device *pdev)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 +193,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 ;