1
2#ifndef _LINUX_ALARMTIMER_H
3#define _LINUX_ALARMTIMER_H
4
5#include <linux/time.h>
6#include <linux/hrtimer.h>
7#include <linux/timerqueue.h>
8#include <linux/rtc.h>
9
10enum alarmtimer_type {
11 ALARM_REALTIME,
12 ALARM_BOOTTIME,
13
14
15 ALARM_NUMTYPE,
16
17
18 ALARM_REALTIME_FREEZER,
19 ALARM_BOOTTIME_FREEZER,
20};
21
22enum alarmtimer_restart {
23 ALARMTIMER_NORESTART,
24 ALARMTIMER_RESTART,
25};
26
27
28#define ALARMTIMER_STATE_INACTIVE 0x00
29#define ALARMTIMER_STATE_ENQUEUED 0x01
30
31
32
33
34
35
36
37
38
39
40
41struct alarm {
42 struct timerqueue_node node;
43 struct hrtimer timer;
44 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
45 enum alarmtimer_type type;
46 int state;
47 void *data;
48};
49
50void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
51 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
52void alarm_start(struct alarm *alarm, ktime_t start);
53void alarm_start_relative(struct alarm *alarm, ktime_t start);
54void alarm_restart(struct alarm *alarm);
55int alarm_try_to_cancel(struct alarm *alarm);
56int alarm_cancel(struct alarm *alarm);
57
58u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
59u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
60ktime_t alarm_expires_remaining(const struct alarm *alarm);
61
62
63struct rtc_device *alarmtimer_get_rtcdev(void);
64
65#endif
66