Make clock_events API more SOC friendly
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 <[email protected]>
---
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.
arch/i386/kernel/apic.c +2 -2
@@ -992,12 +992,12 @@ static void __setup_APIC_LVTT(unsigned iapic_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;
arch/i386/kernel/i8253.c +2 -2
@@ -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;
include/linux/clockchips.h +3 -3
@@ -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;
kernel/time/clockevents.c +5 -4
@@ -85,7 +85,7 @@ static irqreturn_t timer_interrupt(int iif (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);
Signature · 4 lines
Deepak Saxena - [email protected] - 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