diff options
| author | John Stultz <johnstul@us.ibm.com> | 2010-07-13 20:56:28 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2010-07-27 06:40:55 -0400 |
| commit | 852db46d55e85b475a72e665ca08d3317769ceef (patch) | |
| tree | 3802273b1135f0f650868fe9e048d7c0594195fe /kernel/time | |
| parent | f12a15be63d1de9a35971f35f06b73088fa25c3a (diff) | |
clocksource: Add __clocksource_updatefreq_hz/khz methods
To properly handle clocksources that change frequencies
at the clocksource->enable() point, this patch adds
a method that will update the clocksource's mult/shift and
max_idle_ns values.
Signed-off-by: John Stultz <johnstul@us.ibm.com>
LKML-Reference: <1279068988-21864-12-git-send-email-johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/clocksource.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index c543d21b4e54..c18d7efa1b4b 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
| @@ -639,19 +639,18 @@ static void clocksource_enqueue(struct clocksource *cs) | |||
| 639 | #define MAX_UPDATE_LENGTH 5 /* Seconds */ | 639 | #define MAX_UPDATE_LENGTH 5 /* Seconds */ |
| 640 | 640 | ||
| 641 | /** | 641 | /** |
| 642 | * __clocksource_register_scale - Used to install new clocksources | 642 | * __clocksource_updatefreq_scale - Used update clocksource with new freq |
| 643 | * @t: clocksource to be registered | 643 | * @t: clocksource to be registered |
| 644 | * @scale: Scale factor multiplied against freq to get clocksource hz | 644 | * @scale: Scale factor multiplied against freq to get clocksource hz |
| 645 | * @freq: clocksource frequency (cycles per second) divided by scale | 645 | * @freq: clocksource frequency (cycles per second) divided by scale |
| 646 | * | 646 | * |
| 647 | * Returns -EBUSY if registration fails, zero otherwise. | 647 | * This should only be called from the clocksource->enable() method. |
| 648 | * | 648 | * |
| 649 | * This *SHOULD NOT* be called directly! Please use the | 649 | * This *SHOULD NOT* be called directly! Please use the |
| 650 | * clocksource_register_hz() or clocksource_register_khz helper functions. | 650 | * clocksource_updatefreq_hz() or clocksource_updatefreq_khz helper functions. |
| 651 | */ | 651 | */ |
| 652 | int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) | 652 | void __clocksource_updatefreq_scale(struct clocksource *cs, u32 scale, u32 freq) |
| 653 | { | 653 | { |
| 654 | |||
| 655 | /* | 654 | /* |
| 656 | * Ideally we want to use some of the limits used in | 655 | * Ideally we want to use some of the limits used in |
| 657 | * clocksource_max_deferment, to provide a more informed | 656 | * clocksource_max_deferment, to provide a more informed |
| @@ -662,7 +661,27 @@ int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) | |||
| 662 | NSEC_PER_SEC/scale, | 661 | NSEC_PER_SEC/scale, |
| 663 | MAX_UPDATE_LENGTH*scale); | 662 | MAX_UPDATE_LENGTH*scale); |
| 664 | cs->max_idle_ns = clocksource_max_deferment(cs); | 663 | cs->max_idle_ns = clocksource_max_deferment(cs); |
| 664 | } | ||
| 665 | EXPORT_SYMBOL_GPL(__clocksource_updatefreq_scale); | ||
| 666 | |||
| 667 | /** | ||
| 668 | * __clocksource_register_scale - Used to install new clocksources | ||
| 669 | * @t: clocksource to be registered | ||
| 670 | * @scale: Scale factor multiplied against freq to get clocksource hz | ||
| 671 | * @freq: clocksource frequency (cycles per second) divided by scale | ||
| 672 | * | ||
| 673 | * Returns -EBUSY if registration fails, zero otherwise. | ||
| 674 | * | ||
| 675 | * This *SHOULD NOT* be called directly! Please use the | ||
| 676 | * clocksource_register_hz() or clocksource_register_khz helper functions. | ||
| 677 | */ | ||
| 678 | int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) | ||
| 679 | { | ||
| 680 | |||
| 681 | /* Intialize mult/shift and max_idle_ns */ | ||
| 682 | __clocksource_updatefreq_scale(cs, scale, freq); | ||
| 665 | 683 | ||
| 684 | /* Add clocksource to the clcoksource list */ | ||
| 666 | mutex_lock(&clocksource_mutex); | 685 | mutex_lock(&clocksource_mutex); |
| 667 | clocksource_enqueue(cs); | 686 | clocksource_enqueue(cs); |
| 668 | clocksource_select(); | 687 | clocksource_select(); |
