Lines Matching +full:timeout +full:- +full:sec
1 // SPDX-License-Identifier: GPL-2.0+
5 * (c) Copyright 2008-2011 Alan Cox <alan@lxorguk.ukuu.org.uk>,
8 * (c) Copyright 2008-2011 Wim Van Sebroeck <wim@iguana.be>.
22 * This material is provided "AS-IS" and at no charge.
29 #include <linux/errno.h> /* For the -ENODEV/... values */
46 static int stop_on_reboot = -1;
69 list_add_tail(&wdd->deferred, in watchdog_deferred_registration_add()
82 list_del(&wdd_tmp->deferred); in watchdog_deferred_registration_del()
91 * Check that we have valid min and max timeout values, if in watchdog_check_min_max_timeout()
94 if (!wdd->max_hw_heartbeat_ms && wdd->min_timeout > wdd->max_timeout) { in watchdog_check_min_max_timeout()
95 pr_info("Invalid min and max timeout values, resetting to 0!\n"); in watchdog_check_min_max_timeout()
96 wdd->min_timeout = 0; in watchdog_check_min_max_timeout()
97 wdd->max_timeout = 0; in watchdog_check_min_max_timeout()
102 * watchdog_init_timeout() - initialize the timeout field
104 * @timeout_parm: timeout module parameter
105 * @dev: Device that stores the timeout-sec property
107 * Initialize the timeout field of the watchdog_device struct with either the
108 * timeout module parameter (if it is valid value) or the timeout-sec property
111 * be the default timeout value). Note that for the module parameter, '0' means
112 * 'use default' while it is an invalid value for the timeout-sec property.
115 * A zero is returned on success or -EINVAL if all provided values are out of
121 const char *dev_str = wdd->parent ? dev_name(wdd->parent) : in watchdog_init_timeout()
122 (const char *)wdd->info->identity; in watchdog_init_timeout()
131 wdd->timeout = timeout_parm; in watchdog_init_timeout()
134 pr_err("%s: driver supplied timeout (%u) out of range\n", in watchdog_init_timeout()
136 ret = -EINVAL; in watchdog_init_timeout()
140 if (dev && dev->of_node && in watchdog_init_timeout()
141 of_property_read_u32(dev->of_node, "timeout-sec", &t) == 0) { in watchdog_init_timeout()
143 wdd->timeout = t; in watchdog_init_timeout()
146 pr_err("%s: DT supplied timeout (%u) out of range\n", dev_str, t); in watchdog_init_timeout()
147 ret = -EINVAL; in watchdog_init_timeout()
150 if (ret < 0 && wdd->timeout) in watchdog_init_timeout()
151 pr_warn("%s: falling back to default timeout (%u)\n", dev_str, in watchdog_init_timeout()
152 wdd->timeout); in watchdog_init_timeout()
168 ret = wdd->ops->stop(wdd); in watchdog_reboot_notifier()
186 ret = wdd->ops->restart(wdd, action, data); in watchdog_restart_notifier()
221 * watchdog_set_restart_priority - Change priority of restart handler
230 * If a wdd->ops->restart function is provided when watchdog_register_device is
236 wdd->restart_nb.priority = priority; in watchdog_set_restart_priority()
242 int ret, id = -1; in __watchdog_register_device()
244 if (wdd == NULL || wdd->info == NULL || wdd->ops == NULL) in __watchdog_register_device()
245 return -EINVAL; in __watchdog_register_device()
248 if (!wdd->ops->start || (!wdd->ops->stop && !wdd->max_hw_heartbeat_ms)) in __watchdog_register_device()
249 return -EINVAL; in __watchdog_register_device()
260 if (wdd->parent) { in __watchdog_register_device()
261 ret = of_alias_get_id(wdd->parent->of_node, "watchdog"); in __watchdog_register_device()
272 wdd->id = id; in __watchdog_register_device()
277 if (!(id == 0 && ret == -EBUSY)) in __watchdog_register_device()
284 wdd->id = id; in __watchdog_register_device()
294 if (stop_on_reboot != -1) { in __watchdog_register_device()
296 set_bit(WDOG_STOP_ON_REBOOT, &wdd->status); in __watchdog_register_device()
298 clear_bit(WDOG_STOP_ON_REBOOT, &wdd->status); in __watchdog_register_device()
301 if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) { in __watchdog_register_device()
302 if (!wdd->ops->stop) in __watchdog_register_device()
303 pr_warn("watchdog%d: stop_on_reboot not supported\n", wdd->id); in __watchdog_register_device()
305 wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; in __watchdog_register_device()
307 ret = register_reboot_notifier(&wdd->reboot_nb); in __watchdog_register_device()
310 wdd->id, ret); in __watchdog_register_device()
318 if (wdd->ops->restart) { in __watchdog_register_device()
319 wdd->restart_nb.notifier_call = watchdog_restart_notifier; in __watchdog_register_device()
321 ret = register_restart_handler(&wdd->restart_nb); in __watchdog_register_device()
324 wdd->id, ret); in __watchdog_register_device()
327 if (test_bit(WDOG_NO_PING_ON_SUSPEND, &wdd->status)) { in __watchdog_register_device()
328 wdd->pm_nb.notifier_call = watchdog_pm_notifier; in __watchdog_register_device()
330 ret = register_pm_notifier(&wdd->pm_nb); in __watchdog_register_device()
333 wdd->id, ret); in __watchdog_register_device()
340 * watchdog_register_device() - register a watchdog device
363 dev_str = wdd->parent ? dev_name(wdd->parent) : in watchdog_register_device()
364 (const char *)wdd->info->identity; in watchdog_register_device()
378 if (wdd->ops->restart) in __watchdog_unregister_device()
379 unregister_restart_handler(&wdd->restart_nb); in __watchdog_unregister_device()
381 if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) in __watchdog_unregister_device()
382 unregister_reboot_notifier(&wdd->reboot_nb); in __watchdog_unregister_device()
385 ida_simple_remove(&watchdog_ida, wdd->id); in __watchdog_unregister_device()
389 * watchdog_unregister_device() - unregister a watchdog device
414 * devm_watchdog_register_device() - resource managed watchdog_register_device()
431 return -ENOMEM; in devm_watchdog_register_device()
454 list_del(&wdd->deferred); in watchdog_deferred_registration()