Skip to content

Commit

Permalink
kernel: broadcast-hrtimer: Migrate to new 'set-state' interface
Browse files Browse the repository at this point in the history
Migrate broadcast-hrtimer driver to the new 'set-state' interface
provided by clockevents core, the earlier 'set-mode' interface is marked
obsolete now.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
  • Loading branch information
Viresh Kumar authored and Daniel Lezcano committed Aug 10, 2015
1 parent 8e40fc4 commit ecbebcb
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions kernel/time/tick-broadcast-hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,23 @@

static struct hrtimer bctimer;

static void bc_set_mode(enum clock_event_mode mode,
struct clock_event_device *bc)
static int bc_shutdown(struct clock_event_device *evt)
{
switch (mode) {
case CLOCK_EVT_MODE_UNUSED:
case CLOCK_EVT_MODE_SHUTDOWN:
/*
* Note, we cannot cancel the timer here as we might
* run into the following live lock scenario:
*
* cpu 0 cpu1
* lock(broadcast_lock);
* hrtimer_interrupt()
* bc_handler()
* tick_handle_oneshot_broadcast();
* lock(broadcast_lock);
* hrtimer_cancel()
* wait_for_callback()
*/
hrtimer_try_to_cancel(&bctimer);
break;
default:
break;
}
/*
* Note, we cannot cancel the timer here as we might
* run into the following live lock scenario:
*
* cpu 0 cpu1
* lock(broadcast_lock);
* hrtimer_interrupt()
* bc_handler()
* tick_handle_oneshot_broadcast();
* lock(broadcast_lock);
* hrtimer_cancel()
* wait_for_callback()
*/
hrtimer_try_to_cancel(&bctimer);
return 0;
}

/*
Expand Down Expand Up @@ -82,7 +75,7 @@ static int bc_set_next(ktime_t expires, struct clock_event_device *bc)
}

static struct clock_event_device ce_broadcast_hrtimer = {
.set_mode = bc_set_mode,
.set_state_shutdown = bc_shutdown,
.set_next_ktime = bc_set_next,
.features = CLOCK_EVT_FEAT_ONESHOT |
CLOCK_EVT_FEAT_KTIME |
Expand All @@ -102,13 +95,11 @@ static enum hrtimer_restart bc_handler(struct hrtimer *t)
{
ce_broadcast_hrtimer.event_handler(&ce_broadcast_hrtimer);

switch (ce_broadcast_hrtimer.mode) {
case CLOCK_EVT_MODE_ONESHOT:
if (clockevent_state_oneshot(&ce_broadcast_hrtimer))
if (ce_broadcast_hrtimer.next_event.tv64 != KTIME_MAX)
return HRTIMER_RESTART;
default:
return HRTIMER_NORESTART;
}

return HRTIMER_NORESTART;
}

void tick_setup_hrtimer_broadcast(void)
Expand Down

0 comments on commit ecbebcb

Please sign in to comment.