From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>
Cc: Daniel Palmer <daniel@thingy.jp>,
Romain Perier <romain.perier@gmail.com>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
tzungbi@kernel.org
Subject: [PATCH v2 7/9] watchdog: msc313e: Sync timeout value if WDT was running at boot
Date: Sat, 29 Aug 2026 00:13:46 +0800 [thread overview]
Message-ID: <20260828161348.13212-8-tzungbi@kernel.org> (raw)
In-Reply-To: <20260828161348.13212-1-tzungbi@kernel.org>
If WDT was running at boot, the hardware timeout might be set to values
other than the final software timeout.
To be consistent, set the hardware timeout to match the final software
timeout (i.e., after watchdog_init_timeout()) if WDT was running.
Fixes: ffd264bd152c ("watchdog: msc313e: Check if the WDT was running at boot")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
v2:
- New to the series.
---
drivers/watchdog/msc313e_wdt.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/watchdog/msc313e_wdt.c b/drivers/watchdog/msc313e_wdt.c
index e28261c7a8d4..4a5cce2a16b1 100644
--- a/drivers/watchdog/msc313e_wdt.c
+++ b/drivers/watchdog/msc313e_wdt.c
@@ -144,12 +144,21 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
priv->wdev.max_timeout = U32_MAX / rate;
priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT;
+ watchdog_set_drvdata(&priv->wdev, priv);
+ platform_set_drvdata(pdev, priv);
+
+ watchdog_init_timeout(&priv->wdev, timeout, dev);
+ watchdog_stop_on_reboot(&priv->wdev);
+ watchdog_stop_on_unregister(&priv->wdev);
+ watchdog_stop_ping_on_suspend(&priv->wdev);
+
ret = clk_prepare_enable(priv->clk);
if (ret)
return ret;
/* If the period is non-zero the WDT is running */
if (msc313e_wdt_get_hw_timeout(priv)) {
+ msc313e_wdt_set_hw_timeout(priv, priv->wdev.timeout);
set_bit(WDOG_HW_RUNNING, &priv->wdev.status);
/*
* Keep the clock enabled. The watchdog core will skip the next
@@ -160,14 +169,6 @@ static int msc313e_wdt_probe(struct platform_device *pdev)
clk_disable_unprepare(priv->clk);
}
- watchdog_set_drvdata(&priv->wdev, priv);
- platform_set_drvdata(pdev, priv);
-
- watchdog_init_timeout(&priv->wdev, timeout, dev);
- watchdog_stop_on_reboot(&priv->wdev);
- watchdog_stop_on_unregister(&priv->wdev);
- watchdog_stop_ping_on_suspend(&priv->wdev);
-
ret = devm_watchdog_register_device(dev, &priv->wdev);
/* If the WDT is running and anything goes wrong, disable the clock. */
--
2.53.0
next prev parent reply other threads:[~2026-08-28 16:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 16:13 [PATCH v2 0/9] watchdog: msc313e: Fix issues Sashiko reported Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 1/9] watchdog: msc313e: Fix NULL pointer dereference in PM callbacks Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 2/9] watchdog: msc313e: Avoid division by zero Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 3/9] watchdog: msc313e: Fix clock leak and spurious timer in settimeout() Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 4/9] watchdog: msc313e: Enable clock before accessing hardware registers Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 5/9] watchdog: msc313e: Fix spurious reset on suspend Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 6/9] watchdog: msc313e: Fix undefined behavior Tzung-Bi Shih
2026-08-28 16:13 ` Tzung-Bi Shih [this message]
2026-08-28 16:13 ` [PATCH v2 8/9] watchdog: msc313e: Propagate error code in resume() Tzung-Bi Shih
2026-08-28 16:13 ` [PATCH v2 9/9] watchdog: msc313e: Replace commas with semicolons in probe() Tzung-Bi Shih
2026-08-28 16:20 ` [PATCH v2 0/9] watchdog: msc313e: Fix issues Sashiko reported Daniel Palmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260828161348.13212-8-tzungbi@kernel.org \
--to=tzungbi@kernel.org \
--cc=daniel@thingy.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=romain.perier@gmail.com \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®