From: Andrew Morton Currently register_clocksource() is a bit unconventional in that it's currently void, which has to be a first for kernel register_xxx() routines. Additionally, register_clocksource() _can_ fail, and essentially every caller of it has an int return type anyways, so it doesn't make much sense to lie about it. The other issue is that the clocksource documentation is wrong, the example won't compile, defines everything as non-static, and the initcall is never flagged as __init. Also fixes a "teh" typo in a comment. Signed-off-by: Paul Mundt Signed-off-by: John Stultz Signed-off-by: Andrew Morton --- Documentation/timekeeping.txt | 25 +++++++++++-------------- include/linux/time.h | 2 +- kernel/time/clocksource.c | 1 - kernel/time/timeofday.c | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff -puN Documentation/timekeeping.txt~time-generic-timekeeping-infrastructure-fix-crs Documentation/timekeeping.txt --- devel/Documentation/timekeeping.txt~time-generic-timekeeping-infrastructure-fix-crs 2006-02-04 17:26:37.000000000 -0800 +++ devel-akpm/Documentation/timekeeping.txt 2006-02-04 17:26:37.000000000 -0800 @@ -304,31 +304,28 @@ So lets start out an empty cool-counter. #define COOL_READ_PTR 0xFEEDF000 #define COOL_START_PTR 0xFEEDF0F0 -static __iomem *cool_ptr = COOL_READ_PTR; +static __iomem void *cool_ptr = (void*)COOL_READ_PTR; -struct clocksource clocksource_cool -{ +static struct clocksource clocksource_cool = { .name = "cool", .rating = 200, /* its a pretty decent clock */ .mask = 0xFFFFFFFF, /* 32 bits */ - .mult = 0, /*to be computed */ + .mult = 0, /*to be computed */ .shift = 10, -} - +}; -Now let's write the read function: +/* Now let's create the read function: */ -cycle_t cool_counter_read(void) +static cycle_t cool_counter_read(void) { - cycle_t ret = readl(cool_ptr); - return ret; + return (cycle_t)readl(cool_ptr); } -Finally, lets write the init function: +/* Finally, lets create the init function: */ -void cool_counter_init(void) +static int __init cool_counter_init(void) { - __iomem *ptr = COOL_START_PTR; + __iomem void *ptr = (void*)COOL_START_PTR; u32 val; /* start the counter */ @@ -342,7 +339,7 @@ void cool_counter_init(void) clocksource_cool.shift); /* register the clocksource */ - register_clocksource(&clocksource_cool); + return register_clocksource(&clocksource_cool); } module_init(cool_counter_init); diff -puN include/linux/time.h~time-generic-timekeeping-infrastructure-fix-crs include/linux/time.h --- devel/include/linux/time.h~time-generic-timekeeping-infrastructure-fix-crs 2006-02-04 17:26:37.000000000 -0800 +++ devel-akpm/include/linux/time.h 2006-02-04 17:26:37.000000000 -0800 @@ -28,7 +28,7 @@ struct timezone { #ifdef __KERNEL__ /* timeofday base types */ -typedef s64 nsec_t; +typedef s64 nsec_t; /* Large enough for 292+ years */ typedef u64 cycle_t; /* Parameters used to convert the timespec values: */ diff -puN kernel/time/clocksource.c~time-generic-timekeeping-infrastructure-fix-crs kernel/time/clocksource.c --- devel/kernel/time/clocksource.c~time-generic-timekeeping-infrastructure-fix-crs 2006-02-04 17:26:37.000000000 -0800 +++ devel-akpm/kernel/time/clocksource.c 2006-02-04 17:29:06.000000000 -0800 @@ -155,7 +155,6 @@ int register_clocksource(struct clocksou spin_unlock_irqrestore(&clocksource_lock, flags); return ret; } - EXPORT_SYMBOL(register_clocksource); /** diff -puN kernel/time/timeofday.c~time-generic-timekeeping-infrastructure-fix-crs kernel/time/timeofday.c --- devel/kernel/time/timeofday.c~time-generic-timekeeping-infrastructure-fix-crs 2006-02-04 17:26:37.000000000 -0800 +++ devel-akpm/kernel/time/timeofday.c 2006-02-04 17:26:37.000000000 -0800 @@ -50,7 +50,7 @@ static ktime_t system_time; static ktime_t wall_time_offset; /* [timespec based variables] - * These variables mirror teh ktime_t based variables to avoid + * These variables mirror the ktime_t based variables to avoid * performance issues in the userspace syscall paths. * * wall_time_ts: _