0001
0002
0003
0004
0005
0006 #include <linux/hrtimer.h>
0007 #include <linux/watchdog.h>
0008
0009 #include "watchdog_core.h"
0010 #include "watchdog_pretimeout.h"
0011
0012 static enum hrtimer_restart watchdog_hrtimer_pretimeout(struct hrtimer *timer)
0013 {
0014 struct watchdog_core_data *wd_data;
0015
0016 wd_data = container_of(timer, struct watchdog_core_data, pretimeout_timer);
0017
0018 watchdog_notify_pretimeout(wd_data->wdd);
0019 return HRTIMER_NORESTART;
0020 }
0021
0022 void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd)
0023 {
0024 struct watchdog_core_data *wd_data = wdd->wd_data;
0025
0026 hrtimer_init(&wd_data->pretimeout_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
0027 wd_data->pretimeout_timer.function = watchdog_hrtimer_pretimeout;
0028 }
0029
0030 void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
0031 {
0032 if (!(wdd->info->options & WDIOF_PRETIMEOUT) &&
0033 !watchdog_pretimeout_invalid(wdd, wdd->pretimeout))
0034 hrtimer_start(&wdd->wd_data->pretimeout_timer,
0035 ktime_set(wdd->timeout - wdd->pretimeout, 0),
0036 HRTIMER_MODE_REL);
0037 else
0038 hrtimer_cancel(&wdd->wd_data->pretimeout_timer);
0039 }
0040
0041 void watchdog_hrtimer_pretimeout_stop(struct watchdog_device *wdd)
0042 {
0043 hrtimer_cancel(&wdd->wd_data->pretimeout_timer);
0044 }