watchdog: Make set_timeout function optional
For some watchdogs, the watchdog driver handles timeout changes without explicitly setting any registers. In this situation, the watchdog driver might only set the 'timeout' variable but do nothing else. This can as well be handled by the infrastructure, so make the set_timeout callback optional. If WDIOF_SETTIMEOUT is configured but the .set_timeout callback is not available, update the timeout variable in the infrastructure code. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:

committed by
Wim Van Sebroeck

parent
e21f56219b
commit
fb32e9b9de
@@ -183,13 +183,20 @@ static unsigned int watchdog_get_status(struct watchdog_device *wdd)
|
||||
static int watchdog_set_timeout(struct watchdog_device *wdd,
|
||||
unsigned int timeout)
|
||||
{
|
||||
if (!wdd->ops->set_timeout || !(wdd->info->options & WDIOF_SETTIMEOUT))
|
||||
int err = 0;
|
||||
|
||||
if (!(wdd->info->options & WDIOF_SETTIMEOUT))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (watchdog_timeout_invalid(wdd, timeout))
|
||||
return -EINVAL;
|
||||
|
||||
return wdd->ops->set_timeout(wdd, timeout);
|
||||
if (wdd->ops->set_timeout)
|
||||
err = wdd->ops->set_timeout(wdd, timeout);
|
||||
else
|
||||
wdd->timeout = timeout;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user