aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/hrtimer.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2008-09-01 18:02:30 -0400
committerArjan van de Ven <arjan@linux.intel.com>2008-09-06 00:35:13 -0400
commitcc584b213f252bf698849cf4be2377cd3ec7501a (patch)
tree621ba11da6a2ab8598f9ed453836cd2c44192260 /kernel/hrtimer.c
parent23dd7bb09bd8d7efd8a602aed97b93d52f85e675 (diff)
hrtimer: convert kernel/* to the new hrtimer apis
In order to be able to do range hrtimers we need to use accessor functions to the "expire" member of the hrtimer struct. This patch converts kernel/* to these accessors. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Diffstat (limited to 'kernel/hrtimer.c')
-rw-r--r--kernel/hrtimer.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 782137dc755f..ae307feec74c 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -517,7 +517,7 @@ static void hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base)
517 if (!base->first) 517 if (!base->first)
518 continue; 518 continue;
519 timer = rb_entry(base->first, struct hrtimer, node); 519 timer = rb_entry(base->first, struct hrtimer, node);
520 expires = ktime_sub(timer->expires, base->offset); 520 expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
521 if (expires.tv64 < cpu_base->expires_next.tv64) 521 if (expires.tv64 < cpu_base->expires_next.tv64)
522 cpu_base->expires_next = expires; 522 cpu_base->expires_next = expires;
523 } 523 }
@@ -539,10 +539,10 @@ static int hrtimer_reprogram(struct hrtimer *timer,
539 struct hrtimer_clock_base *base) 539 struct hrtimer_clock_base *base)
540{ 540{
541 ktime_t *expires_next = &__get_cpu_var(hrtimer_bases).expires_next; 541 ktime_t *expires_next = &__get_cpu_var(hrtimer_bases).expires_next;
542 ktime_t expires = ktime_sub(timer->expires, base->offset); 542 ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
543 int res; 543 int res;
544 544
545 WARN_ON_ONCE(timer->expires.tv64 < 0); 545 WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0);
546 546
547 /* 547 /*
548 * When the callback is running, we do not reprogram the clock event 548 * When the callback is running, we do not reprogram the clock event
@@ -794,7 +794,7 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
794 u64 orun = 1; 794 u64 orun = 1;
795 ktime_t delta; 795 ktime_t delta;
796 796
797 delta = ktime_sub(now, timer->expires); 797 delta = ktime_sub(now, hrtimer_get_expires(timer));
798 798
799 if (delta.tv64 < 0) 799 if (delta.tv64 < 0)
800 return 0; 800 return 0;
@@ -806,8 +806,8 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
806 s64 incr = ktime_to_ns(interval); 806 s64 incr = ktime_to_ns(interval);
807 807
808 orun = ktime_divns(delta, incr); 808 orun = ktime_divns(delta, incr);
809 timer->expires = ktime_add_ns(timer->expires, incr * orun); 809 hrtimer_add_expires_ns(timer, incr * orun);
810 if (timer->expires.tv64 > now.tv64) 810 if (hrtimer_get_expires_tv64(timer) > now.tv64)
811 return orun; 811 return orun;
812 /* 812 /*
813 * This (and the ktime_add() below) is the 813 * This (and the ktime_add() below) is the
@@ -815,7 +815,7 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
815 */ 815 */
816 orun++; 816 orun++;
817 } 817 }
818 timer->expires = ktime_add_safe(timer->expires, interval); 818 hrtimer_add_expires(timer, interval);
819 819
820 return orun; 820 return orun;
821} 821}
@@ -847,7 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
847 * We dont care about collisions. Nodes with 847 * We dont care about collisions. Nodes with
848 * the same expiry time stay together. 848 * the same expiry time stay together.
849 */ 849 */
850 if (timer->expires.tv64 < entry->expires.tv64) { 850 if (hrtimer_get_expires_tv64(timer) <
851 hrtimer_get_expires_tv64(entry)) {
851 link = &(*link)->rb_left; 852 link = &(*link)->rb_left;
852 } else { 853 } else {
853 link = &(*link)->rb_right; 854 link = &(*link)->rb_right;
@@ -982,7 +983,7 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
982#endif 983#endif
983 } 984 }
984 985
985 timer->expires = tim; 986 hrtimer_set_expires(timer, tim);
986 987
987 timer_stats_hrtimer_set_start_info(timer); 988 timer_stats_hrtimer_set_start_info(timer);
988 989
@@ -1076,7 +1077,7 @@ ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
1076 ktime_t rem; 1077 ktime_t rem;
1077 1078
1078 base = lock_hrtimer_base(timer, &flags); 1079 base = lock_hrtimer_base(timer, &flags);
1079 rem = ktime_sub(timer->expires, base->get_time()); 1080 rem = hrtimer_expires_remaining(timer);
1080 unlock_hrtimer_base(timer, &flags); 1081 unlock_hrtimer_base(timer, &flags);
1081 1082
1082 return rem; 1083 return rem;
@@ -1108,7 +1109,7 @@ ktime_t hrtimer_get_next_event(void)
1108 continue; 1109 continue;
1109 1110
1110 timer = rb_entry(base->first, struct hrtimer, node); 1111 timer = rb_entry(base->first, struct hrtimer, node);
1111 delta.tv64 = timer->expires.tv64; 1112 delta.tv64 = hrtimer_get_expires_tv64(timer);
1112 delta = ktime_sub(delta, base->get_time()); 1113 delta = ktime_sub(delta, base->get_time());
1113 if (delta.tv64 < mindelta.tv64) 1114 if (delta.tv64 < mindelta.tv64)
1114 mindelta.tv64 = delta.tv64; 1115 mindelta.tv64 = delta.tv64;
@@ -1308,10 +1309,10 @@ void hrtimer_interrupt(struct clock_event_device *dev)
1308 1309
1309 timer = rb_entry(node, struct hrtimer, node); 1310 timer = rb_entry(node, struct hrtimer, node);
1310 1311
1311 if (basenow.tv64 < timer->expires.tv64) { 1312 if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
1312 ktime_t expires; 1313 ktime_t expires;
1313 1314
1314 expires = ktime_sub(timer->expires, 1315 expires = ktime_sub(hrtimer_get_expires(timer),
1315 base->offset); 1316 base->offset);
1316 if (expires.tv64 < expires_next.tv64) 1317 if (expires.tv64 < expires_next.tv64)
1317 expires_next = expires; 1318 expires_next = expires;
@@ -1414,7 +1415,8 @@ void hrtimer_run_queues(void)
1414 struct hrtimer *timer; 1415 struct hrtimer *timer;
1415 1416
1416 timer = rb_entry(node, struct hrtimer, node); 1417 timer = rb_entry(node, struct hrtimer, node);
1417 if (base->softirq_time.tv64 <= timer->expires.tv64) 1418 if (base->softirq_time.tv64 <=
1419 hrtimer_get_expires_tv64(timer))
1418 break; 1420 break;
1419 1421
1420 if (timer->cb_mode == HRTIMER_CB_SOFTIRQ) { 1422 if (timer->cb_mode == HRTIMER_CB_SOFTIRQ) {
@@ -1462,7 +1464,7 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod
1462 1464
1463 do { 1465 do {
1464 set_current_state(TASK_INTERRUPTIBLE); 1466 set_current_state(TASK_INTERRUPTIBLE);
1465 hrtimer_start(&t->timer, t->timer.expires, mode); 1467 hrtimer_start_expires(&t->timer, mode);
1466 if (!hrtimer_active(&t->timer)) 1468 if (!hrtimer_active(&t->timer))
1467 t->task = NULL; 1469 t->task = NULL;
1468 1470
@@ -1484,7 +1486,7 @@ static int update_rmtp(struct hrtimer *timer, struct timespec __user *rmtp)
1484 struct timespec rmt; 1486 struct timespec rmt;
1485 ktime_t rem; 1487 ktime_t rem;
1486 1488
1487 rem = ktime_sub(timer->expires, timer->base->get_time()); 1489 rem = hrtimer_expires_remaining(timer);
1488 if (rem.tv64 <= 0) 1490 if (rem.tv64 <= 0)
1489 return 0; 1491 return 0;
1490 rmt = ktime_to_timespec(rem); 1492 rmt = ktime_to_timespec(rem);
@@ -1503,7 +1505,7 @@ long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
1503 1505
1504 hrtimer_init_on_stack(&t.timer, restart->nanosleep.index, 1506 hrtimer_init_on_stack(&t.timer, restart->nanosleep.index,
1505 HRTIMER_MODE_ABS); 1507 HRTIMER_MODE_ABS);
1506 t.timer.expires.tv64 = restart->nanosleep.expires; 1508 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires);
1507 1509
1508 if (do_nanosleep(&t, HRTIMER_MODE_ABS)) 1510 if (do_nanosleep(&t, HRTIMER_MODE_ABS))
1509 goto out; 1511 goto out;
@@ -1530,7 +1532,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
1530 int ret = 0; 1532 int ret = 0;
1531 1533
1532 hrtimer_init_on_stack(&t.timer, clockid, mode); 1534 hrtimer_init_on_stack(&t.timer, clockid, mode);
1533 t.timer.expires = timespec_to_ktime(*rqtp); 1535 hrtimer_set_expires(&t.timer, timespec_to_ktime(*rqtp));
1534 if (do_nanosleep(&t, mode)) 1536 if (do_nanosleep(&t, mode))
1535 goto out; 1537 goto out;
1536 1538
@@ -1550,7 +1552,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
1550 restart->fn = hrtimer_nanosleep_restart; 1552 restart->fn = hrtimer_nanosleep_restart;
1551 restart->nanosleep.index = t.timer.base->index; 1553 restart->nanosleep.index = t.timer.base->index;
1552 restart->nanosleep.rmtp = rmtp; 1554 restart->nanosleep.rmtp = rmtp;
1553 restart->nanosleep.expires = t.timer.expires.tv64; 1555 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer);
1554 1556
1555 ret = -ERESTART_RESTARTBLOCK; 1557 ret = -ERESTART_RESTARTBLOCK;
1556out: 1558out:
@@ -1724,11 +1726,11 @@ int __sched schedule_hrtimeout(ktime_t *expires,
1724 } 1726 }
1725 1727
1726 hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, mode); 1728 hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, mode);
1727 t.timer.expires = *expires; 1729 hrtimer_set_expires(&t.timer, *expires);
1728 1730
1729 hrtimer_init_sleeper(&t, current); 1731 hrtimer_init_sleeper(&t, current);
1730 1732
1731 hrtimer_start(&t.timer, t.timer.expires, mode); 1733 hrtimer_start_expires(&t.timer, mode);
1732 if (!hrtimer_active(&t.timer)) 1734 if (!hrtimer_active(&t.timer))
1733 t.task = NULL; 1735 t.task = NULL;
1734 1736