• Home
  • Raw
  • Download

Lines Matching full:wdd

53  * @wdd:	Pointer to watchdog device.
60 struct watchdog_device *wdd; member
96 static inline bool watchdog_need_worker(struct watchdog_device *wdd) in watchdog_need_worker() argument
99 unsigned int hm = wdd->max_hw_heartbeat_ms; in watchdog_need_worker()
100 unsigned int t = wdd->timeout * 1000; in watchdog_need_worker()
115 return (hm && watchdog_active(wdd) && t > hm) || in watchdog_need_worker()
116 (t && !watchdog_active(wdd) && watchdog_hw_running(wdd)); in watchdog_need_worker()
119 static ktime_t watchdog_next_keepalive(struct watchdog_device *wdd) in watchdog_next_keepalive() argument
121 struct watchdog_core_data *wd_data = wdd->wd_data; in watchdog_next_keepalive()
122 unsigned int timeout_ms = wdd->timeout * 1000; in watchdog_next_keepalive()
128 if (watchdog_active(wdd)) in watchdog_next_keepalive()
134 hw_heartbeat_ms = min_not_zero(timeout_ms, wdd->max_hw_heartbeat_ms); in watchdog_next_keepalive()
138 * To ensure that the watchdog times out wdd->timeout seconds in watchdog_next_keepalive()
149 static inline void watchdog_update_worker(struct watchdog_device *wdd) in watchdog_update_worker() argument
151 struct watchdog_core_data *wd_data = wdd->wd_data; in watchdog_update_worker()
153 if (watchdog_need_worker(wdd)) { in watchdog_update_worker()
154 ktime_t t = watchdog_next_keepalive(wdd); in watchdog_update_worker()
164 static int __watchdog_ping(struct watchdog_device *wdd) in __watchdog_ping() argument
166 struct watchdog_core_data *wd_data = wdd->wd_data; in __watchdog_ping()
171 ms_to_ktime(wdd->min_hw_heartbeat_ms)); in __watchdog_ping()
183 if (wdd->ops->ping) in __watchdog_ping()
184 err = wdd->ops->ping(wdd); /* ping the watchdog */ in __watchdog_ping()
186 err = wdd->ops->start(wdd); /* restart watchdog */ in __watchdog_ping()
188 watchdog_update_worker(wdd); in __watchdog_ping()
195 * @wdd: the watchdog device to ping
205 static int watchdog_ping(struct watchdog_device *wdd) in watchdog_ping() argument
207 struct watchdog_core_data *wd_data = wdd->wd_data; in watchdog_ping()
209 if (!watchdog_active(wdd) && !watchdog_hw_running(wdd)) in watchdog_ping()
215 return __watchdog_ping(wdd); in watchdog_ping()
220 struct watchdog_device *wdd = wd_data->wdd; in watchdog_worker_should_ping() local
222 if (!wdd) in watchdog_worker_should_ping()
225 if (watchdog_active(wdd)) in watchdog_worker_should_ping()
228 return watchdog_hw_running(wdd) && !watchdog_past_open_deadline(wd_data); in watchdog_worker_should_ping()
239 __watchdog_ping(wd_data->wdd); in watchdog_ping_work()
255 * @wdd: the watchdog device to start
264 static int watchdog_start(struct watchdog_device *wdd) in watchdog_start() argument
266 struct watchdog_core_data *wd_data = wdd->wd_data; in watchdog_start()
270 if (watchdog_active(wdd)) in watchdog_start()
276 if (watchdog_hw_running(wdd) && wdd->ops->ping) { in watchdog_start()
277 err = __watchdog_ping(wdd); in watchdog_start()
279 set_bit(WDOG_ACTIVE, &wdd->status); in watchdog_start()
281 err = wdd->ops->start(wdd); in watchdog_start()
283 set_bit(WDOG_ACTIVE, &wdd->status); in watchdog_start()
286 watchdog_update_worker(wdd); in watchdog_start()
295 * @wdd: the watchdog device to stop
305 static int watchdog_stop(struct watchdog_device *wdd) in watchdog_stop() argument
309 if (!watchdog_active(wdd)) in watchdog_stop()
312 if (test_bit(WDOG_NO_WAY_OUT, &wdd->status)) { in watchdog_stop()
314 wdd->id); in watchdog_stop()
318 if (wdd->ops->stop) { in watchdog_stop()
319 clear_bit(WDOG_HW_RUNNING, &wdd->status); in watchdog_stop()
320 err = wdd->ops->stop(wdd); in watchdog_stop()
322 set_bit(WDOG_HW_RUNNING, &wdd->status); in watchdog_stop()
326 clear_bit(WDOG_ACTIVE, &wdd->status); in watchdog_stop()
327 watchdog_update_worker(wdd); in watchdog_stop()
335 * @wdd: the watchdog device to get the status from
342 static unsigned int watchdog_get_status(struct watchdog_device *wdd) in watchdog_get_status() argument
344 struct watchdog_core_data *wd_data = wdd->wd_data; in watchdog_get_status()
347 if (wdd->ops->status) in watchdog_get_status()
348 status = wdd->ops->status(wdd); in watchdog_get_status()
350 status = wdd->bootstatus & (WDIOF_CARDRESET | in watchdog_get_status()
369 * @wdd: the watchdog device to set the timeout for
375 static int watchdog_set_timeout(struct watchdog_device *wdd, in watchdog_set_timeout() argument
380 if (!(wdd->info->options & WDIOF_SETTIMEOUT)) in watchdog_set_timeout()
383 if (watchdog_timeout_invalid(wdd, timeout)) in watchdog_set_timeout()
386 if (wdd->ops->set_timeout) { in watchdog_set_timeout()
387 err = wdd->ops->set_timeout(wdd, timeout); in watchdog_set_timeout()
389 wdd->timeout = timeout; in watchdog_set_timeout()
391 if (wdd->pretimeout >= wdd->timeout) in watchdog_set_timeout()
392 wdd->pretimeout = 0; in watchdog_set_timeout()
395 watchdog_update_worker(wdd); in watchdog_set_timeout()
402 * @wdd: the watchdog device to set the timeout for
406 static int watchdog_set_pretimeout(struct watchdog_device *wdd, in watchdog_set_pretimeout() argument
411 if (!(wdd->info->options & WDIOF_PRETIMEOUT)) in watchdog_set_pretimeout()
414 if (watchdog_pretimeout_invalid(wdd, timeout)) in watchdog_set_pretimeout()
417 if (wdd->ops->set_pretimeout) in watchdog_set_pretimeout()
418 err = wdd->ops->set_pretimeout(wdd, timeout); in watchdog_set_pretimeout()
420 wdd->pretimeout = timeout; in watchdog_set_pretimeout()
427 * @wdd: the watchdog device to get the remaining time from
435 static int watchdog_get_timeleft(struct watchdog_device *wdd, in watchdog_get_timeleft() argument
440 if (!wdd->ops->get_timeleft) in watchdog_get_timeleft()
443 *timeleft = wdd->ops->get_timeleft(wdd); in watchdog_get_timeleft()
452 struct watchdog_device *wdd = dev_get_drvdata(dev); in nowayout_show() local
454 return sprintf(buf, "%d\n", !!test_bit(WDOG_NO_WAY_OUT, &wdd->status)); in nowayout_show()
460 struct watchdog_device *wdd = dev_get_drvdata(dev); in nowayout_store() local
470 if (test_bit(WDOG_NO_WAY_OUT, &wdd->status) && !value) in nowayout_store()
472 watchdog_set_nowayout(wdd, value); in nowayout_store()
480 struct watchdog_device *wdd = dev_get_drvdata(dev); in status_show() local
481 struct watchdog_core_data *wd_data = wdd->wd_data; in status_show()
485 status = watchdog_get_status(wdd); in status_show()
495 struct watchdog_device *wdd = dev_get_drvdata(dev); in bootstatus_show() local
497 return sprintf(buf, "%u\n", wdd->bootstatus); in bootstatus_show()
504 struct watchdog_device *wdd = dev_get_drvdata(dev); in timeleft_show() local
505 struct watchdog_core_data *wd_data = wdd->wd_data; in timeleft_show()
510 status = watchdog_get_timeleft(wdd, &val); in timeleft_show()
522 struct watchdog_device *wdd = dev_get_drvdata(dev); in timeout_show() local
524 return sprintf(buf, "%u\n", wdd->timeout); in timeout_show()
531 struct watchdog_device *wdd = dev_get_drvdata(dev); in pretimeout_show() local
533 return sprintf(buf, "%u\n", wdd->pretimeout); in pretimeout_show()
540 struct watchdog_device *wdd = dev_get_drvdata(dev); in identity_show() local
542 return sprintf(buf, "%s\n", wdd->info->identity); in identity_show()
549 struct watchdog_device *wdd = dev_get_drvdata(dev); in state_show() local
551 if (watchdog_active(wdd)) in state_show()
569 struct watchdog_device *wdd = dev_get_drvdata(dev); in pretimeout_governor_show() local
571 return watchdog_pretimeout_governor_get(wdd, buf); in pretimeout_governor_show()
578 struct watchdog_device *wdd = dev_get_drvdata(dev); in pretimeout_governor_store() local
579 int ret = watchdog_pretimeout_governor_set(wdd, buf); in pretimeout_governor_store()
592 struct watchdog_device *wdd = dev_get_drvdata(dev); in wdt_is_visible() local
595 if (attr == &dev_attr_timeleft.attr && !wdd->ops->get_timeleft) in wdt_is_visible()
598 !(wdd->info->options & WDIOF_PRETIMEOUT)) in wdt_is_visible()
602 (!(wdd->info->options & WDIOF_PRETIMEOUT) || in wdt_is_visible()
633 * @wdd: the watchdog device to do the ioctl on
640 static int watchdog_ioctl_op(struct watchdog_device *wdd, unsigned int cmd, in watchdog_ioctl_op() argument
643 if (!wdd->ops->ioctl) in watchdog_ioctl_op()
646 return wdd->ops->ioctl(wdd, cmd, arg); in watchdog_ioctl_op()
665 struct watchdog_device *wdd; in watchdog_write() local
691 wdd = wd_data->wdd; in watchdog_write()
692 if (wdd) in watchdog_write()
693 err = watchdog_ping(wdd); in watchdog_write()
717 struct watchdog_device *wdd; in watchdog_ioctl() local
724 wdd = wd_data->wdd; in watchdog_ioctl()
725 if (!wdd) { in watchdog_ioctl()
730 err = watchdog_ioctl_op(wdd, cmd, arg); in watchdog_ioctl()
736 err = copy_to_user(argp, wdd->info, in watchdog_ioctl()
740 val = watchdog_get_status(wdd); in watchdog_ioctl()
744 err = put_user(wdd->bootstatus, p); in watchdog_ioctl()
752 err = watchdog_stop(wdd); in watchdog_ioctl()
757 err = watchdog_start(wdd); in watchdog_ioctl()
760 if (!(wdd->info->options & WDIOF_KEEPALIVEPING)) { in watchdog_ioctl()
764 err = watchdog_ping(wdd); in watchdog_ioctl()
771 err = watchdog_set_timeout(wdd, val); in watchdog_ioctl()
777 err = watchdog_ping(wdd); in watchdog_ioctl()
783 if (wdd->timeout == 0) { in watchdog_ioctl()
787 err = put_user(wdd->timeout, p); in watchdog_ioctl()
790 err = watchdog_get_timeleft(wdd, &val); in watchdog_ioctl()
800 err = watchdog_set_pretimeout(wdd, val); in watchdog_ioctl()
803 err = put_user(wdd->pretimeout, p); in watchdog_ioctl()
828 struct watchdog_device *wdd; in watchdog_open() local
843 wdd = wd_data->wdd; in watchdog_open()
849 hw_running = watchdog_hw_running(wdd); in watchdog_open()
850 if (!hw_running && !try_module_get(wdd->ops->owner)) { in watchdog_open()
855 err = watchdog_start(wdd); in watchdog_open()
877 module_put(wd_data->wdd->ops->owner); in watchdog_open()
905 struct watchdog_device *wdd; in watchdog_release() local
911 wdd = wd_data->wdd; in watchdog_release()
912 if (!wdd) in watchdog_release()
920 if (!watchdog_active(wdd)) in watchdog_release()
923 !(wdd->info->options & WDIOF_MAGICCLOSE)) in watchdog_release()
924 err = watchdog_stop(wdd); in watchdog_release()
928 pr_crit("watchdog%d: watchdog did not stop!\n", wdd->id); in watchdog_release()
929 watchdog_ping(wdd); in watchdog_release()
932 watchdog_update_worker(wdd); in watchdog_release()
938 running = wdd && watchdog_hw_running(wdd); in watchdog_release()
975 * @wdd: watchdog device
982 static int watchdog_cdev_register(struct watchdog_device *wdd) in watchdog_cdev_register() argument
992 wd_data->wdd = wdd; in watchdog_cdev_register()
993 wdd->wd_data = wd_data; in watchdog_cdev_register()
1001 wd_data->dev.devt = MKDEV(MAJOR(watchdog_devt), wdd->id); in watchdog_cdev_register()
1003 wd_data->dev.parent = wdd->parent; in watchdog_cdev_register()
1004 wd_data->dev.groups = wdd->groups; in watchdog_cdev_register()
1006 dev_set_drvdata(&wd_data->dev, wdd); in watchdog_cdev_register()
1007 dev_set_name(&wd_data->dev, "watchdog%d", wdd->id); in watchdog_cdev_register()
1013 if (wdd->id == 0) { in watchdog_cdev_register()
1015 watchdog_miscdev.parent = wdd->parent; in watchdog_cdev_register()
1019 wdd->info->identity, WATCHDOG_MINOR, err); in watchdog_cdev_register()
1022 wdd->info->identity); in watchdog_cdev_register()
1036 wdd->id, MAJOR(watchdog_devt), wdd->id); in watchdog_cdev_register()
1037 if (wdd->id == 0) { in watchdog_cdev_register()
1045 wd_data->cdev.owner = wdd->ops->owner; in watchdog_cdev_register()
1055 if (watchdog_hw_running(wdd)) { in watchdog_cdev_register()
1056 __module_get(wdd->ops->owner); in watchdog_cdev_register()
1063 wdd->id); in watchdog_cdev_register()
1077 static void watchdog_cdev_unregister(struct watchdog_device *wdd) in watchdog_cdev_unregister() argument
1079 struct watchdog_core_data *wd_data = wdd->wd_data; in watchdog_cdev_unregister()
1082 if (wdd->id == 0) { in watchdog_cdev_unregister()
1087 if (watchdog_active(wdd) && in watchdog_cdev_unregister()
1088 test_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status)) { in watchdog_cdev_unregister()
1089 watchdog_stop(wdd); in watchdog_cdev_unregister()
1093 wd_data->wdd = NULL; in watchdog_cdev_unregister()
1094 wdd->wd_data = NULL; in watchdog_cdev_unregister()
1105 * @wdd: watchdog device
1112 int watchdog_dev_register(struct watchdog_device *wdd) in watchdog_dev_register() argument
1116 ret = watchdog_cdev_register(wdd); in watchdog_dev_register()
1120 ret = watchdog_register_pretimeout(wdd); in watchdog_dev_register()
1122 watchdog_cdev_unregister(wdd); in watchdog_dev_register()
1135 void watchdog_dev_unregister(struct watchdog_device *wdd) in watchdog_dev_unregister() argument
1137 watchdog_unregister_pretimeout(wdd); in watchdog_dev_unregister()
1138 watchdog_cdev_unregister(wdd); in watchdog_dev_unregister()
1143 * @wdd: watchdog device
1152 int watchdog_set_last_hw_keepalive(struct watchdog_device *wdd, in watchdog_set_last_hw_keepalive() argument
1158 if (!wdd) in watchdog_set_last_hw_keepalive()
1161 wd_data = wdd->wd_data; in watchdog_set_last_hw_keepalive()
1167 if (watchdog_hw_running(wdd) && handle_boot_enabled) in watchdog_set_last_hw_keepalive()
1168 return __watchdog_ping(wdd); in watchdog_set_last_hw_keepalive()