The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/2] watchdog: sbsa_wdog: Fix the timeout calculation while programming
@ 2023-02-07  4:46 George Cherian
  2023-02-07  4:46 ` [PATCH 2/2] watchdog: sbsa_wdog: Make sure to program a larger timeout value George Cherian
  2023-02-07 16:03 ` [PATCH 1/2] watchdog: sbsa_wdog: Fix the timeout calculation while programming Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: George Cherian @ 2023-02-07  4:46 UTC (permalink / raw)
  To: wim, linux, zhangshaokun; +Cc: linux-watchdog, linux-kernel, George Cherian

The time out calculation done in sbsa_gwdt_set_timeout() would always
return a 32-bit value. Use proper typecasting to make sure the overflow
values are captured.

Fixes: abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")

Signed-off-by: George Cherian <george.cherian@marvell.com>
---
 drivers/watchdog/sbsa_gwdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c
index 9791c74aebd4..aaa3f5631f29 100644
--- a/drivers/watchdog/sbsa_gwdt.c
+++ b/drivers/watchdog/sbsa_gwdt.c
@@ -152,14 +152,14 @@ static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd,
 	wdd->timeout = timeout;
 
 	if (action)
-		sbsa_gwdt_reg_write(gwdt->clk * timeout, gwdt);
+		sbsa_gwdt_reg_write((u64)gwdt->clk * (u64)timeout, gwdt);
 	else
 		/*
 		 * In the single stage mode, The first signal (WS0) is ignored,
 		 * the timeout is (WOR * 2), so the WOR should be configured
 		 * to half value of timeout.
 		 */
-		sbsa_gwdt_reg_write(gwdt->clk / 2 * timeout, gwdt);
+		sbsa_gwdt_reg_write((u64)gwdt->clk / 2 * (u64)timeout, gwdt);
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-07 17:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-07  4:46 [PATCH 1/2] watchdog: sbsa_wdog: Fix the timeout calculation while programming George Cherian
2023-02-07  4:46 ` [PATCH 2/2] watchdog: sbsa_wdog: Make sure to program a larger timeout value George Cherian
2023-02-07 16:03 ` [PATCH 1/2] watchdog: sbsa_wdog: Fix the timeout calculation while programming Guenter Roeck
2023-02-07 17:01   ` George Cherian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox