From: Ludovic Barre <ludovic.barre@xxxxxx> This patch updates return values on watchdog-kernel-api.txt: return 0 on succes, -EINVAL for "parameter out of range" and -EIO for "could not write value to the watchdog". Signed-off-by: Ludovic Barre <ludovic.barre@xxxxxx> --- drivers/watchdog/stm32_iwdg.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c index e191bd8..f19a6d4 100644 --- a/drivers/watchdog/stm32_iwdg.c +++ b/drivers/watchdog/stm32_iwdg.c @@ -81,7 +81,6 @@ static int stm32_iwdg_start(struct watchdog_device *wdd) struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd); u32 val = FLAG_PVU | FLAG_RVU; u32 reload; - int ret; dev_dbg(wdd->parent, "%s\n", __func__); @@ -98,13 +97,11 @@ static int stm32_iwdg_start(struct watchdog_device *wdd) reg_write(wdt->regs, IWDG_KR, KR_KEY_ENABLE); /* wait for the registers to be updated (max 100ms) */ - ret = readl_relaxed_poll_timeout(wdt->regs + IWDG_SR, val, - !(val & (FLAG_PVU | FLAG_RVU)), - SLEEP_US, TIMEOUT_US); - if (ret) { - dev_err(wdd->parent, - "Fail to set prescaler or reload registers\n"); - return ret; + if (readl_relaxed_poll_timeout(wdt->regs + IWDG_SR, val, + !(val & (FLAG_PVU | FLAG_RVU)), + SLEEP_US, TIMEOUT_US)) { + dev_err(wdd->parent, "Fail to set prescaler, reload regs\n"); + return -EIO; } /* reload watchdog */ @@ -128,8 +125,16 @@ static int stm32_iwdg_ping(struct watchdog_device *wdd) static int stm32_iwdg_set_timeout(struct watchdog_device *wdd, unsigned int timeout) { + unsigned int tout = clamp(timeout, wdd->min_timeout, + wdd->max_hw_heartbeat_ms / 1000); + dev_dbg(wdd->parent, "%s timeout: %d sec\n", __func__, timeout); + if (tout != timeout) { + dev_err(wdd->parent, "parameter out of range\n"); + return -EINVAL; + } + wdd->timeout = timeout; if (watchdog_active(wdd)) -- 2.7.4