Skip to content

Commit

Permalink
alarmtimer: Return relative times in timer_gettime
Browse files Browse the repository at this point in the history
Returns the time remaining for an alarm timer, rather than the time at
which it is scheduled to expire.  If the timer has already expired or it
is not currently scheduled, the it_value's members are set to zero.

This new behavior matches that of the other posix-timers and the POSIX
specifications.

This is a change in user-visible behavior, and may break existing
applications.  Hopefully, few users rely on the old incorrect behavior.

Cc: stable@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Sharvil Nanavati <sharvil@google.com>
Signed-off-by: Richard Larocque <rlarocque@google.com>
[jstultz: minor style tweak]
Signed-off-by: John Stultz <john.stultz@linaro.org>
  • Loading branch information
Richard Larocque authored and John Stultz committed Sep 12, 2014
1 parent d78c930 commit e86fea7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions kernel/time/alarmtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,18 +541,22 @@ static int alarm_timer_create(struct k_itimer *new_timer)
* @new_timer: k_itimer pointer
* @cur_setting: itimerspec data to fill
*
* Copies the itimerspec data out from the k_itimer
* Copies out the current itimerspec data
*/
static void alarm_timer_get(struct k_itimer *timr,
struct itimerspec *cur_setting)
{
memset(cur_setting, 0, sizeof(struct itimerspec));
ktime_t relative_expiry_time =
alarm_expires_remaining(&(timr->it.alarm.alarmtimer));

cur_setting->it_interval =
ktime_to_timespec(timr->it.alarm.interval);
cur_setting->it_value =
ktime_to_timespec(timr->it.alarm.alarmtimer.node.expires);
return;
if (ktime_to_ns(relative_expiry_time) > 0) {
cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
} else {
cur_setting->it_value.tv_sec = 0;
cur_setting->it_value.tv_nsec = 0;
}

cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
}

/**
Expand Down

0 comments on commit e86fea7

Please sign in to comment.