提交 7f9f303a 编写于 作者: J Jim Cromie 提交者: Linus Torvalds

[PATCH] generic-time: add macro to simplify/hide mask constants

Add a CLOCKSOURCE_MASK macro to simplify initializing the mask for a struct
clocksource, and use it to replace literal mask constants in the various
clocksource drivers.
Signed-off-by: NJim Cromie <jim.cromie@gmail.com>
Acked-by: NJohn Stultz <johnstul@us.ibm.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 7d622d47
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <asm/hpet.h> #include <asm/hpet.h>
#include <asm/io.h> #include <asm/io.h>
#define HPET_MASK 0xFFFFFFFF #define HPET_MASK CLOCKSOURCE_MASK(32)
#define HPET_SHIFT 22 #define HPET_SHIFT 22
/* FSEC = 10^-15 NSEC = 10^-9 */ /* FSEC = 10^-15 NSEC = 10^-9 */
...@@ -23,7 +23,7 @@ static struct clocksource clocksource_hpet = { ...@@ -23,7 +23,7 @@ static struct clocksource clocksource_hpet = {
.name = "hpet", .name = "hpet",
.rating = 250, .rating = 250,
.read = read_hpet, .read = read_hpet,
.mask = (cycle_t)HPET_MASK, .mask = HPET_MASK,
.mult = 0, /* set below */ .mult = 0, /* set below */
.shift = HPET_SHIFT, .shift = HPET_SHIFT,
.is_continuous = 1, .is_continuous = 1,
......
...@@ -69,7 +69,7 @@ static struct clocksource clocksource_pit = { ...@@ -69,7 +69,7 @@ static struct clocksource clocksource_pit = {
.name = "pit", .name = "pit",
.rating = 110, .rating = 110,
.read = pit_read, .read = pit_read,
.mask = (cycle_t)-1, .mask = CLOCKSOURCE_MASK(64),
.mult = 0, .mult = 0,
.shift = 20, .shift = 20,
}; };
......
...@@ -337,7 +337,7 @@ static struct clocksource clocksource_tsc = { ...@@ -337,7 +337,7 @@ static struct clocksource clocksource_tsc = {
.name = "tsc", .name = "tsc",
.rating = 300, .rating = 300,
.read = read_tsc, .read = read_tsc,
.mask = (cycle_t)-1, .mask = CLOCKSOURCE_MASK(64),
.mult = 0, /* to be set */ .mult = 0, /* to be set */
.shift = 22, .shift = 22,
.update_callback = tsc_update_callback, .update_callback = tsc_update_callback,
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
u32 pmtmr_ioport __read_mostly; u32 pmtmr_ioport __read_mostly;
#define ACPI_PM_MASK 0xFFFFFF /* limit it to 24 bits */ #define ACPI_PM_MASK CLOCKSOURCE_MASK(24) /* limit it to 24 bits */
static inline u32 read_pmtmr(void) static inline u32 read_pmtmr(void)
{ {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define CYCLONE_MPCS_OFFSET 0x51A8 /* offset to select register */ #define CYCLONE_MPCS_OFFSET 0x51A8 /* offset to select register */
#define CYCLONE_MPMC_OFFSET 0x51D0 /* offset to count register */ #define CYCLONE_MPMC_OFFSET 0x51D0 /* offset to count register */
#define CYCLONE_TIMER_FREQ 99780000 /* 100Mhz, but not really */ #define CYCLONE_TIMER_FREQ 99780000 /* 100Mhz, but not really */
#define CYCLONE_TIMER_MASK 0xFFFFFFFF /* 32 bit mask */ #define CYCLONE_TIMER_MASK CLOCKSOURCE_MASK(32) /* 32 bit mask */
int use_cyclone = 0; int use_cyclone = 0;
static void __iomem *cyclone_ptr; static void __iomem *cyclone_ptr;
...@@ -28,7 +28,7 @@ static struct clocksource clocksource_cyclone = { ...@@ -28,7 +28,7 @@ static struct clocksource clocksource_cyclone = {
.name = "cyclone", .name = "cyclone",
.rating = 250, .rating = 250,
.read = read_cyclone, .read = read_cyclone,
.mask = (cycle_t)CYCLONE_TIMER_MASK, .mask = CYCLONE_TIMER_MASK,
.mult = 10, .mult = 10,
.shift = 0, .shift = 0,
.is_continuous = 1, .is_continuous = 1,
......
...@@ -65,6 +65,8 @@ struct clocksource { ...@@ -65,6 +65,8 @@ struct clocksource {
u64 interval_snsecs; u64 interval_snsecs;
}; };
/* simplify initialization of mask field */
#define CLOCKSOURCE_MASK(bits) (cycle_t)(bits<64 ? ((1ULL<<bits)-1) : -1)
/** /**
* clocksource_khz2mult - calculates mult from khz and shift * clocksource_khz2mult - calculates mult from khz and shift
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册