aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2013-05-07 20:43:29 -0700
committerArve Hjønnevåg <arve@android.com>2013-07-01 14:16:28 -0700
commit7b71ddcebb443992703f409994bebb3a3121bfc8 (patch)
tree4155702b2b32722d6ab06ca5acf666a2b7f2aead
parent9231422b0b0c91d88361752efd34b67ff5e2800c (diff)
alarmtimer: add alarm_expires_remaining
Similar to hrtimer_expires_remaining, return the amount of time remaining until alarm expiry. Change-Id: I8c57512d619ac66bcdaf2d9ccdf0d7f74af2ff66 Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r--include/linux/alarmtimer.h1
-rw-r--r--kernel/time/alarmtimer.c6
2 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h
index f47dadc6dab..a899402a5a0 100644
--- a/include/linux/alarmtimer.h
+++ b/include/linux/alarmtimer.h
@@ -51,6 +51,7 @@ int alarm_cancel(struct alarm *alarm);
u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
u64 alarm_forward_now(struct alarm *alarm, ktime_t interval);
+ktime_t alarm_expires_remaining(const struct alarm *alarm);
/* Provide way to access the rtc device being used by alarmtimers */
struct rtc_device *alarmtimer_get_rtcdev(void);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index adfcd78e79f..3e5cba27447 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -199,6 +199,12 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer)
}
+ktime_t alarm_expires_remaining(const struct alarm *alarm)
+{
+ struct alarm_base *base = &alarm_bases[alarm->type];
+ return ktime_sub(alarm->node.expires, base->gettime());
+}
+
#ifdef CONFIG_RTC_CLASS
/**
* alarmtimer_suspend - Suspend time callback