alarmtimer: add alarm_expires_remaining
authorTodd Poynor <toddpoynor@google.com>
Wed, 8 May 2013 03:43:29 +0000 (20:43 -0700)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 21:16:28 +0000 (14:16 -0700)
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>
include/linux/alarmtimer.h
kernel/time/alarmtimer.c

index f47dadc6dab3357e86a1fd78a6a1545ef683ce4a..a899402a5a0e6325c0b3dce2f03c7dca06846238 100644 (file)
@@ -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);
index adfcd78e79fd474ba2835dc4a9db3494ea6c4bd5..3e5cba274475df2ab70edb04d9695dfe28a945aa 100644 (file)
@@ -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