diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-10-23 18:55:59 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-10-24 09:59:30 +0200 |
commit | c2d167823588708c9f8f68c7db111ce146e19e3f (patch) | |
tree | 6d2f32a4500b7e3c55cae282c049482f6af2693c /drivers | |
parent | 2731cc09db884b5089d027a412e0396d07d23f42 (diff) | |
download | barebox-c2d167823588708c9f8f68c7db111ce146e19e3f.tar.gz barebox-c2d167823588708c9f8f68c7db111ce146e19e3f.tar.xz |
watchdog: export priority as device parameter
8f4cf30903 ("watchdog: Allow multiple watchdogs") introduced the ability
to set a per-watchdog priority from within drivers, which is usually
populated with of_get_watchdog_priority.
For debugging, it can be useful to query and override this priority on
the fly. Provide a device parameter to do so.
As watchdog_get_default only considers priorities > 0, it makes sense
to have a newly set priority of 0 disable the watchdog.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/watchdog/wd_core.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index e6e5ddecd2..ae29a76064 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -41,6 +41,16 @@ static int _watchdog_set_timeout(struct watchdog *wd, unsigned timeout) return wd->set_timeout(wd, timeout); } +static int watchdog_set_priority(struct param_d *param, void *priv) +{ + struct watchdog *wd = priv; + + if (wd->priority == 0) + return _watchdog_set_timeout(wd, 0); + + return 0; +} + static int watchdog_set_cur(struct param_d *param, void *priv) { struct watchdog *wd = priv; @@ -130,6 +140,12 @@ int watchdog_register(struct watchdog *wd) if (!wd->priority) wd->priority = WATCHDOG_DEFAULT_PRIORITY; + p = dev_add_param_uint32(&wd->dev, "priority", + watchdog_set_priority, NULL, + &wd->priority, "%u", wd); + if (IS_ERR(p)) + return PTR_ERR(p); + /* set some default sane value */ if (!wd->timeout_max) wd->timeout_max = 60 * 60 * 24; |