Commit 1d447cb6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Linus Torvalds

[PATCH] minor i386 timer changes for 2.5.41

Here's an additional patch that contains the cleanups I did to John's
timer patches.  It does the following:

	- uses C99 initializers
	- makes the timer list static
	- adds better documentation to the timer function structure
	- makes the timer init function return 0 on success
	- NULL terminates the list of timers to make further patches
	  easier.
parent 23288376
...@@ -2,31 +2,34 @@ ...@@ -2,31 +2,34 @@
#include <asm/timer.h> #include <asm/timer.h>
/* list of externed timers */ /* list of externed timers */
#ifndef CONFIG_X86_TSC
extern struct timer_opts timer_pit; extern struct timer_opts timer_pit;
#endif
extern struct timer_opts timer_tsc; extern struct timer_opts timer_tsc;
/* list of timers, ordered by preference */ /* list of timers, ordered by preference, NULL terminated */
struct timer_opts* timers[] = { static struct timer_opts* timers[] = {
&timer_tsc &timer_tsc,
#ifndef CONFIG_X86_TSC #ifndef CONFIG_X86_TSC
,&timer_pit &timer_pit,
#endif #endif
NULL,
}; };
#define NR_TIMERS (sizeof(timers)/sizeof(timers[0]))
/* iterates through the list of timers, returning the first /* iterates through the list of timers, returning the first
* one that initializes successfully. * one that initializes successfully.
*/ */
struct timer_opts* select_timer(void) struct timer_opts* select_timer(void)
{ {
int i; int i = 0;
/* find most preferred working timer */ /* find most preferred working timer */
for(i=0; i < NR_TIMERS; i++) while (timers[i]) {
if(timers[i]->init()) if (timers[i]->init)
if (timers[i]->init() == 0)
return timers[i]; return timers[i];
++i;
}
panic("select_timer: Cannot find a suitable timer\n"); panic("select_timer: Cannot find a suitable timer\n");
return 0; return NULL;
} }
...@@ -15,7 +15,7 @@ extern spinlock_t i8253_lock; ...@@ -15,7 +15,7 @@ extern spinlock_t i8253_lock;
static int init_pit(void) static int init_pit(void)
{ {
return 1; return 0;
} }
static void mark_offset_pit(void) static void mark_offset_pit(void)
...@@ -122,7 +122,7 @@ static unsigned long get_offset_pit(void) ...@@ -122,7 +122,7 @@ static unsigned long get_offset_pit(void)
/* tsc timer_opts struct */ /* tsc timer_opts struct */
struct timer_opts timer_pit = { struct timer_opts timer_pit = {
init: init_pit, .init = init_pit,
mark_offset: mark_offset_pit, .mark_offset = mark_offset_pit,
get_offset: get_offset_pit .get_offset = get_offset_pit,
}; };
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/timex.h> #include <linux/timex.h>
#include <linux/errno.h>
#include <asm/timer.h> #include <asm/timer.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -263,17 +264,17 @@ static int init_tsc(void) ...@@ -263,17 +264,17 @@ static int init_tsc(void)
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
cpufreq_register_notifier(&time_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); cpufreq_register_notifier(&time_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
#endif #endif
return 1; return 0;
} }
} }
return 0; return -ENODEV;
} }
/************************************************************/ /************************************************************/
/* tsc timer_opts struct */ /* tsc timer_opts struct */
struct timer_opts timer_tsc = { struct timer_opts timer_tsc = {
init: init_tsc, .init = init_tsc,
mark_offset: mark_offset_tsc, .mark_offset = mark_offset_tsc,
get_offset: get_offset_tsc .get_offset = get_offset_tsc,
}; };
#ifndef _ASMi386_TIMER_H #ifndef _ASMi386_TIMER_H
#define _ASMi386_TIMER_H #define _ASMi386_TIMER_H
/**
* struct timer_ops - used to define a timer source
*
* @init: Probes and initializes the timer. Returns 0 on success, anything
* else on failure.
* @mark_offset: called by the timer interrupt
* @get_offset: called by gettimeofday(). Returns the number of ms since the
* last timer intruupt.
*/
struct timer_opts{ struct timer_opts{
/* probes and initializes timer. returns 1 on sucess, 0 on failure */
int (*init)(void); int (*init)(void);
/* called by the timer interrupt */
void (*mark_offset)(void); void (*mark_offset)(void);
/* called by gettimeofday. returns # ms since the last timer interrupt */
unsigned long (*get_offset)(void); unsigned long (*get_offset)(void);
}; };
#define TICK_SIZE (tick_nsec / 1000) #define TICK_SIZE (tick_nsec / 1000)
struct timer_opts* select_timer(void);
extern struct timer_opts* select_timer(void);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment