From 9231422b0b0c91d88361752efd34b67ff5e2800c Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Fri, 10 May 2013 17:41:06 -0700 Subject: [PATCH] alarmtimer: add alarm_start_relative Start an alarmtimer with an expires time relative to the current time of the associated clock. Change-Id: Ifb5309a15e0d502bb4d0209ca5510a56ee7fa88c Signed-off-by: Todd Poynor --- include/linux/alarmtimer.h | 1 + kernel/time/alarmtimer.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h index 8e696a105a4d..f47dadc6dab3 100644 --- a/include/linux/alarmtimer.h +++ b/include/linux/alarmtimer.h @@ -44,6 +44,7 @@ struct alarm { void alarm_init(struct alarm *alarm, enum alarmtimer_type type, enum alarmtimer_restart (*function)(struct alarm *, ktime_t)); int alarm_start(struct alarm *alarm, ktime_t start); +int alarm_start_relative(struct alarm *alarm, ktime_t start); void alarm_restart(struct alarm *alarm); int alarm_try_to_cancel(struct alarm *alarm); int alarm_cancel(struct alarm *alarm); diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 2f125e74d33d..adfcd78e79fd 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -305,7 +305,7 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type, } /** - * alarm_start - Sets an alarm to fire + * alarm_start - Sets an absolute alarm to fire * @alarm: ptr to alarm to set * @start: time to run the alarm */ @@ -324,6 +324,19 @@ int alarm_start(struct alarm *alarm, ktime_t start) return ret; } +/** + * alarm_start_relative - Sets a relative alarm to fire + * @alarm: ptr to alarm to set + * @start: time relative to now to run the alarm + */ +int alarm_start_relative(struct alarm *alarm, ktime_t start) +{ + struct alarm_base *base = &alarm_bases[alarm->type]; + + start = ktime_add(start, base->gettime()); + return alarm_start(alarm, start); +} + void alarm_restart(struct alarm *alarm) { struct alarm_base *base = &alarm_bases[alarm->type]; -- 2.34.1