Re: [PATCH RESEND 5.10.y-cip 13/13] watchdog: rzg2l_wdt: Add set_timeout callback

Biju Das

Hi Pavel,

Thanks for the feedback.

Subject: Re: [PATCH RESEND 5.10.y-cip 13/13] watchdog: rzg2l_wdt: Add
set_timeout callback


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.

+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -115,6 +115,25 @@ static int rzg2l_wdt_stop(struct watchdog_device
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
+ * register so that it is updated with new timeout values.
+ */
Ok, Will fix this in mainline.

+ if (watchdog_active(wdev)) {
+ pm_runtime_put(wdev->parent);
+ reset_control_reset(priv->rstc);
+ rzg2l_wdt_start(wdev);
+ }
This code is quite tricky. AFAICT it is correct, but calling
rzg2l_wdt_stop() instead would make it more readable.
From readability point, this code holds good as we need to do
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.


Join to automatically receive all group messages.