Message ID | 20210305213659.31025-2-pali@kernel.org |
---|---|
State | Superseded |
Delegated to: | Stefan Roese |
Headers | show |
Series | [1/4] watchdog: Set/unset GD_FLG_WDT_READY flag in wdt_start()/wdt_stop() | expand |
On 05.03.21 22:36, Pali Rohár wrote: > Function wdt_start() may fail. So in initr_watchdog() function check return > value of wdt_start() call and print error message when watchdog starting > failed. > > Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Thanks, Stefan > --- > drivers/watchdog/wdt-uclass.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c > index 3f707f61f74f..7500b3ed90e3 100644 > --- a/drivers/watchdog/wdt-uclass.c > +++ b/drivers/watchdog/wdt-uclass.c > @@ -27,6 +27,7 @@ static ulong reset_period = 1000; > int initr_watchdog(void) > { > u32 timeout = WATCHDOG_TIMEOUT_SECS; > + int ret; > > /* > * Init watchdog: This will call the probe function of the > @@ -50,7 +51,12 @@ int initr_watchdog(void) > 4 * reset_period) / 4; > } > > - wdt_start(gd->watchdog_dev, timeout * 1000, 0); > + ret = wdt_start(gd->watchdog_dev, timeout * 1000, 0); > + if (ret != 0) { > + printf("WDT: Failed to start\n"); > + return 0; > + } > + > printf("WDT: Started with%s servicing (%ds timeout)\n", > IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout); > > Viele Grüße, Stefan
diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c index 3f707f61f74f..7500b3ed90e3 100644 --- a/drivers/watchdog/wdt-uclass.c +++ b/drivers/watchdog/wdt-uclass.c @@ -27,6 +27,7 @@ static ulong reset_period = 1000; int initr_watchdog(void) { u32 timeout = WATCHDOG_TIMEOUT_SECS; + int ret; /* * Init watchdog: This will call the probe function of the @@ -50,7 +51,12 @@ int initr_watchdog(void) 4 * reset_period) / 4; } - wdt_start(gd->watchdog_dev, timeout * 1000, 0); + ret = wdt_start(gd->watchdog_dev, timeout * 1000, 0); + if (ret != 0) { + printf("WDT: Failed to start\n"); + return 0; + } + printf("WDT: Started with%s servicing (%ds timeout)\n", IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout);
Function wdt_start() may fail. So in initr_watchdog() function check return value of wdt_start() call and print error message when watchdog starting failed. Signed-off-by: Pali Rohár <pali@kernel.org> --- drivers/watchdog/wdt-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)