Skip to content

Commit 73b08d2

Browse files
KAGA-KOKOLinus Torvalds
authored andcommitted
[PATCH] clocksource: replace is_continuous by a flag field
Using a flag filed allows to encode more than one information into a variable. Preparatory patch for the generic clocksource verification. [mingo@elte.hu: convert vmitime.c to the new clocksource flag] Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: john stultz <johnstul@us.ibm.com> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 95492e4 commit 73b08d2

9 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎arch/i386/kernel/hpet.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static struct clocksource clocksource_hpet = {
2626
.mask = HPET_MASK,
2727
.mult = 0, /* set below */
2828
.shift = HPET_SHIFT,
29-
.is_continuous = 1,
29+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
3030
};
3131

3232
static int __init init_hpet_clocksource(void)

‎arch/i386/kernel/tsc.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ static struct clocksource clocksource_tsc = {
314314
.mult = 0, /* to be set */
315315
.shift = 22,
316316
.update_callback = tsc_update_callback,
317-
.is_continuous = 1,
317+
.flags = CLOCK_SOURCE_IS_CONTINUOUS |
318+
CLOCK_SOURCE_MUST_VERIFY,
318319
};
319320

320321
static int tsc_update_callback(void)
@@ -434,8 +435,10 @@ static int __init init_tsc_clocksource(void)
434435
clocksource_tsc.mult = clocksource_khz2mult(current_tsc_khz,
435436
clocksource_tsc.shift);
436437
/* lower the rating if we already know its unstable: */
437-
if (check_tsc_unstable())
438+
if (check_tsc_unstable()) {
438439
clocksource_tsc.rating = 0;
440+
clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
441+
}
439442

440443
init_timer(&verify_tsc_freq_timer);
441444
verify_tsc_freq_timer.function = verify_tsc_freq;

‎arch/i386/kernel/vmitime.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static struct clocksource clocksource_vmi = {
115115
.mask = CLOCKSOURCE_MASK(64),
116116
.mult = 0, /* to be set */
117117
.shift = 22,
118-
.is_continuous = 1,
118+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
119119
};
120120

121121

‎drivers/clocksource/acpi_pm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ static struct clocksource clocksource_acpi_pm = {
7272
.mask = (cycle_t)ACPI_PM_MASK,
7373
.mult = 0, /*to be caluclated*/
7474
.shift = 22,
75-
.is_continuous = 1,
75+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
76+
7677
};
7778

7879

‎drivers/clocksource/cyclone.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static struct clocksource clocksource_cyclone = {
3131
.mask = CYCLONE_TIMER_MASK,
3232
.mult = 10,
3333
.shift = 0,
34-
.is_continuous = 1,
34+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
3535
};
3636

3737
static int __init init_cyclone_clocksource(void)

‎drivers/clocksource/scx200_hrt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static struct clocksource cs_hrt = {
5757
.rating = 250,
5858
.read = read_hrt,
5959
.mask = CLOCKSOURCE_MASK(32),
60-
.is_continuous = 1,
60+
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
6161
/* mult, shift are set based on mhz27 flag */
6262
};
6363

‎include/linux/clocksource.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ typedef u64 cycle_t;
4545
* @mult: cycle to nanosecond multiplier
4646
* @shift: cycle to nanosecond divisor (power of two)
4747
* @update_callback: called when safe to alter clocksource values
48-
* @is_continuous: defines if clocksource is free-running.
48+
* @flags: flags describing special properties
4949
* @cycle_interval: Used internally by timekeeping core, please ignore.
5050
* @xtime_interval: Used internally by timekeeping core, please ignore.
5151
*/
@@ -58,14 +58,20 @@ struct clocksource {
5858
u32 mult;
5959
u32 shift;
6060
int (*update_callback)(void);
61-
int is_continuous;
61+
unsigned long flags;
6262

6363
/* timekeeping specific data, ignore */
6464
cycle_t cycle_last, cycle_interval;
6565
u64 xtime_nsec, xtime_interval;
6666
s64 error;
6767
};
6868

69+
/*
70+
* Clock source flags bits::
71+
*/
72+
#define CLOCK_SOURCE_IS_CONTINUOUS 0x01
73+
#define CLOCK_SOURCE_MUST_VERIFY 0x02
74+
6975
/* simplify initialization of mask field */
7076
#define CLOCKSOURCE_MASK(bits) (cycle_t)(bits<64 ? ((1ULL<<bits)-1) : -1)
7177

‎kernel/time/jiffies.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct clocksource clocksource_jiffies = {
6262
.mask = 0xffffffff, /*32bits*/
6363
.mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */
6464
.shift = JIFFIES_SHIFT,
65-
.is_continuous = 0, /* tick based, not free running */
6665
};
6766

6867
static int __init init_jiffies_clocksource(void)

‎kernel/timer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ int timekeeping_is_continuous(void)
871871
do {
872872
seq = read_seqbegin(&xtime_lock);
873873

874-
ret = clock->is_continuous;
874+
ret = clock->flags & CLOCK_SOURCE_IS_CONTINUOUS;
875875

876876
} while (read_seqretry(&xtime_lock, seq));
877877

0 commit comments

Comments
 (0)