at v4.10 1.8 kB view raw
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 9enum alarmtimer_type { 10 ALARM_REALTIME, 11 ALARM_BOOTTIME, 12 13 /* Supported types end here */ 14 ALARM_NUMTYPE, 15 16 /* Used for tracing information. No usable types. */ 17 ALARM_REALTIME_FREEZER, 18 ALARM_BOOTTIME_FREEZER, 19}; 20 21enum alarmtimer_restart { 22 ALARMTIMER_NORESTART, 23 ALARMTIMER_RESTART, 24}; 25 26 27#define ALARMTIMER_STATE_INACTIVE 0x00 28#define ALARMTIMER_STATE_ENQUEUED 0x01 29 30/** 31 * struct alarm - Alarm timer structure 32 * @node: timerqueue node for adding to the event list this value 33 * also includes the expiration time. 34 * @timer: hrtimer used to schedule events while running 35 * @function: Function pointer to be executed when the timer fires. 36 * @type: Alarm type (BOOTTIME/REALTIME). 37 * @state: Flag that represents if the alarm is set to fire or not. 38 * @data: Internal data value. 39 */ 40struct alarm { 41 struct timerqueue_node node; 42 struct hrtimer timer; 43 enum alarmtimer_restart (*function)(struct alarm *, ktime_t now); 44 enum alarmtimer_type type; 45 int state; 46 void *data; 47}; 48 49void alarm_init(struct alarm *alarm, enum alarmtimer_type type, 50 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)); 51void alarm_start(struct alarm *alarm, ktime_t start); 52void alarm_start_relative(struct alarm *alarm, ktime_t start); 53void alarm_restart(struct alarm *alarm); 54int alarm_try_to_cancel(struct alarm *alarm); 55int alarm_cancel(struct alarm *alarm); 56 57u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval); 58u64 alarm_forward_now(struct alarm *alarm, ktime_t interval); 59ktime_t alarm_expires_remaining(const struct alarm *alarm); 60 61/* Provide way to access the rtc device being used by alarmtimers */ 62struct rtc_device *alarmtimer_get_rtcdev(void); 63 64#endif