Skip to content

Commit ff3ead9

Browse files
timers: Introduce in-kernel alarm-timer interface
This provides the in kernel interface and infrastructure for alarm-timers. Alarm-timers are a hybrid style timer, similar to hrtimers, but when the system is suspended, the RTC device is set to fire and wake the system for when the soonest alarm-timer expires. The concept for Alarm-timers was inspired by the Android Alarm driver (by Arve Hjønnevåg) found in the Android kernel tree. See: http://android.git.kernel.org/?p=kernel/common.git;a=blob;f=drivers/rtc/alarm.c;h=1250edfbdf3302f5e4ea6194847c6ef4bb7beb1c;hb=android-2.6.36 This in-kernel interface should be fairly compatible with the Android alarm driver in-kernel interface, but has the advantage of utilizing the new RTC timerqueue code instead of doing direct RTC manipulation. CC: Arve Hjønnevåg <arve@android.com> CC: Thomas Gleixner <tglx@linutronix.de> CC: Alessandro Zummo <a.zummo@towertech.it> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent 88d19cf commit ff3ead9

3 files changed

Lines changed: 406 additions & 1 deletion

File tree

‎include/linux/alarmtimer.h‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
16+
struct alarm {
17+
struct timerqueue_node node;
18+
ktime_t period;
19+
void (*function)(struct alarm *);
20+
enum alarmtimer_type type;
21+
char enabled;
22+
void *data;
23+
};
24+
25+
void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
26+
void (*function)(struct alarm *));
27+
void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
28+
void alarm_cancel(struct alarm *alarm);
29+
30+
#endif

‎kernel/time/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
obj-y += timekeeping.o ntp.o clocksource.o jiffies.o timer_list.o timecompare.o
2-
obj-y += timeconv.o posix-clock.o
2+
obj-y += timeconv.o posix-clock.o alarmtimer.o
33

44
obj-$(CONFIG_GENERIC_CLOCKEVENTS_BUILD) += clockevents.o
55
obj-$(CONFIG_GENERIC_CLOCKEVENTS) += tick-common.o

0 commit comments

Comments
 (0)