Lines Matching +full:timeout +full:- +full:sec

1 // SPDX-License-Identifier: GPL-2.0+
5 * (c) Copyright 2008-2011 Alan Cox <[email protected]>,
8 * (c) Copyright 2008-2011 Wim Van Sebroeck <[email protected]>.
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()
268 id = ida_alloc_max(&watchdog_ida, MAX_DOGS - 1, GFP_KERNEL); in ___watchdog_register_device()
272 wdd->id = id; in ___watchdog_register_device()
277 if (!(id == 0 && ret == -EBUSY)) in ___watchdog_register_device()
281 id = ida_alloc_range(&watchdog_ida, 1, MAX_DOGS - 1, in ___watchdog_register_device()
285 wdd->id = id; in ___watchdog_register_device()
295 if (stop_on_reboot != -1) { in ___watchdog_register_device()
297 set_bit(WDOG_STOP_ON_REBOOT, &wdd->status); in ___watchdog_register_device()
299 clear_bit(WDOG_STOP_ON_REBOOT, &wdd->status); in ___watchdog_register_device()
302 if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) { in ___watchdog_register_device()
303 if (!wdd->ops->stop) in ___watchdog_register_device()
304 pr_warn("watchdog%d: stop_on_reboot not supported\n", wdd->id); in ___watchdog_register_device()
306 wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; in ___watchdog_register_device()
308 ret = register_reboot_notifier(&wdd->reboot_nb); in ___watchdog_register_device()
311 wdd->id, ret); in ___watchdog_register_device()
319 if (wdd->ops->restart) { in ___watchdog_register_device()
320 wdd->restart_nb.notifier_call = watchdog_restart_notifier; in ___watchdog_register_device()
322 ret = register_restart_handler(&wdd->restart_nb); in ___watchdog_register_device()
325 wdd->id, ret); in ___watchdog_register_device()
328 if (test_bit(WDOG_NO_PING_ON_SUSPEND, &wdd->status)) { in ___watchdog_register_device()
329 wdd->pm_nb.notifier_call = watchdog_pm_notifier; in ___watchdog_register_device()
331 ret = register_pm_notifier(&wdd->pm_nb); in ___watchdog_register_device()
334 wdd->id, ret); in ___watchdog_register_device()
347 dev_str = wdd->parent ? dev_name(wdd->parent) : in __watchdog_register_device()
348 (const char *)wdd->info->identity; in __watchdog_register_device()
357 * watchdog_register_device() - register a watchdog device
387 if (wdd->ops->restart) in __watchdog_unregister_device()
388 unregister_restart_handler(&wdd->restart_nb); in __watchdog_unregister_device()
390 if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) in __watchdog_unregister_device()
391 unregister_reboot_notifier(&wdd->reboot_nb); in __watchdog_unregister_device()
394 ida_free(&watchdog_ida, wdd->id); in __watchdog_unregister_device()
398 * watchdog_unregister_device() - unregister a watchdog device
423 * devm_watchdog_register_device() - resource managed watchdog_register_device()
440 return -ENOMEM; in devm_watchdog_register_device()
463 list_del(&wdd->deferred); in watchdog_deferred_registration()