Date
1 - 3 of 3
[PATCH RESEND 5.10.y-cip 13/13] watchdog: rzg2l_wdt: Add set_timeout callback
Biju Das
commit 4055ee81009e606e830af1acd9e2e35a36249713 upstream.
This patch adds support for set_timeout callback. Once WDT is started, the WDT cycle setting register(WDTSET) can be updated only after issuing a module reset. Otherwise, it will ignore the writes and will hold the previous value. This patch updates the WDTSET register if it is active. Signed-off-by: Biju Das <biju.das.jz@...> Reviewed-by: Geert Uytterhoeven <geert+renesas@...> Reviewed-by: Guenter Roeck <linux@...> Link: https://lore.kernel.org/r/20220225175320.11041-8-biju.das.jz@bp.renesas.com Signed-off-by: Guenter Roeck <linux@...> Signed-off-by: Wim Van Sebroeck <wim@...> Signed-off-by: Biju Das <biju.das.jz@...> --- drivers/watchdog/rzg2l_wdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index 4e7107655cc2..6eea0ee4af49 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -115,6 +115,25 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev) return 0; } +static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int timeout) +{ + struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); + + wdev->timeout = timeout; + + /* + * If the watchdog is active, reset the module for updating the WDTSET + * register so that it is updated with new timeout values. + */ + if (watchdog_active(wdev)) { + pm_runtime_put(wdev->parent); + reset_control_reset(priv->rstc); + rzg2l_wdt_start(wdev); + } + + return 0; +} + static int rzg2l_wdt_restart(struct watchdog_device *wdev, unsigned long action, void *data) { @@ -151,6 +170,7 @@ static const struct watchdog_ops rzg2l_wdt_ops = { .start = rzg2l_wdt_start, .stop = rzg2l_wdt_stop, .ping = rzg2l_wdt_ping, + .set_timeout = rzg2l_wdt_set_timeout, .restart = rzg2l_wdt_restart, }; -- 2.25.1
|
|
Pavel Machek
Hi!
commit 4055ee81009e606e830af1acd9e2e35a36249713 upstream. +++ b/drivers/watchdog/rzg2l_wdt.cvalues->value? + if (watchdog_active(wdev)) {This code is quite tricky. AFAICT it is correct, but calling rzg2l_wdt_stop() instead would make it more readable. Best regards, Pavel -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
|
|
Biju Das
Hi Pavel,
Thanks for the feedback. Subject: Re: [PATCH RESEND 5.10.y-cip 13/13] watchdog: rzg2l_wdt: AddOk, Will fix this in mainline. From readability point, this code holds good as we need to do+ if (watchdog_active(wdev)) {This code is quite tricky. AFAICT it is correct, but calling Module reset for changing time out values for WDT. But from code optimization point, whatever you suggested is ok. What do we do here, readability or optimization? Please suggest. Cheers, Biju
|
|