linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] watchdog: asm9260_wdt: Use watchdog core to install restart handler
@ 2017-01-04 21:28 Guenter Roeck
  2017-01-04 21:28 ` [PATCH 2/4] watchdog: bcm2835_wdt: " Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Guenter Roeck @ 2017-01-04 21:28 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: Guenter Roeck, linux-watchdog, linux-kernel

Use the infrastructure provided by the watchdog core to install
the restart handler.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/asm9260_wdt.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c
index d0b59ba0f661..05a2b922304b 100644
--- a/drivers/watchdog/asm9260_wdt.c
+++ b/drivers/watchdog/asm9260_wdt.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] watchdog: bcm2835_wdt: Use watchdog core to install restart handler
  2017-01-04 21:28 [PATCH 1/4] watchdog: asm9260_wdt: Use watchdog core to install restart handler Guenter Roeck
@ 2017-01-04 21:28 ` Guenter Roeck
  2017-01-04 21:28 ` [PATCH 3/4] watchdog: dw_wdt: " Guenter Roeck
  2017-01-04 21:28 ` [PATCH 4/4] watchdog: tangox: " Guenter Roeck
  2 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2017-01-04 21:28 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Guenter Roeck, Stephen Warren, Lee Jones, Eric Anholt,
	Florian Fainelli, Ray Jui, Scott Branden,
	bcm-kernel-feedback-list, linux-watchdog, linux-rpi-kernel,
	linux-arm-kernel, linux-kernel

Use the infrastructure provided by the watchdog core to install
the restart handler.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/bcm2835_wdt.c | 54 +++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index c32c45bd8b09..2bc7d195f0a4 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] watchdog: dw_wdt: Use watchdog core to install restart handler
  2017-01-04 21:28 [PATCH 1/4] watchdog: asm9260_wdt: Use watchdog core to install restart handler Guenter Roeck
  2017-01-04 21:28 ` [PATCH 2/4] watchdog: bcm2835_wdt: " Guenter Roeck
@ 2017-01-04 21:28 ` Guenter Roeck
  2017-01-04 21:28 ` [PATCH 4/4] watchdog: tangox: " Guenter Roeck
  2 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2017-01-04 21:28 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: Guenter Roeck, linux-watchdog, linux-kernel

Use the infrastructure provided by the watchdog core to install
the restart handler.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/dw_wdt.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 3c6a3de13a1b..158054904876 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -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);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
  2017-01-04 21:28 [PATCH 1/4] watchdog: asm9260_wdt: Use watchdog core to install restart handler Guenter Roeck
  2017-01-04 21:28 ` [PATCH 2/4] watchdog: bcm2835_wdt: " Guenter Roeck
  2017-01-04 21:28 ` [PATCH 3/4] watchdog: dw_wdt: " Guenter Roeck
@ 2017-01-04 21:28 ` Guenter Roeck
  2017-01-05  9:42   ` Marc Gonzalez
  2 siblings, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2017-01-04 21:28 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: Guenter Roeck, Marc Gonzalez, linux-watchdog, linux-arm-kernel,
	linux-kernel

Use the infrastructure provided by the watchdog core to install
the restart handler.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/tangox_wdt.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c
index 202c4b9cc921..49e6e805db7c 100644
--- a/drivers/watchdog/tangox_wdt.c
+++ b/drivers/watchdog/tangox_wdt.c
@@ -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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
  2017-01-04 21:28 ` [PATCH 4/4] watchdog: tangox: " Guenter Roeck
@ 2017-01-05  9:42   ` Marc Gonzalez
  2017-01-05 11:38     ` Måns Rullgård
  2017-01-05 14:25     ` Guenter Roeck
  0 siblings, 2 replies; 8+ messages in thread
From: Marc Gonzalez @ 2017-01-05  9:42 UTC (permalink / raw)
  To: Guenter Roeck, Mans Rullgard
  Cc: Wim Van Sebroeck, linux-watchdog, linux-arm-kernel, linux-kernel

[ 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.

On 04/01/2017 22:28, Guenter Roeck wrote:
> Use the infrastructure provided by the watchdog core to install
> the restart handler.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/watchdog/tangox_wdt.c | 32 +++++++++++---------------------
>  1 file changed, 11 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c
> index 202c4b9cc921..49e6e805db7c 100644
> --- a/drivers/watchdog/tangox_wdt.c
> +++ b/drivers/watchdog/tangox_wdt.c
> @@ -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;
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
  2017-01-05  9:42   ` Marc Gonzalez
@ 2017-01-05 11:38     ` Måns Rullgård
  2017-01-05 11:55       ` Marc Gonzalez
  2017-01-05 14:25     ` Guenter Roeck
  1 sibling, 1 reply; 8+ messages in thread
From: Måns Rullgård @ 2017-01-05 11:38 UTC (permalink / raw)
  To: Marc Gonzalez
  Cc: Guenter Roeck, Wim Van Sebroeck, linux-watchdog,
	linux-arm-kernel, linux-kernel

Marc Gonzalez <marc_gonzalez@sigmadesigns.com> writes:

> [ 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.

I don't see the relation of either of those to this patch.

> On 04/01/2017 22:28, Guenter Roeck wrote:
>> Use the infrastructure provided by the watchdog core to install
>> the restart handler.
>> 
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>  drivers/watchdog/tangox_wdt.c | 32 +++++++++++---------------------
>>  1 file changed, 11 insertions(+), 21 deletions(-)
>> 
>> diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c
>> index 202c4b9cc921..49e6e805db7c 100644
>> --- a/drivers/watchdog/tangox_wdt.c
>> +++ b/drivers/watchdog/tangox_wdt.c
>> @@ -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;
>> 

-- 
Måns Rullgård

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
  2017-01-05 11:38     ` Måns Rullgård
@ 2017-01-05 11:55       ` Marc Gonzalez
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Gonzalez @ 2017-01-05 11:55 UTC (permalink / raw)
  To: Mans Rullgard
  Cc: Guenter Roeck, Wim Van Sebroeck, linux-watchdog,
	linux-arm-kernel, linux-kernel

On 05/01/2017 12:38, Måns Rullgård wrote:

> Marc Gonzalez writes:
> 
>> Guenter, patch c7ef68c32265 states "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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
  2017-01-05  9:42   ` Marc Gonzalez
  2017-01-05 11:38     ` Måns Rullgård
@ 2017-01-05 14:25     ` Guenter Roeck
  1 sibling, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2017-01-05 14:25 UTC (permalink / raw)
  To: Marc Gonzalez, Mans Rullgard
  Cc: Wim Van Sebroeck, linux-watchdog, linux-arm-kernel, linux-kernel

On 01/05/2017 01:42 AM, Marc Gonzalez wrote:
> [ 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.
>
max_hw_heartbeat_ms must be set for WDOG_HW_RUNNING to work.

Guenter

> Regards.
>
> On 04/01/2017 22:28, Guenter Roeck wrote:
>> Use the infrastructure provided by the watchdog core to install
>> the restart handler.
>>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>  drivers/watchdog/tangox_wdt.c | 32 +++++++++++---------------------
>>  1 file changed, 11 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c
>> index 202c4b9cc921..49e6e805db7c 100644
>> --- a/drivers/watchdog/tangox_wdt.c
>> +++ b/drivers/watchdog/tangox_wdt.c
>> @@ -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;
>>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-01-05 14:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-04 21:28 [PATCH 1/4] watchdog: asm9260_wdt: Use watchdog core to install restart handler Guenter Roeck
2017-01-04 21:28 ` [PATCH 2/4] watchdog: bcm2835_wdt: " Guenter Roeck
2017-01-04 21:28 ` [PATCH 3/4] watchdog: dw_wdt: " Guenter Roeck
2017-01-04 21:28 ` [PATCH 4/4] watchdog: tangox: " Guenter Roeck
2017-01-05  9:42   ` Marc Gonzalez
2017-01-05 11:38     ` Måns Rullgård
2017-01-05 11:55       ` Marc Gonzalez
2017-01-05 14:25     ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).