watchdog: ftwdt010_wdt: add _restart() function
PATCH 1/1 watchdog: ftwdt010_wdt: add _restart() function
Add a missing _restart function to watchdog_ops. FTWDT010 resets system when it is started with timeout = 0.
--- drivers/watchdog/ftwdt010_wdt.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/watchdog/ftwdt010_wdt.c +8 -0
@@ -93,6 +93,13 @@ static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd,return 0 ; } +static int ftwdt010_wdt_restart (struct watchdog_device *wdd, +unsigned long action,void *data) +{ + wdd->timeout =0 ; +return ftwdt010_wdt_start (wdd); +} +static irqreturn_t ftwdt010_wdt_interrupt (int irq,void *data) {struct ftwdt010_wdt *gwdt = data;
@@ -107,6 +114,7 @@ static const struct watchdog_ops ftwdt010_wdt_ops = { .stop = ftwdt010_wdt_stop, .ping = ftwdt010_wdt_ping, .set_timeout = ftwdt010_wdt_set_timeout, + .restart = ftwdt010_wdt_restart, .owner = THIS_MODULE, };
Signature · 1 line
2.34.1
Guenter Roeck
maintainerQuoted 1 line · Sergei Antonov
Add a missing
_restartfunction towatchdog_ops.
The restart function isn't "missing" because it is optional.
Quoted 12 lines
FTWDT010 resets system when it is started with timeout = 0.
Signed-off-by Sergei Antonov <[email protected]>--- drivers/watchdog/ftwdt010_wdt.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/watchdog/ftwdt010_wdt.c +0
-0
drivers/watchdog/ftwdt010_wdt.c static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd, · line 100
Quoted 8 lines
drivers/watchdog/ftwdt010_wdt.c +5
-0@@ -93,6 +93,13 @@ static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd,return 0 ; } +static int ftwdt010_wdt_restart (struct watchdog_device *wdd, +unsigned long action,void *data) +{ + wdd->timeout =0 ; +return ftwdt010_wdt_start (wdd);
While technically correct, this crates the impression that ftwdt010_wdt_start() might return an error - which it never does. Given that, I would prefer
ftwdt010_wdt_start(wdd); return 0;
Also, did you make sure that interrupt support does not interfer with restart ? We don't want to get an interrupt when the watchdog fires due to a call to the restart handler.
Thanks,
Guenter
Quoted 16 lines
drivers/watchdog/ftwdt010_wdt.c +3
-0+} +static irqreturn_t ftwdt010_wdt_interrupt (int irq,void *data) {struct ftwdt010_wdt *gwdt = data;@@ -107,6 +114,7 @@ static const struct watchdog_ops ftwdt010_wdt_ops = { .stop = ftwdt010_wdt_stop, .ping = ftwdt010_wdt_ping, .set_timeout = ftwdt010_wdt_set_timeout, + .restart = ftwdt010_wdt_restart, .owner = THIS_MODULE, };Signature · 1 line
2.34.1
Quoted 30 lines · Guenter Roeck
Quoted 1 line · Sergei Antonov
Add a missing
_restartfunction towatchdog_ops.The restart function isn't "missing" because it is optional.
Quoted 12 lines
FTWDT010 resets system when it is started with timeout = 0.
Signed-off-by Sergei Antonov <[email protected]>--- drivers/watchdog/ftwdt010_wdt.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/watchdog/ftwdt010_wdt.c +0
-0drivers/watchdog/ftwdt010_wdt.c static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd, · line 100
Quoted 8 lines
drivers/watchdog/ftwdt010_wdt.c +5
-0@@ -93,6 +93,13 @@ static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd,return 0 ; } +static int ftwdt010_wdt_restart (struct watchdog_device *wdd, +unsigned long action,void *data) +{ + wdd->timeout =0 ; +return ftwdt010_wdt_start (wdd);While technically correct, this crates the impression that
ftwdt010_wdt_start()might return an error - which it never does. Given that, I would prefer
Quoted 2 lines
ftwdt010_wdt_start(wdd);
return 0;Why loose the return value? My code lets it propagate. It is potentially non-zero.
Quoted 3 lines
Also, did you make sure that interrupt support does not interfer with restart ? We don't want to get an interrupt when the watchdog fires due to a call to the restart handler.
No, I did not test watchdog interrupt on my hardware (don't' know yet how to set it up correctly). I only tested that restart restarts the hardware as expected.
Now that I think of it, it may be more precise to do gwdt->has_irq = false;
before calling ftwdt010_wdt_start()
So that WDCR_WDINTR flag will not be set and the chip will not trigger an interrupt.
Guenter Roeck
maintainerQuoted 34 lines · Sergei Antonov
Quoted 30 lines · Guenter Roeck
Quoted 1 line · Sergei Antonov
Add a missing
_restartfunction towatchdog_ops.The restart function isn't "missing" because it is optional.
Quoted 12 lines
FTWDT010 resets system when it is started with timeout = 0.
Signed-off-by Sergei Antonov <[email protected]>--- drivers/watchdog/ftwdt010_wdt.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/watchdog/ftwdt010_wdt.c +0
-0drivers/watchdog/ftwdt010_wdt.c static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd, · line 100
Quoted 8 lines
drivers/watchdog/ftwdt010_wdt.c +5
-0@@ -93,6 +93,13 @@ static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd,return 0 ; } +static int ftwdt010_wdt_restart (struct watchdog_device *wdd, +unsigned long action,void *data) +{ + wdd->timeout =0 ; +return ftwdt010_wdt_start (wdd);While technically correct, this crates the impression that
ftwdt010_wdt_start()might return an error - which it never does. Given that, I would preferQuoted 2 lines
ftwdt010_wdt_start(wdd); return 0;
Quoted 3 lines
Why loose the return value? My code lets it propagate. It is potentially non-zero.
No, it never is. Look at the code. That is the whole point.
Quoted 4 lines
Quoted 3 lines
Also, did you make sure that interrupt support does not interfer with restart ? We don't want to get an interrupt when the watchdog fires due to a call to the restart handler.
Quoted 8 lines
No, I did not test watchdog interrupt on my hardware (don't' know yet how to set it up correctly). I only tested that restart restarts the hardware as expected.
Now that I think of it, it may be more precise to dogwdt->has_irq= false;
before callingftwdt010_wdt_start()
So thatWDCR_WDINTRflag will not be set and the chip will not trigger an interrupt.
In that case I'd rather see a separate function which is called from both ftwdt010_wdt_start() and the restart function and has timeout and the interrupt flag as parameters. That would also address the never-happening error return.
Thanks,
Guenter
Quoted 12 lines · Guenter Roeck
Quoted 12 lines
Quoted 11 lines
drivers/watchdog/ftwdt010_wdt.c static int ftwdt010_wdt_set_timeout(struct watchdog_device *wdd, · line 100
Quoted 5 lines
drivers/watchdog/ftwdt010_wdt.c +5
-0+static int ftwdt010_wdt_restart (struct watchdog_device *wdd, +unsigned long action,void *data) +{ + wdd->timeout =0 ; +return ftwdt010_wdt_start (wdd);While technically correct, this crates the impression that
ftwdt010_wdt_start()might return an error - which it never does. Given that, I would preferftwdt010_wdt_start(wdd); return 0;
Quoted 4 lines
Quoted 3 lines
Why loose the return value? My code lets it propagate. It is potentially non-zero.
No, it never is. Look at the code. That is the whole point.
Of course I looked at ftwdt010_wdt_start() and saw it always returning
0. By "potentially" I meant it returning errors too in the future.
Quoted 13 lines
Quoted 4 lines
Quoted 3 lines
Also, did you make sure that interrupt support does not interfer with restart ? We don't want to get an interrupt when the watchdog fires due to a call to the restart handler.
Quoted 8 lines
No, I did not test watchdog interrupt on my hardware (don't' know yet how to set it up correctly). I only tested that restart restarts the hardware as expected.
Now that I think of it, it may be more precise to dogwdt->has_irq= false;
before callingftwdt010_wdt_start()
So thatWDCR_WDINTRflag will not be set and the chip will not trigger an interrupt.
Quoted 3 lines
In that case I'd rather see a separate function which is called from both
ftwdt010_wdt_start()and the restart function and has timeout and the interrupt flag as parameters. That would also address the never-happening error return.
OK. Submitting a new patch.