public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH-rt] Make clock_events API more SOC friendly
@ 2006-06-07 19:31 Deepak Saxena
  0 siblings, 0 replies; only message in thread
From: Deepak Saxena @ 2006-06-07 19:31 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner
  Cc: dwalker, James Perkins, mlachwani, khilman, linux-kernel


SOCs often have multiple timers that behave the exact way, where
the only difference is the base address of the register bank. In
these cases, it would be nice to have a single function shared
across timers instead of one per timer. For this to work properly,
all clock_event function pointers need to take a priv pointer with
timer-specific context information.

Signed-off-by: Deepak Saxena <dsaxena@plexity.net>

---

Note: Not compile tested yet...just want to make sure this OK with
folks before I start implementing support on my ARM boards. X86 just
ignores the priv pointer.

Index: linux-2.6-rt/arch/i386/kernel/apic.c
===================================================================
--- linux-2.6-rt.orig/arch/i386/kernel/apic.c
+++ linux-2.6-rt/arch/i386/kernel/apic.c
@@ -992,12 +992,12 @@ static void __setup_APIC_LVTT(unsigned i
 		apic_write_around(APIC_TMICT, clocks/APIC_DIVISOR);
 }
 
-static void lapic_next_event(unsigned long evt)
+static void lapic_next_event(unsigned long evt, void *priv)
 {
 	apic_write_around(APIC_TMICT, evt);
 }
 
-static void lapic_timer_setup(int mode)
+static void lapic_timer_setup(int mode, void *priv)
 {
 	unsigned long flags;
 
Index: linux-2.6-rt/arch/i386/kernel/i8253.c
===================================================================
--- linux-2.6-rt.orig/arch/i386/kernel/i8253.c
+++ linux-2.6-rt/arch/i386/kernel/i8253.c
@@ -21,7 +21,7 @@
 DEFINE_RAW_SPINLOCK(i8253_lock);
 EXPORT_SYMBOL(i8253_lock);
 
-static void init_pit_timer(int mode)
+static void init_pit_timer(int mode, void *priv)
 {
 	unsigned long flags;
 
@@ -42,7 +42,7 @@ static void init_pit_timer(int mode)
 	spin_unlock_irqrestore(&i8253_lock, flags);
 }
 
-static void pit_next_event(unsigned long evt)
+static void pit_next_event(unsigned long evt, void *priv)
 {
 	unsigned long flags;
 
Index: linux-2.6-rt/include/linux/clockchips.h
===================================================================
--- linux-2.6-rt.orig/include/linux/clockchips.h
+++ linux-2.6-rt/include/linux/clockchips.h
@@ -79,11 +79,11 @@ struct clock_event {
 	unsigned long min_delta_ns;
 	u32 mult;
 	u32 shift;
-	void (*set_next_event)(unsigned long evt);
-	void (*set_mode)(int mode);
+	void (*set_next_event)(unsigned long evt, void *priv);
+	void (*set_mode)(int mode, void *priv);
 	int (*suspend)(void);
 	int (*resume)(void);
-	void (*event_handler)(struct pt_regs *regs);
+	void (*event_handler)(struct pt_regs *regs, void *priv);
 	void (*start_event)(void *priv);
 	void (*end_event)(void *priv);
 	unsigned int irq;
Index: linux-2.6-rt/kernel/time/clockevents.c
===================================================================
--- linux-2.6-rt.orig/kernel/time/clockevents.c
+++ linux-2.6-rt/kernel/time/clockevents.c
@@ -85,7 +85,7 @@ static irqreturn_t timer_interrupt(int i
 	if (evt->start_event)
 		evt->start_event(evt->priv);
 
-	evt->event_handler(regs);
+	evt->event_handler(regs, evt->priv);
 
 	if (evt->end_event)
 		evt->end_event(evt->priv);
@@ -345,7 +345,7 @@ static int setup_event(struct event_desc
 	descr->real_caps = caps;
 	descr->mode = CLOCK_EVT_STARTUP;
 	if (evt->set_mode)
-		evt->set_mode(CLOCK_EVT_STARTUP);
+		evt->set_mode(CLOCK_EVT_STARTUP, evt->priv);
 	printk(KERN_INFO "Event source %s installed with caps set: %02x\n",
 	       descr->event->name, descr->real_caps);
 
@@ -508,7 +508,8 @@ int clockevents_init_next_event(void)
 		return 0;
 
 	if (sources->nextevt->set_mode)
-		sources->nextevt->set_mode(CLOCK_EVT_ONESHOT);
+		sources->nextevt->set_mode(CLOCK_EVT_ONESHOT,
+					   sources->nextevt->priv);
 
 	return 1;
 }
@@ -533,7 +534,7 @@ int clockevents_set_next_event(ktime_t e
 	clc = clc >> sources->nextevt->shift;
 #endif
 
-	sources->nextevt->set_next_event(clc);
+	sources->nextevt->set_next_event(clc, sources->nextevt->priv);
 
 	hrtimer_trace(expires, clc);
 


-- 
Deepak Saxena - dsaxena@plexity.net - http://www.plexity.net

In the end, they will not say, "those were dark times,"  they will ask
"why were their poets silent?" - Bertold Brecht

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-07 19:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-07 19:31 [PATCH-rt] Make clock_events API more SOC friendly Deepak Saxena

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox