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

watchdog: add error messages when initializing timeout fails

This not only removes boilerplate code from watchdog drivers, it can
also be more specific which of the supplied value actually fails. Also,
the loglevel becomes now consistent across drivers.
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent 34ef4087
...@@ -115,6 +115,8 @@ static void watchdog_check_min_max_timeout(struct watchdog_device *wdd) ...@@ -115,6 +115,8 @@ static void watchdog_check_min_max_timeout(struct watchdog_device *wdd)
int watchdog_init_timeout(struct watchdog_device *wdd, int watchdog_init_timeout(struct watchdog_device *wdd,
unsigned int timeout_parm, struct device *dev) unsigned int timeout_parm, struct device *dev)
{ {
const char *dev_str = wdd->parent ? dev_name(wdd->parent) :
(const char *)wdd->info->identity;
unsigned int t = 0; unsigned int t = 0;
int ret = 0; int ret = 0;
...@@ -126,6 +128,8 @@ int watchdog_init_timeout(struct watchdog_device *wdd, ...@@ -126,6 +128,8 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
wdd->timeout = timeout_parm; wdd->timeout = timeout_parm;
return 0; return 0;
} }
pr_err("%s: driver supplied timeout (%u) out of range\n",
dev_str, timeout_parm);
ret = -EINVAL; ret = -EINVAL;
} }
...@@ -136,9 +140,14 @@ int watchdog_init_timeout(struct watchdog_device *wdd, ...@@ -136,9 +140,14 @@ int watchdog_init_timeout(struct watchdog_device *wdd,
wdd->timeout = t; wdd->timeout = t;
return 0; return 0;
} }
pr_err("%s: DT supplied timeout (%u) out of range\n", dev_str, t);
ret = -EINVAL; ret = -EINVAL;
} }
if (ret < 0 && wdd->timeout)
pr_warn("%s: falling back to default timeout (%u)\n", dev_str,
wdd->timeout);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(watchdog_init_timeout); EXPORT_SYMBOL_GPL(watchdog_init_timeout);
......
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