John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 1 | #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 | |
| 9 | enum alarmtimer_type { |
| 10 | ALARM_REALTIME, |
| 11 | ALARM_BOOTTIME, |
| 12 | |
| 13 | ALARM_NUMTYPE, |
| 14 | }; |
| 15 | |
John Stultz | 180bf81 | 2011-04-28 12:58:11 -0700 | [diff] [blame] | 16 | /** |
| 17 | * struct alarm - Alarm timer structure |
| 18 | * @node: timerqueue node for adding to the event list this value |
| 19 | * also includes the expiration time. |
| 20 | * @period: Period for recuring alarms |
| 21 | * @function: Function pointer to be executed when the timer fires. |
| 22 | * @type: Alarm type (BOOTTIME/REALTIME) |
| 23 | * @enabled: Flag that represents if the alarm is set to fire or not |
| 24 | * @data: Internal data value. |
| 25 | */ |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 26 | struct alarm { |
| 27 | struct timerqueue_node node; |
| 28 | ktime_t period; |
| 29 | void (*function)(struct alarm *); |
| 30 | enum alarmtimer_type type; |
John Stultz | 180bf81 | 2011-04-28 12:58:11 -0700 | [diff] [blame] | 31 | bool enabled; |
John Stultz | ff3ead9 | 2011-01-11 09:42:13 -0800 | [diff] [blame] | 32 | void *data; |
| 33 | }; |
| 34 | |
| 35 | void alarm_init(struct alarm *alarm, enum alarmtimer_type type, |
| 36 | void (*function)(struct alarm *)); |
| 37 | void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period); |
| 38 | void alarm_cancel(struct alarm *alarm); |
| 39 | |
| 40 | #endif |