blob: 17535963b2744c14b9907308980b7761b345b9c6 [file] [log] [blame]
John Stultzff3ead92011-01-11 09:42:13 -08001#ifndef _LINUX_ALARMTIMER_H
2#define _LINUX_ALARMTIMER_H
3
4#include <linux/time.h>
5#include <linux/hrtimer.h>
6#include <linux/timerqueue.h>
7#include <linux/rtc.h>
8
9enum alarmtimer_type {
10 ALARM_REALTIME,
11 ALARM_BOOTTIME,
12
13 ALARM_NUMTYPE,
14};
15
John Stultz4b413082011-08-10 10:37:59 -070016enum alarmtimer_restart {
17 ALARMTIMER_NORESTART,
18 ALARMTIMER_RESTART,
19};
20
John Stultz180bf812011-04-28 12:58:11 -070021/**
22 * struct alarm - Alarm timer structure
23 * @node: timerqueue node for adding to the event list this value
24 * also includes the expiration time.
25 * @period: Period for recuring alarms
26 * @function: Function pointer to be executed when the timer fires.
27 * @type: Alarm type (BOOTTIME/REALTIME)
28 * @enabled: Flag that represents if the alarm is set to fire or not
29 * @data: Internal data value.
30 */
John Stultzff3ead92011-01-11 09:42:13 -080031struct alarm {
32 struct timerqueue_node node;
33 ktime_t period;
John Stultz4b413082011-08-10 10:37:59 -070034 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
John Stultzff3ead92011-01-11 09:42:13 -080035 enum alarmtimer_type type;
John Stultz180bf812011-04-28 12:58:11 -070036 bool enabled;
John Stultzff3ead92011-01-11 09:42:13 -080037 void *data;
38};
39
40void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
John Stultz4b413082011-08-10 10:37:59 -070041 enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
John Stultzff3ead92011-01-11 09:42:13 -080042void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
43void alarm_cancel(struct alarm *alarm);
44
John Stultzdce75a82011-08-10 11:31:03 -070045u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
46
John Stultzff3ead92011-01-11 09:42:13 -080047#endif