alarmtimers: Remove period from alarm structure
authorJohn Stultz <john.stultz@linaro.org>
Wed, 10 Aug 2011 19:09:24 +0000 (12:09 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Wed, 10 Aug 2011 21:55:26 +0000 (14:55 -0700)
Now that periodic alarmtimers are managed by the handler function,
remove the period value from the alarm structure and let the handlers
manage the interval on their own.

CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/alarmtimer.h
include/linux/posix-timers.h
kernel/time/alarmtimer.c

index 17535963b2744c14b9907308980b7761b345b9c6..c854a8efa863e05e776ef3a6c657d32f4dcd2339 100644 (file)
@@ -30,7 +30,6 @@ enum alarmtimer_restart {
  */
 struct alarm {
        struct timerqueue_node  node;
-       ktime_t                 period;
        enum alarmtimer_restart (*function)(struct alarm *, ktime_t now);
        enum alarmtimer_type    type;
        bool                    enabled;
@@ -39,7 +38,7 @@ struct alarm {
 
 void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
                enum alarmtimer_restart (*function)(struct alarm *, ktime_t));
-void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period);
+void alarm_start(struct alarm *alarm, ktime_t start);
 void alarm_cancel(struct alarm *alarm);
 
 u64 alarm_forward(struct alarm *alarm, ktime_t now, ktime_t interval);
index 959c14132f465f8f3d0f5f61cd6d2701c252ae30..042058fdb0af3c4adcf7a0e3c5ee317fb73e2a8b 100644 (file)
@@ -81,7 +81,10 @@ struct k_itimer {
                        unsigned long incr;
                        unsigned long expires;
                } mmtimer;
-               struct alarm alarmtimer;
+               struct {
+                       struct alarm alarmtimer;
+                       ktime_t interval;
+               } alarm;
                struct rcu_head rcu;
        } it;
 };
index a522c007e6fda479f16f9bd2ea8a9459b16f21ef..90935591dd44573713e37b23f5a2e0db6e9babeb 100644 (file)
@@ -303,7 +303,6 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
                enum alarmtimer_restart (*function)(struct alarm *, ktime_t))
 {
        timerqueue_init(&alarm->node);
-       alarm->period = ktime_set(0, 0);
        alarm->function = function;
        alarm->type = type;
        alarm->enabled = 0;
@@ -313,9 +312,8 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
  * alarm_start - Sets an alarm to fire
  * @alarm: ptr to alarm to set
  * @start: time to run the alarm
- * @period: period at which the alarm will recur
  */
-void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period)
+void alarm_start(struct alarm *alarm, ktime_t start)
 {
        struct alarm_base *base = &alarm_bases[alarm->type];
        unsigned long flags;
@@ -324,7 +322,6 @@ void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period)
        if (alarm->enabled)
                alarmtimer_remove(base, alarm);
        alarm->node.expires = start;
-       alarm->period = period;
        alarmtimer_enqueue(base, alarm);
        alarm->enabled = 1;
        spin_unlock_irqrestore(&base->lock, flags);
@@ -405,13 +402,14 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
                                                        ktime_t now)
 {
        struct k_itimer *ptr = container_of(alarm, struct k_itimer,
-                                               it.alarmtimer);
+                                               it.alarm.alarmtimer);
        if (posix_timer_event(ptr, 0) != 0)
                ptr->it_overrun++;
 
        /* Re-add periodic timers */
-       if (alarm->period.tv64) {
-               ptr->it_overrun += alarm_forward(alarm, now, alarm->period);
+       if (ptr->it.alarm.interval.tv64) {
+               ptr->it_overrun += alarm_forward(alarm, now,
+                                               ptr->it.alarm.interval);
                return ALARMTIMER_RESTART;
        }
        return ALARMTIMER_NORESTART;
@@ -471,7 +469,7 @@ static int alarm_timer_create(struct k_itimer *new_timer)
 
        type = clock2alarm(new_timer->it_clock);
        base = &alarm_bases[type];
-       alarm_init(&new_timer->it.alarmtimer, type, alarm_handle_timer);
+       alarm_init(&new_timer->it.alarm.alarmtimer, type, alarm_handle_timer);
        return 0;
 }
 
@@ -488,9 +486,9 @@ static void alarm_timer_get(struct k_itimer *timr,
        memset(cur_setting, 0, sizeof(struct itimerspec));
 
        cur_setting->it_interval =
-                       ktime_to_timespec(timr->it.alarmtimer.period);
+                       ktime_to_timespec(timr->it.alarm.interval);
        cur_setting->it_value =
-                       ktime_to_timespec(timr->it.alarmtimer.node.expires);
+               ktime_to_timespec(timr->it.alarm.alarmtimer.node.expires);
        return;
 }
 
@@ -505,7 +503,7 @@ static int alarm_timer_del(struct k_itimer *timr)
        if (!rtcdev)
                return -ENOTSUPP;
 
-       alarm_cancel(&timr->it.alarmtimer);
+       alarm_cancel(&timr->it.alarm.alarmtimer);
        return 0;
 }
 
@@ -529,12 +527,12 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
                alarm_timer_get(timr, old_setting);
 
        /* If the timer was already set, cancel it */
-       alarm_cancel(&timr->it.alarmtimer);
+       alarm_cancel(&timr->it.alarm.alarmtimer);
 
        /* start the timer */
-       alarm_start(&timr->it.alarmtimer,
-                       timespec_to_ktime(new_setting->it_value),
-                       timespec_to_ktime(new_setting->it_interval));
+       timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval);
+       alarm_start(&timr->it.alarm.alarmtimer,
+                       timespec_to_ktime(new_setting->it_value));
        return 0;
 }
 
@@ -567,7 +565,7 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp)
        alarm->data = (void *)current;
        do {
                set_current_state(TASK_INTERRUPTIBLE);
-               alarm_start(alarm, absexp, ktime_set(0, 0));
+               alarm_start(alarm, absexp);
                if (likely(alarm->data))
                        schedule();