diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2013-04-25 16:31:45 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2013-05-16 05:09:15 -0400 |
| commit | f5a2e34375a5e2b711aea488ac3ae50eeba6d57c (patch) | |
| tree | 807d8e1ffb7c0b45a63e0dab7b0cb74d8bf52982 /kernel/time | |
| parent | 09ac369c825d9d593404306d59062d854b321e9b (diff) | |
clocksource: Allow clocksource select to skip current clocksource
Preparatory patch for clocksource unbind support.
Split out code from clocksource_select and modify it, so it skips the
current clocksource on request and tries to find a fallback
clocksource. Convert all existing users. No functional change.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130425143435.834965397@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/clocksource.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 1923a340bd91..9782997cb6cf 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
| @@ -553,7 +553,7 @@ static u64 clocksource_max_deferment(struct clocksource *cs) | |||
| 553 | 553 | ||
| 554 | #ifndef CONFIG_ARCH_USES_GETTIMEOFFSET | 554 | #ifndef CONFIG_ARCH_USES_GETTIMEOFFSET |
| 555 | 555 | ||
| 556 | static struct clocksource *clocksource_find_best(bool oneshot) | 556 | static struct clocksource *clocksource_find_best(bool oneshot, bool skipcur) |
| 557 | { | 557 | { |
| 558 | struct clocksource *cs; | 558 | struct clocksource *cs; |
| 559 | 559 | ||
| @@ -566,6 +566,8 @@ static struct clocksource *clocksource_find_best(bool oneshot) | |||
| 566 | * the best rating. | 566 | * the best rating. |
| 567 | */ | 567 | */ |
| 568 | list_for_each_entry(cs, &clocksource_list, list) { | 568 | list_for_each_entry(cs, &clocksource_list, list) { |
| 569 | if (skipcur && cs == curr_clocksource) | ||
| 570 | continue; | ||
| 569 | if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) | 571 | if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) |
| 570 | continue; | 572 | continue; |
| 571 | return cs; | 573 | return cs; |
| @@ -573,26 +575,20 @@ static struct clocksource *clocksource_find_best(bool oneshot) | |||
| 573 | return NULL; | 575 | return NULL; |
| 574 | } | 576 | } |
| 575 | 577 | ||
| 576 | /** | 578 | static void __clocksource_select(bool skipcur) |
| 577 | * clocksource_select - Select the best clocksource available | ||
| 578 | * | ||
| 579 | * Private function. Must hold clocksource_mutex when called. | ||
| 580 | * | ||
| 581 | * Select the clocksource with the best rating, or the clocksource, | ||
| 582 | * which is selected by userspace override. | ||
| 583 | */ | ||
| 584 | static void clocksource_select(void) | ||
| 585 | { | 579 | { |
| 586 | bool oneshot = tick_oneshot_mode_active(); | 580 | bool oneshot = tick_oneshot_mode_active(); |
| 587 | struct clocksource *best, *cs; | 581 | struct clocksource *best, *cs; |
| 588 | 582 | ||
| 589 | /* Find the best suitable clocksource */ | 583 | /* Find the best suitable clocksource */ |
| 590 | best = clocksource_find_best(oneshot); | 584 | best = clocksource_find_best(oneshot, skipcur); |
| 591 | if (!best) | 585 | if (!best) |
| 592 | return; | 586 | return; |
| 593 | 587 | ||
| 594 | /* Check for the override clocksource. */ | 588 | /* Check for the override clocksource. */ |
| 595 | list_for_each_entry(cs, &clocksource_list, list) { | 589 | list_for_each_entry(cs, &clocksource_list, list) { |
| 590 | if (skipcur && cs == curr_clocksource) | ||
| 591 | continue; | ||
| 596 | if (strcmp(cs->name, override_name) != 0) | 592 | if (strcmp(cs->name, override_name) != 0) |
| 597 | continue; | 593 | continue; |
| 598 | /* | 594 | /* |
| @@ -618,6 +614,19 @@ static void clocksource_select(void) | |||
| 618 | } | 614 | } |
| 619 | } | 615 | } |
| 620 | 616 | ||
| 617 | /** | ||
| 618 | * clocksource_select - Select the best clocksource available | ||
| 619 | * | ||
| 620 | * Private function. Must hold clocksource_mutex when called. | ||
| 621 | * | ||
| 622 | * Select the clocksource with the best rating, or the clocksource, | ||
| 623 | * which is selected by userspace override. | ||
| 624 | */ | ||
| 625 | static void clocksource_select(void) | ||
| 626 | { | ||
| 627 | return __clocksource_select(false); | ||
| 628 | } | ||
| 629 | |||
| 621 | #else /* !CONFIG_ARCH_USES_GETTIMEOFFSET */ | 630 | #else /* !CONFIG_ARCH_USES_GETTIMEOFFSET */ |
| 622 | 631 | ||
| 623 | static inline void clocksource_select(void) { } | 632 | static inline void clocksource_select(void) { } |
