From: Todd Poynor Date: Wed, 8 May 2013 22:49:18 +0000 (-0700) Subject: alarmtimer: add alarm_restart X-Git-Tag: firefly_0821_release~4090^2~566 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0ccfc3ce82fbc2b2df5ab11ebfa43f894a6a4ae7;p=firefly-linux-kernel-4.4.55.git alarmtimer: add alarm_restart 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 --- diff --git a/include/linux/alarmtimer.h b/include/linux/alarmtimer.h index 9069694e70eb..65e04ceec27d 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); +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 f11d83b12949..059e78b12676 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -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