Commit b51247c8 authored by Wolfram Sang's avatar Wolfram Sang Committed by Wim Van Sebroeck

watchdog: renesas_wdt: check rate also for upper limit

When checking the clock rate, ensure also that counting all 16 bits
takes at least one second to match the granularity of the framework.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent f6159dd4
...@@ -134,14 +134,14 @@ static int rwdt_probe(struct platform_device *pdev) ...@@ -134,14 +134,14 @@ static int rwdt_probe(struct platform_device *pdev)
for (i = ARRAY_SIZE(clk_divs) - 1; i >= 0; i--) { for (i = ARRAY_SIZE(clk_divs) - 1; i >= 0; i--) {
clks_per_sec = DIV_ROUND_UP(rate, clk_divs[i]); clks_per_sec = DIV_ROUND_UP(rate, clk_divs[i]);
if (clks_per_sec) { if (clks_per_sec && clks_per_sec < 65536) {
priv->clks_per_sec = clks_per_sec; priv->clks_per_sec = clks_per_sec;
priv->cks = i; priv->cks = i;
break; break;
} }
} }
if (!clks_per_sec) { if (i < 0) {
dev_err(&pdev->dev, "Can't find suitable clock divider\n"); dev_err(&pdev->dev, "Can't find suitable clock divider\n");
return -ERANGE; return -ERANGE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment