diff options
author | Jaswinder Singh Rajput <jaswinderrajput@gmail.com> | 2009-03-21 07:26:10 -0400 |
---|---|---|
committer | Jaswinder Singh Rajput <jaswinderrajput@gmail.com> | 2009-03-21 07:26:10 -0400 |
commit | c8344bc218ce7ebc728337839698566a79edfe5a (patch) | |
tree | ba4138001984ce0b85d23670862672d9eae2e7c4 /arch/x86/kernel/i8253.c | |
parent | 390cd85c8ae4dc54ffba460a0e6575889170f56e (diff) |
x86: i8253 cleanup
Impact: cleanup
- fix various style problems
- fix header file issues
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Diffstat (limited to 'arch/x86/kernel/i8253.c')
-rw-r--r-- | arch/x86/kernel/i8253.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c index 10f92fb532f3..3475440baa54 100644 --- a/arch/x86/kernel/i8253.c +++ b/arch/x86/kernel/i8253.c | |||
@@ -3,17 +3,17 @@ | |||
3 | * | 3 | * |
4 | */ | 4 | */ |
5 | #include <linux/clockchips.h> | 5 | #include <linux/clockchips.h> |
6 | #include <linux/init.h> | ||
7 | #include <linux/interrupt.h> | 6 | #include <linux/interrupt.h> |
7 | #include <linux/spinlock.h> | ||
8 | #include <linux/jiffies.h> | 8 | #include <linux/jiffies.h> |
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
10 | #include <linux/spinlock.h> | 10 | #include <linux/delay.h> |
11 | #include <linux/init.h> | ||
12 | #include <linux/io.h> | ||
11 | 13 | ||
12 | #include <asm/smp.h> | ||
13 | #include <asm/delay.h> | ||
14 | #include <asm/i8253.h> | 14 | #include <asm/i8253.h> |
15 | #include <asm/io.h> | ||
16 | #include <asm/hpet.h> | 15 | #include <asm/hpet.h> |
16 | #include <asm/smp.h> | ||
17 | 17 | ||
18 | DEFINE_SPINLOCK(i8253_lock); | 18 | DEFINE_SPINLOCK(i8253_lock); |
19 | EXPORT_SYMBOL(i8253_lock); | 19 | EXPORT_SYMBOL(i8253_lock); |
@@ -40,7 +40,7 @@ static void init_pit_timer(enum clock_event_mode mode, | |||
40 | { | 40 | { |
41 | spin_lock(&i8253_lock); | 41 | spin_lock(&i8253_lock); |
42 | 42 | ||
43 | switch(mode) { | 43 | switch (mode) { |
44 | case CLOCK_EVT_MODE_PERIODIC: | 44 | case CLOCK_EVT_MODE_PERIODIC: |
45 | /* binary, mode 2, LSB/MSB, ch 0 */ | 45 | /* binary, mode 2, LSB/MSB, ch 0 */ |
46 | outb_pit(0x34, PIT_MODE); | 46 | outb_pit(0x34, PIT_MODE); |
@@ -95,7 +95,7 @@ static int pit_next_event(unsigned long delta, struct clock_event_device *evt) | |||
95 | * registered. This mechanism replaces the previous #ifdef LOCAL_APIC - | 95 | * registered. This mechanism replaces the previous #ifdef LOCAL_APIC - |
96 | * !using_apic_timer decisions in do_timer_interrupt_hook() | 96 | * !using_apic_timer decisions in do_timer_interrupt_hook() |
97 | */ | 97 | */ |
98 | static struct clock_event_device pit_clockevent = { | 98 | static struct clock_event_device pit_ce = { |
99 | .name = "pit", | 99 | .name = "pit", |
100 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, | 100 | .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, |
101 | .set_mode = init_pit_timer, | 101 | .set_mode = init_pit_timer, |
@@ -114,15 +114,13 @@ void __init setup_pit_timer(void) | |||
114 | * Start pit with the boot cpu mask and make it global after the | 114 | * Start pit with the boot cpu mask and make it global after the |
115 | * IO_APIC has been initialized. | 115 | * IO_APIC has been initialized. |
116 | */ | 116 | */ |
117 | pit_clockevent.cpumask = cpumask_of(smp_processor_id()); | 117 | pit_ce.cpumask = cpumask_of(smp_processor_id()); |
118 | pit_clockevent.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, | 118 | pit_ce.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, pit_ce.shift); |
119 | pit_clockevent.shift); | 119 | pit_ce.max_delta_ns = clockevent_delta2ns(0x7FFF, &pit_ce); |
120 | pit_clockevent.max_delta_ns = | 120 | pit_ce.min_delta_ns = clockevent_delta2ns(0xF, &pit_ce); |
121 | clockevent_delta2ns(0x7FFF, &pit_clockevent); | 121 | |
122 | pit_clockevent.min_delta_ns = | 122 | clockevents_register_device(&pit_ce); |
123 | clockevent_delta2ns(0xF, &pit_clockevent); | 123 | global_clock_event = &pit_ce; |
124 | clockevents_register_device(&pit_clockevent); | ||
125 | global_clock_event = &pit_clockevent; | ||
126 | } | 124 | } |
127 | 125 | ||
128 | #ifndef CONFIG_X86_64 | 126 | #ifndef CONFIG_X86_64 |
@@ -133,11 +131,11 @@ void __init setup_pit_timer(void) | |||
133 | */ | 131 | */ |
134 | static cycle_t pit_read(void) | 132 | static cycle_t pit_read(void) |
135 | { | 133 | { |
134 | static int old_count; | ||
135 | static u32 old_jifs; | ||
136 | unsigned long flags; | 136 | unsigned long flags; |
137 | int count; | 137 | int count; |
138 | u32 jifs; | 138 | u32 jifs; |
139 | static int old_count; | ||
140 | static u32 old_jifs; | ||
141 | 139 | ||
142 | spin_lock_irqsave(&i8253_lock, flags); | 140 | spin_lock_irqsave(&i8253_lock, flags); |
143 | /* | 141 | /* |
@@ -179,9 +177,9 @@ static cycle_t pit_read(void) | |||
179 | * Previous attempts to handle these cases intelligently were | 177 | * Previous attempts to handle these cases intelligently were |
180 | * buggy, so we just do the simple thing now. | 178 | * buggy, so we just do the simple thing now. |
181 | */ | 179 | */ |
182 | if (count > old_count && jifs == old_jifs) { | 180 | if (count > old_count && jifs == old_jifs) |
183 | count = old_count; | 181 | count = old_count; |
184 | } | 182 | |
185 | old_count = count; | 183 | old_count = count; |
186 | old_jifs = jifs; | 184 | old_jifs = jifs; |
187 | 185 | ||
@@ -192,13 +190,13 @@ static cycle_t pit_read(void) | |||
192 | return (cycle_t)(jifs * LATCH) + count; | 190 | return (cycle_t)(jifs * LATCH) + count; |
193 | } | 191 | } |
194 | 192 | ||
195 | static struct clocksource clocksource_pit = { | 193 | static struct clocksource pit_cs = { |
196 | .name = "pit", | 194 | .name = "pit", |
197 | .rating = 110, | 195 | .rating = 110, |
198 | .read = pit_read, | 196 | .read = pit_read, |
199 | .mask = CLOCKSOURCE_MASK(32), | 197 | .mask = CLOCKSOURCE_MASK(32), |
200 | .mult = 0, | 198 | .mult = 0, |
201 | .shift = 20, | 199 | .shift = 20, |
202 | }; | 200 | }; |
203 | 201 | ||
204 | static void pit_disable_clocksource(void) | 202 | static void pit_disable_clocksource(void) |
@@ -206,9 +204,9 @@ static void pit_disable_clocksource(void) | |||
206 | /* | 204 | /* |
207 | * Use mult to check whether it is registered or not | 205 | * Use mult to check whether it is registered or not |
208 | */ | 206 | */ |
209 | if (clocksource_pit.mult) { | 207 | if (pit_cs.mult) { |
210 | clocksource_unregister(&clocksource_pit); | 208 | clocksource_unregister(&pit_cs); |
211 | clocksource_pit.mult = 0; | 209 | pit_cs.mult = 0; |
212 | } | 210 | } |
213 | } | 211 | } |
214 | 212 | ||
@@ -222,13 +220,13 @@ static int __init init_pit_clocksource(void) | |||
222 | * - when local APIC timer is active (PIT is switched off) | 220 | * - when local APIC timer is active (PIT is switched off) |
223 | */ | 221 | */ |
224 | if (num_possible_cpus() > 1 || is_hpet_enabled() || | 222 | if (num_possible_cpus() > 1 || is_hpet_enabled() || |
225 | pit_clockevent.mode != CLOCK_EVT_MODE_PERIODIC) | 223 | pit_ce.mode != CLOCK_EVT_MODE_PERIODIC) |
226 | return 0; | 224 | return 0; |
227 | 225 | ||
228 | clocksource_pit.mult = clocksource_hz2mult(CLOCK_TICK_RATE, | 226 | pit_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, pit_cs.shift); |
229 | clocksource_pit.shift); | 227 | |
230 | return clocksource_register(&clocksource_pit); | 228 | return clocksource_register(&pit_cs); |
231 | } | 229 | } |
232 | arch_initcall(init_pit_clocksource); | 230 | arch_initcall(init_pit_clocksource); |
233 | 231 | ||
234 | #endif | 232 | #endif /* !CONFIG_X86_64 */ |