timeout_cur will be used for watchdog poller. Provided values should be good enough for most users and still can be changed for separate projects and fit to needed requirements. Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx> --- drivers/watchdog/wd_core.c | 15 +++++++++++++++ include/watchdog.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c index 66dbd790d..3162dd59c 100644 --- a/drivers/watchdog/wd_core.c +++ b/drivers/watchdog/wd_core.c @@ -31,6 +31,16 @@ static const char *watchdog_name(struct watchdog *wd) return "unknown"; } +static int watchdog_set_cur(struct param_d *param, void *priv) +{ + struct watchdog *wd = priv; + + if (wd->timeout_cur > wd->timeout_max) + return -EINVAL; + + return 0; +} + int watchdog_register(struct watchdog *wd) { @@ -45,8 +55,13 @@ int watchdog_register(struct watchdog *wd) if (!wd->timeout_max) wd->timeout_max = 60 * 4; + if (!wd->timeout_cur || wd->timeout_cur > wd->timeout_max) + wd->timeout_cur = wd->timeout_max; + dev_add_param_uint32_ro(&wd->dev, "timeout_max", &wd->timeout_max, "%u"); + dev_add_param_uint32(&wd->dev, "timeout_cur", watchdog_set_cur, NULL, + &wd->timeout_cur, "%u", wd); list_add_tail(&wd->list, &watchdog_list); diff --git a/include/watchdog.h b/include/watchdog.h index a2459d255..2f1874c19 100644 --- a/include/watchdog.h +++ b/include/watchdog.h @@ -20,6 +20,7 @@ struct watchdog { struct device_d dev; unsigned int priority; unsigned int timeout_max; + unsigned int timeout_cur; struct list_head list; }; -- 2.16.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox