alarmtimer: add alarm_restart
authorTodd Poynor <toddpoynor@google.com>
Wed, 8 May 2013 22:49:18 +0000 (15:49 -0700)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 21:16:28 +0000 (14:16 -0700)
Analogous to hrtimer_restart, restart an alarmtimer after the expires
time has already been updated (as with alarm_forward).

Change-Id: Ia2613bbb467404cb2c35c11efa772bc56294963a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
include/linux/alarmtimer.h
kernel/time/alarmtimer.c

index 9069694e70eb9eee8b1bf4e229f29f7959ce3b46..65e04ceec27d1432609729a99ab05a0c70eef765 100644 (file)
@@ -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);
+void alarm_restart(struct alarm *alarm);
 int alarm_try_to_cancel(struct alarm *alarm);
 int alarm_cancel(struct alarm *alarm);
 
index f11d83b1294992db1e13c5f9266fb14f1bbde573..059e78b12676d50969fe2f23583c2379b34d6fa0 100644 (file)
@@ -324,6 +324,18 @@ int alarm_start(struct alarm *alarm, ktime_t start)
        return ret;
 }
 
+void alarm_restart(struct alarm *alarm)
+{
+       struct alarm_base *base = &alarm_bases[alarm->type];
+       unsigned long flags;
+
+       spin_lock_irqsave(&base->lock, flags);
+       hrtimer_set_expires(&alarm->timer, alarm->node.expires);
+       hrtimer_restart(&alarm->timer);
+       alarmtimer_enqueue(base, alarm);
+       spin_unlock_irqrestore(&base->lock, flags);
+}
+
 /**
  * alarm_try_to_cancel - Tries to cancel an alarm timer
  * @alarm: ptr to alarm to be canceled