summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/ar9344_wdt.c
diff options
context:
space:
mode:
authorOleksij Rempel <linux@rempel-privat.de>2018-03-13 09:33:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-03-23 07:35:24 +0100
commitdc16077260f59df5d22b02c189a4187c27cc3367 (patch)
tree0434f846c0c14171c6b7fdf9997c6fcb7a425c33 /drivers/watchdog/ar9344_wdt.c
parent65a644388e845bde01215bf378d4df2a6a260a6a (diff)
downloadbarebox-dc16077260f59df5d22b02c189a4187c27cc3367.tar.gz
barebox-dc16077260f59df5d22b02c189a4187c27cc3367.tar.xz
watchdog: move max timeout test in to wd_core
this also will be needed for watchdog poller as well Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/watchdog/ar9344_wdt.c')
-rw-r--r--drivers/watchdog/ar9344_wdt.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/watchdog/ar9344_wdt.c b/drivers/watchdog/ar9344_wdt.c
index c1dfc994a1..4615288631 100644
--- a/drivers/watchdog/ar9344_wdt.c
+++ b/drivers/watchdog/ar9344_wdt.c
@@ -41,20 +41,11 @@ struct ar9344_wd {
static int ar9344_watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
{
struct ar9344_wd *priv = to_ar9344_wd(wd);
- u32 val, ctrl, rate, max_timout;
-
- rate = clk_get_rate(priv->clk);
- max_timout = U32_MAX / rate;
-
- if (timeout > max_timout) {
- dev_err(priv->dev, "timeout value out of range: %d > %d\n",
- timeout, max_timout);
- return -EINVAL;
- }
+ u32 val, ctrl;
if (timeout) {
ctrl = AR9344_WD_CTRL_ACTION_FCR;
- val = timeout * rate;
+ val = timeout * clk_get_rate(priv->clk);
} else {
ctrl = AR9344_WD_CTRL_ACTION_NONE;
val = U32_MAX;
@@ -111,6 +102,8 @@ static int ar9344_wdt_probe(struct device_d *dev)
clk_enable(priv->clk);
+ priv->wd.timeout_max = U32_MAX / clk_get_rate(priv->clk);
+
ret = watchdog_register(&priv->wd);
if (ret)
goto on_error;