HRTIMER_RESTART,
};
-/*
- * Timer states:
- */
-enum hrtimer_state {
- HRTIMER_INACTIVE, /* Timer is inactive */
- HRTIMER_PENDING, /* Timer is pending */
-};
+#define HRTIMER_INACTIVE ((void *)1UL)
struct hrtimer_base;
struct hrtimer {
struct rb_node node;
ktime_t expires;
- enum hrtimer_state state;
int (*function)(void *);
void *data;
struct hrtimer_base *base;
static inline int hrtimer_active(const struct hrtimer *timer)
{
- return timer->state == HRTIMER_PENDING;
+ return timer->node.rb_parent != HRTIMER_INACTIVE;
}
/* Forward a hrtimer so it expires after now: */
rb_link_node(&timer->node, parent, link);
rb_insert_color(&timer->node, &base->active);
- timer->state = HRTIMER_PENDING;
-
if (!base->first || timer->expires.tv64 <
rb_entry(base->first, struct hrtimer, node)->expires.tv64)
base->first = &timer->node;
if (base->first == &timer->node)
base->first = rb_next(&timer->node);
rb_erase(&timer->node, &base->active);
+ timer->node.rb_parent = HRTIMER_INACTIVE;
}
/*
{
if (hrtimer_active(timer)) {
__remove_hrtimer(timer, base);
- timer->state = HRTIMER_INACTIVE;
return 1;
}
return 0;
clock_id = CLOCK_MONOTONIC;
timer->base = &bases[clock_id];
+ timer->node.rb_parent = HRTIMER_INACTIVE;
}
/**
fn = timer->function;
data = timer->data;
set_curr_timer(base, timer);
- timer->state = HRTIMER_INACTIVE;
__remove_hrtimer(timer, base);
spin_unlock_irq(&base->lock);
spin_lock_irq(&base->lock);
- /* Another CPU has added back the timer */
- if (timer->state != HRTIMER_INACTIVE)
- continue;
-
- if (restart != HRTIMER_NORESTART)
+ if (restart != HRTIMER_NORESTART) {
+ BUG_ON(hrtimer_active(timer));
enqueue_hrtimer(timer, base);
+ }
}
set_curr_timer(base, NULL);
spin_unlock_irq(&base->lock);