* [PATCH 2/4] watchdog: bcm2835_wdt: Use watchdog core to install restart handler
[not found] <1483565318-25578-1-git-send-email-linux@roeck-us.net>
@ 2017-01-04 21:28 ` Guenter Roeck
2017-01-04 21:28 ` [PATCH 4/4] watchdog: tangox: " Guenter Roeck
1 sibling, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2017-01-04 21:28 UTC (permalink / raw)
To: linux-arm-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] 6+ messages in thread
* [PATCH 4/4] watchdog: tangox: Use watchdog core to install restart handler
[not found] <1483565318-25578-1-git-send-email-linux@roeck-us.net>
2017-01-04 21:28 ` [PATCH 2/4] watchdog: bcm2835_wdt: Use watchdog core to install restart handler Guenter Roeck
@ 2017-01-04 21:28 ` Guenter Roeck
2017-01-05 9:42 ` Marc Gonzalez
1 sibling, 1 reply; 6+ messages in thread
From: Guenter Roeck @ 2017-01-04 21:28 UTC (permalink / raw)
To: linux-arm-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] 6+ messages in thread
* [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; 6+ messages in thread
From: Marc Gonzalez @ 2017-01-05 9:42 UTC (permalink / raw)
To: linux-arm-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] 6+ messages in thread
* [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; 6+ messages in thread
From: Måns Rullgård @ 2017-01-05 11:38 UTC (permalink / raw)
To: linux-arm-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] 6+ messages in thread
* [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; 6+ messages in thread
From: Marc Gonzalez @ 2017-01-05 11:55 UTC (permalink / raw)
To: linux-arm-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] 6+ messages in thread
* [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; 6+ messages in thread
From: Guenter Roeck @ 2017-01-05 14:25 UTC (permalink / raw)
To: linux-arm-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] 6+ messages in thread
end of thread, other threads:[~2017-01-05 14:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1483565318-25578-1-git-send-email-linux@roeck-us.net>
2017-01-04 21:28 ` [PATCH 2/4] watchdog: bcm2835_wdt: Use watchdog core to install restart handler 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).