0001
0002 #ifndef _LINUX_ALARMTIMER_H
0003 #define _LINUX_ALARMTIMER_H
0004
0005 #include <linux/time.h>
0006 #include <linux/hrtimer.h>
0007 #include <linux/timerqueue.h>
0008
0009 struct rtc_device;
0010
0011 enum alarmtimer_type {
0012 ALARM_REALTIME,
0013 ALARM_BOOTTIME,
0014
0015
0016 ALARM_NUMTYPE,
0017
0018
0019 ALARM_REALTIME_FREEZER,
0020 ALARM_BOOTTIME_FREEZER,
0021 };
0022
0023 enum alarmtimer_restart {
0024 ALARMTIMER_NORESTART,
0025 ALARMTIMER_RESTART,
0026 };
0027
0028
0029 #define ALARMTIMER_STATE_INACTIVE 0x00
0030 #define ALARMTIMER_STATE_ENQUEUED 0x01
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 struct alarm {
0043 struct timerqueue_node node;
0044 struct hrtimer timer;
0045 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
0046 enum alarmtimer_type type;
0047 int state;
0048 void *data;
0049 };
0050
0051 void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
0052 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
0053 void alarm_start(struct alarm *alarm, ktime_t start);
0054 void alarm_start_relative(struct alarm *alarm, ktime_t start);
0055 void alarm_restart(struct alarm *alarm);
0056 int alarm_try_to_cancel(struct alarm *alarm);
0057 int alarm_cancel(struct alarm *alarm);
0058
0059 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
0060 u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
0061 ktime_t alarm_expires_remaining(const struct alarm *alarm);
0062
0063 #ifdef CONFIG_RTC_CLASS
0064
0065 struct rtc_device *alarmtimer_get_rtcdev(void);
0066 #else
0067 static inline struct rtc_device *alarmtimer_get_rtcdev(void) { return NULL; }
0068 #endif
0069
0070 #endif