watchdog: aspeed: fix hardware timeout calculation
authorTao Ren <rentao.bupt@gmail.com>
Sat, 17 Apr 2021 03:42:49 +0000 (20:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:17:53 +0000 (16:17 +0200)
[ Upstream commit e7dc481c92060f9ce872878b0b7a08c24713a7e5 ]

Fix hardware timeout calculation in aspeed_wdt_set_timeout function to
ensure the reload value does not exceed the hardware limit.

Fixes: efa859f7d786 ("watchdog: Add Aspeed watchdog driver")
Reported-by: Amithash Prasad <amithash@fb.com>
Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210417034249.5978-1-rentao.bupt@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/watchdog/aspeed_wdt.c

index f5835cbd5d415af33ea44e317d0674233c91f418..5c13659cc89a14f13d238d96b77d46f9a05167b2 100644 (file)
@@ -147,7 +147,7 @@ static int aspeed_wdt_set_timeout(struct watchdog_device *wdd,
 
        wdd->timeout = timeout;
 
-       actual = min(timeout, wdd->max_hw_heartbeat_ms * 1000);
+       actual = min(timeout, wdd->max_hw_heartbeat_ms / 1000);
 
        writel(actual * WDT_RATE_1MHZ, wdt->base + WDT_RELOAD_VALUE);
        writel(WDT_RESTART_MAGIC, wdt->base + WDT_RESTART);