aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/alarmtimer.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index a522c007e6fd..90935591dd44 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -303,7 +303,6 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
303 enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) 303 enum alarmtimer_restart (*function)(struct alarm *, ktime_t))
304{ 304{
305 timerqueue_init(&alarm->node); 305 timerqueue_init(&alarm->node);
306 alarm->period = ktime_set(0, 0);
307 alarm->function = function; 306 alarm->function = function;
308 alarm->type = type; 307 alarm->type = type;
309 alarm->enabled = 0; 308 alarm->enabled = 0;
@@ -313,9 +312,8 @@ void alarm_init(struct alarm *alarm, enum alarmtimer_type type,
313 * alarm_start - Sets an alarm to fire 312 * alarm_start - Sets an alarm to fire
314 * @alarm: ptr to alarm to set 313 * @alarm: ptr to alarm to set
315 * @start: time to run the alarm 314 * @start: time to run the alarm
316 * @period: period at which the alarm will recur
317 */ 315 */
318void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period) 316void alarm_start(struct alarm *alarm, ktime_t start)
319{ 317{
320 struct alarm_base *base = &alarm_bases[alarm->type]; 318 struct alarm_base *base = &alarm_bases[alarm->type];
321 unsigned long flags; 319 unsigned long flags;
@@ -324,7 +322,6 @@ void alarm_start(struct alarm *alarm, ktime_t start, ktime_t period)
324 if (alarm->enabled) 322 if (alarm->enabled)
325 alarmtimer_remove(base, alarm); 323 alarmtimer_remove(base, alarm);
326 alarm->node.expires = start; 324 alarm->node.expires = start;
327 alarm->period = period;
328 alarmtimer_enqueue(base, alarm); 325 alarmtimer_enqueue(base, alarm);
329 alarm->enabled = 1; 326 alarm->enabled = 1;
330 spin_unlock_irqrestore(&base->lock, flags); 327 spin_unlock_irqrestore(&base->lock, flags);
@@ -405,13 +402,14 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
405 ktime_t now) 402 ktime_t now)
406{ 403{
407 struct k_itimer *ptr = container_of(alarm, struct k_itimer, 404 struct k_itimer *ptr = container_of(alarm, struct k_itimer,
408 it.alarmtimer); 405 it.alarm.alarmtimer);
409 if (posix_timer_event(ptr, 0) != 0) 406 if (posix_timer_event(ptr, 0) != 0)
410 ptr->it_overrun++; 407 ptr->it_overrun++;
411 408
412 /* Re-add periodic timers */ 409 /* Re-add periodic timers */
413 if (alarm->period.tv64) { 410 if (ptr->it.alarm.interval.tv64) {
414 ptr->it_overrun += alarm_forward(alarm, now, alarm->period); 411 ptr->it_overrun += alarm_forward(alarm, now,
412 ptr->it.alarm.interval);
415 return ALARMTIMER_RESTART; 413 return ALARMTIMER_RESTART;
416 } 414 }
417 return ALARMTIMER_NORESTART; 415 return ALARMTIMER_NORESTART;
@@ -471,7 +469,7 @@ static int alarm_timer_create(struct k_itimer *new_timer)
471 469
472 type = clock2alarm(new_timer->it_clock); 470 type = clock2alarm(new_timer->it_clock);
473 base = &alarm_bases[type]; 471 base = &alarm_bases[type];
474 alarm_init(&new_timer->it.alarmtimer, type, alarm_handle_timer); 472 alarm_init(&new_timer->it.alarm.alarmtimer, type, alarm_handle_timer);
475 return 0; 473 return 0;
476} 474}
477 475
@@ -488,9 +486,9 @@ static void alarm_timer_get(struct k_itimer *timr,
488 memset(cur_setting, 0, sizeof(struct itimerspec)); 486 memset(cur_setting, 0, sizeof(struct itimerspec));
489 487
490 cur_setting->it_interval = 488 cur_setting->it_interval =
491 ktime_to_timespec(timr->it.alarmtimer.period); 489 ktime_to_timespec(timr->it.alarm.interval);
492 cur_setting->it_value = 490 cur_setting->it_value =
493 ktime_to_timespec(timr->it.alarmtimer.node.expires); 491 ktime_to_timespec(timr->it.alarm.alarmtimer.node.expires);
494 return; 492 return;
495} 493}
496 494
@@ -505,7 +503,7 @@ static int alarm_timer_del(struct k_itimer *timr)
505 if (!rtcdev) 503 if (!rtcdev)
506 return -ENOTSUPP; 504 return -ENOTSUPP;
507 505
508 alarm_cancel(&timr->it.alarmtimer); 506 alarm_cancel(&timr->it.alarm.alarmtimer);
509 return 0; 507 return 0;
510} 508}
511 509
@@ -529,12 +527,12 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
529 alarm_timer_get(timr, old_setting); 527 alarm_timer_get(timr, old_setting);
530 528
531 /* If the timer was already set, cancel it */ 529 /* If the timer was already set, cancel it */
532 alarm_cancel(&timr->it.alarmtimer); 530 alarm_cancel(&timr->it.alarm.alarmtimer);
533 531
534 /* start the timer */ 532 /* start the timer */
535 alarm_start(&timr->it.alarmtimer, 533 timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval);
536 timespec_to_ktime(new_setting->it_value), 534 alarm_start(&timr->it.alarm.alarmtimer,
537 timespec_to_ktime(new_setting->it_interval)); 535 timespec_to_ktime(new_setting->it_value));
538 return 0; 536 return 0;
539} 537}
540 538
@@ -567,7 +565,7 @@ static int alarmtimer_do_nsleep(struct alarm *alarm, ktime_t absexp)
567 alarm->data = (void *)current; 565 alarm->data = (void *)current;
568 do { 566 do {
569 set_current_state(TASK_INTERRUPTIBLE); 567 set_current_state(TASK_INTERRUPTIBLE);
570 alarm_start(alarm, absexp, ktime_set(0, 0)); 568 alarm_start(alarm, absexp);
571 if (likely(alarm->data)) 569 if (likely(alarm->data))
572 schedule(); 570 schedule();
573 571