watchdog: mtk_wdt: fix timeout calculation
Subsystems (2)
PATCH 2/3 watchdog: mtk_wdt: fix timeout calculation
U-Boot passes timeout in milliseconds for ops->start. However the driver treats this value as seconds. This will cause an overflow on writing wdt register.
This patch divides the timeout by 1000 before writing to wdt register.
Reviewed-by Ryder Lee <[email protected]>
Signed-off-by Weijie Gao <[email protected]>
--- drivers/watchdog/mtk_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/mtk_wdt.c +1 -1
@@ -78,7 +78,7 @@ static void mtk_wdt_set_timeout(struct udevice *dev, unsigned int timeout)* One bit is the value of 512 ticks * The clock has 32 KHz */ - timeout =WDT_LENGTH_TIMEOUT (timeout <<6 ) |WDT_LENGTH_KEY ; + timeout =WDT_LENGTH_TIMEOUT ((timeout <<6 ) /1000 ) |WDT_LENGTH_KEY ;writel (timeout, priv->base +MTK_WDT_LENGTH );mtk_wdt_reset (dev);
Signature · 1 line
2.18.0
PATCH 2/3 watchdog: mtk_wdt: fix timeout calculation
Quoted 8 lines · Weijie Gao
U-Boot passes timeout in milliseconds for
ops->start. However the driver treats this value as seconds. This will cause an overflow on writing wdt register.This patch divides the timeout by 1000 before writing to wdt register.
Reviewed-by Ryder Lee <[email protected]>Signed-off-by Weijie Gao <[email protected]>
Reviewed-by Stefan Roese <[email protected]>
Thanks,
Stefan