Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143793
b: refs/heads/master
c: 4614e6a
h: refs/heads/master
i:
  143791: 1b22d07
v: v3
  • Loading branch information
Magnus Damm authored and Linus Torvalds committed Apr 21, 2009
1 parent f2707c4 commit 5d2ffbd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8e19608e8b5c001e4a66ce482edc474f05fb7355
refs/heads/master: 4614e6adafa2c5e6c3a9c245af2807fa7bc5117a
31 changes: 31 additions & 0 deletions trunk/include/linux/clocksource.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ extern u64 timecounter_cyc2time(struct timecounter *tc,
* The ideal clocksource. A must-use where
* available.
* @read: returns a cycle value, passes clocksource as argument
* @enable: optional function to enable the clocksource
* @disable: optional function to disable the clocksource
* @mask: bitmask for two's complement
* subtraction of non 64 bit counters
* @mult: cycle to nanosecond multiplier (adjusted by NTP)
Expand All @@ -163,6 +165,8 @@ struct clocksource {
struct list_head list;
int rating;
cycle_t (*read)(struct clocksource *cs);
int (*enable)(struct clocksource *cs);
void (*disable)(struct clocksource *cs);
cycle_t mask;
u32 mult;
u32 mult_orig;
Expand Down Expand Up @@ -274,6 +278,33 @@ static inline cycle_t clocksource_read(struct clocksource *cs)
return cs->read(cs);
}

/**
* clocksource_enable: - enable clocksource
* @cs: pointer to clocksource
*
* Enables the specified clocksource. The clocksource callback
* function should start up the hardware and setup mult and field
* members of struct clocksource to reflect hardware capabilities.
*/
static inline int clocksource_enable(struct clocksource *cs)
{
return cs->enable ? cs->enable(cs) : 0;
}

/**
* clocksource_disable: - disable clocksource
* @cs: pointer to clocksource
*
* Disables the specified clocksource. The clocksource callback
* function should power down the now unused hardware block to
* save power.
*/
static inline void clocksource_disable(struct clocksource *cs)
{
if (cs->disable)
cs->disable(cs);
}

/**
* cyc2ns - converts clocksource cycles to nanoseconds
* @cs: Pointer to clocksource
Expand Down
12 changes: 9 additions & 3 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ EXPORT_SYMBOL(do_settimeofday);
*/
static void change_clocksource(void)
{
struct clocksource *new;
struct clocksource *new, *old;

new = clocksource_get_next();

Expand All @@ -191,11 +191,16 @@ static void change_clocksource(void)

clocksource_forward_now();

new->raw_time = clock->raw_time;
if (clocksource_enable(new))
return;

new->raw_time = clock->raw_time;
old = clock;
clock = new;
clocksource_disable(old);

clock->cycle_last = 0;
clock->cycle_last = clocksource_read(new);
clock->cycle_last = clocksource_read(clock);
clock->error = 0;
clock->xtime_nsec = 0;
clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
Expand Down Expand Up @@ -292,6 +297,7 @@ void __init timekeeping_init(void)
ntp_init();

clock = clocksource_get_next();
clocksource_enable(clock);
clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
clock->cycle_last = clocksource_read(clock);

Expand Down

0 comments on commit 5d2ffbd

Please sign in to comment.