Re: [PATCH 3/4] watchdog: rzg2l_wdt: Add set_timeout callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/11/21 1:38 PM, Guenter Roeck wrote:
On 12/11/21 1:26 PM, Biju Das wrote:
Add support for set_timeout() callback.

This needs an explanation. WDIOF_SETTIMEOUT is, after all,
already supported. I can see that 'count' is not recalculated,
so that is one of the reasons. However, it also needs to be explained
why it is necessary to stop and restart the watchdog.

Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
---
  drivers/watchdog/rzg2l_wdt.c | 10 ++++++++++
  1 file changed, 10 insertions(+)

diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 58fe4efd9a89..c81b9dd05e63 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -117,6 +117,15 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)
      return 0;
  }
+static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int timeout)
+{
+    wdev->timeout = timeout;
+    rzg2l_wdt_stop(wdev);
+    rzg2l_wdt_start(wdev);

Is it necessary to stop and restart the timeout, or would it be sufficient
to call rza_wdt_calc_timeout() ? If it is necessary, please add a comment

That should have been rzg2l_wdt_init_timeout(). Also, as mentioned in
the second patch of the series, the return value of rzg2l_wdt_start()
needs to be checked if the watchdog needs to be stopped and restarted.

Thanks,
Guenter

describing the reason.

Either case, calling rzg2l_wdt_start() unconditionally is wrong because
the watchdog might be stopped.

Guenter

+
+    return 0;
+}
+
  static int rzg2l_wdt_restart(struct watchdog_device *wdev,
                   unsigned long action, void *data)
  {
@@ -160,6 +169,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,
  };






[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux