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 */
43 static int stop_on_reboot = -1;
66 list_add_tail(&wdd->deferred, in watchdog_deferred_registration_add()
79 list_del(&wdd_tmp->deferred); in watchdog_deferred_registration_del()
88 * Check that we have valid min and max timeout values, if in watchdog_check_min_max_timeout()
91 if (!wdd->max_hw_heartbeat_ms && wdd->min_timeout > wdd->max_timeout) { in watchdog_check_min_max_timeout()
92 pr_info("Invalid min and max timeout values, resetting to 0!\n"); in watchdog_check_min_max_timeout()
93 wdd->min_timeout = 0; in watchdog_check_min_max_timeout()
94 wdd->max_timeout = 0; in watchdog_check_min_max_timeout()
99 * watchdog_init_timeout() - initialize the timeout field
101 * @timeout_parm: timeout module parameter
102 * @dev: Device that stores the timeout-sec property
104 * Initialize the timeout field of the watchdog_device struct with either the
105 * timeout module parameter (if it is valid value) or the timeout-sec property
108 * be the default timeout value). Note that for the module parameter, '0' means
109 * 'use default' while it is an invalid value for the timeout-sec property.
112 * A zero is returned on success or -EINVAL if all provided values are out of
118 const char *dev_str = wdd->parent ? dev_name(wdd->parent) : in watchdog_init_timeout()
119 (const char *)wdd->info->identity; in watchdog_init_timeout()
128 wdd->timeout = timeout_parm; in watchdog_init_timeout()
131 pr_err("%s: driver supplied timeout (%u) out of range\n", in watchdog_init_timeout()
133 ret = -EINVAL; in watchdog_init_timeout()
137 if (dev && dev->of_node && in watchdog_init_timeout()
138 of_property_read_u32(dev->of_node, "timeout-sec", &t) == 0) { in watchdog_init_timeout()
140 wdd->timeout = t; in watchdog_init_timeout()
143 pr_err("%s: DT supplied timeout (%u) out of range\n", dev_str, t); in watchdog_init_timeout()
144 ret = -EINVAL; in watchdog_init_timeout()
147 if (ret < 0 && wdd->timeout) in watchdog_init_timeout()
148 pr_warn("%s: falling back to default timeout (%u)\n", dev_str, in watchdog_init_timeout()
149 wdd->timeout); in watchdog_init_timeout()
165 ret = wdd->ops->stop(wdd); in watchdog_reboot_notifier()
182 ret = wdd->ops->restart(wdd, action, data); in watchdog_restart_notifier()
217 * watchdog_set_restart_priority - Change priority of restart handler
226 * If a wdd->ops->restart function is provided when watchdog_register_device is
232 wdd->restart_nb.priority = priority; in watchdog_set_restart_priority()
238 int ret, id = -1; in __watchdog_register_device()
240 if (wdd == NULL || wdd->info == NULL || wdd->ops == NULL) in __watchdog_register_device()
241 return -EINVAL; in __watchdog_register_device()
244 if (!wdd->ops->start || (!wdd->ops->stop && !wdd->max_hw_heartbeat_ms)) in __watchdog_register_device()
245 return -EINVAL; in __watchdog_register_device()
256 if (wdd->parent) { in __watchdog_register_device()
257 ret = of_alias_get_id(wdd->parent->of_node, "watchdog"); in __watchdog_register_device()
268 wdd->id = id; in __watchdog_register_device()
273 if (!(id == 0 && ret == -EBUSY)) in __watchdog_register_device()
280 wdd->id = id; in __watchdog_register_device()
290 if (stop_on_reboot != -1) { in __watchdog_register_device()
292 set_bit(WDOG_STOP_ON_REBOOT, &wdd->status); in __watchdog_register_device()
294 clear_bit(WDOG_STOP_ON_REBOOT, &wdd->status); in __watchdog_register_device()
297 if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) { in __watchdog_register_device()
298 if (!wdd->ops->stop) in __watchdog_register_device()
299 pr_warn("watchdog%d: stop_on_reboot not supported\n", wdd->id); in __watchdog_register_device()
301 wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; in __watchdog_register_device()
303 ret = register_reboot_notifier(&wdd->reboot_nb); in __watchdog_register_device()
306 wdd->id, ret); in __watchdog_register_device()
314 if (wdd->ops->restart) { in __watchdog_register_device()
315 wdd->restart_nb.notifier_call = watchdog_restart_notifier; in __watchdog_register_device()
317 ret = register_restart_handler(&wdd->restart_nb); in __watchdog_register_device()
320 wdd->id, ret); in __watchdog_register_device()
323 if (test_bit(WDOG_NO_PING_ON_SUSPEND, &wdd->status)) { in __watchdog_register_device()
324 wdd->pm_nb.notifier_call = watchdog_pm_notifier; in __watchdog_register_device()
326 ret = register_pm_notifier(&wdd->pm_nb); in __watchdog_register_device()
329 wdd->id, ret); in __watchdog_register_device()
336 * watchdog_register_device() - register a watchdog device
359 dev_str = wdd->parent ? dev_name(wdd->parent) : in watchdog_register_device()
360 (const char *)wdd->info->identity; in watchdog_register_device()
374 if (wdd->ops->restart) in __watchdog_unregister_device()
375 unregister_restart_handler(&wdd->restart_nb); in __watchdog_unregister_device()
377 if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) in __watchdog_unregister_device()
378 unregister_reboot_notifier(&wdd->reboot_nb); in __watchdog_unregister_device()
381 ida_simple_remove(&watchdog_ida, wdd->id); in __watchdog_unregister_device()
385 * watchdog_unregister_device() - unregister a watchdog device
410 * devm_watchdog_register_device() - resource managed watchdog_register_device()
427 return -ENOMEM; in devm_watchdog_register_device()
450 list_del(&wdd->deferred); in watchdog_deferred_registration()