Skip to contentSkip to conversation

pcspeaker driver update

PATCH In review Stas Sergeev 2 participants 5 messages Jun 14, 2005 – Jun 16, 2005 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 pcspeaker driver update

Hello.

The following patches is a small update to the pcspeaker driver.

Attached one is just a clean-up:
it removes the extern definitions for the i8253_lock and i8259A_lock, making the use of the appropriate headers instead.

Signed-off-by [email protected]
arch/i386/kernel/apic.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/kernel/apic.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/apic.c
@@ -34,6 +34,7 @@
 #include <asm/desc.h>
 #include <asm/arch_hooks.h>
 #include <asm/hpet.h>
+#include <asm/timer.h>
 
 #include <mach_apic.h>
 
@@ -857,7 +858,6 @@
  */
 static unsigned int __init get_8254_timer_count(void)
 {
-	extern spinlock_t i8253_lock;
 	unsigned long flags;
 
 	unsigned int count;
arch/i386/kernel/apm.c +1 -2
diff -urN linux-2.6.12-rc6/arch/i386/kernel/apm.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/apm.c
@@ -228,10 +228,10 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/desc.h>
+#include <asm/timer.h>
 
 #include "io_ports.h"
 
-extern spinlock_t i8253_lock;
 extern unsigned long get_cmos_time(void);
 extern void machine_real_restart(unsigned char *, int);
 
@@ -1169,7 +1169,6 @@
 {
 #ifdef INIT_TIMER_AFTER_SUSPEND
 	unsigned long	flags;
-	extern spinlock_t i8253_lock;
 
 	spin_lock_irqsave(&i8253_lock, flags);
 	/* set the clock to 100 Hz */
arch/i386/kernel/io_apic.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/kernel/io_apic.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/io_apic.c
@@ -37,6 +37,7 @@
 #include <asm/smp.h>
 #include <asm/desc.h>
 #include <asm/timer.h>
+#include <asm/i8259.h>
 
 #include <mach_apic.h>
 
@@ -1565,7 +1566,6 @@
 
 void /*__init*/ print_PIC(void)
 {
-	extern spinlock_t i8259A_lock;
 	unsigned int v;
 	unsigned long flags;
 
arch/i386/kernel/time.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/kernel/time.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/time.c
@@ -63,12 +63,12 @@
 #include <linux/config.h>
 
 #include <asm/hpet.h>
+#include <asm/i8259.h>
 
 #include <asm/arch_hooks.h>
 
 #include "io_ports.h"
 
-extern spinlock_t i8259A_lock;
 int pit_latch_buggy;              /* extern */
 
 #include "do_timer.h"
arch/i386/kernel/timers/timer_cyclone.c +1 -2
diff -urN linux-2.6.12-rc6/arch/i386/kernel/timers/timer_cyclone.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/timers/timer_cyclone.c
@@ -17,10 +17,9 @@
 #include <asm/io.h>
 #include <asm/pgtable.h>
 #include <asm/fixmap.h>
+#include <asm/timer.h>
 #include "io_ports.h"
 
-extern spinlock_t i8253_lock;
-
 /* Number of usecs that the last interrupt was delayed */
 static int delay_at_last_interrupt;
 
arch/i386/kernel/timers/timer_pit.c +2 -3
diff -urN linux-2.6.12-rc6/arch/i386/kernel/timers/timer_pit.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/timers/timer_pit.c
@@ -15,9 +15,9 @@
 #include <asm/smp.h>
 #include <asm/io.h>
 #include <asm/arch_hooks.h>
+#include <asm/timer.h>
+#include <asm/i8259.h>
 
-extern spinlock_t i8259A_lock;
-extern spinlock_t i8253_lock;
 #include "do_timer.h"
 #include "io_ports.h"
 
@@ -166,7 +172,6 @@
 
 void setup_pit_timer(void)
 {
-	extern spinlock_t i8253_lock;
 	unsigned long flags;
 
 	spin_lock_irqsave(&i8253_lock, flags);
arch/i386/kernel/timers/timer_tsc.c +1 -2
diff -urN linux-2.6.12-rc6/arch/i386/kernel/timers/timer_tsc.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/timers/timer_tsc.c
@@ -17,6 +17,7 @@
 
 #include <asm/timer.h>
 #include <asm/io.h>
+#include <asm/timer.h>
 /* processor.h for distable_tsc flag */
 #include <asm/processor.h>
 
@@ -35,8 +36,6 @@
 
 int tsc_disable __initdata = 0;
 
-extern spinlock_t i8253_lock;
-
 static int use_tsc;
 /* Number of usecs that the last interrupt was delayed */
 static int delay_at_last_interrupt;
arch/i386/mach-voyager/voyager_basic.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/mach-voyager/voyager_basic.c linux-2.6.12-rc6-spinlk/arch/i386/mach-voyager/voyager_basic.c
@@ -30,6 +30,7 @@
 #include <linux/irq.h>
 #include <asm/tlbflush.h>
 #include <asm/arch_hooks.h>
+#include <asm/timer.h>
 
 /*
  * Power off function, if any
@@ -182,7 +183,6 @@
 		 * and swiftly introduce it to something sharp and
 		 * pointy.  */
 		__u16 val;
-		extern spinlock_t i8253_lock;
 
 		spin_lock(&i8253_lock);
 		
drivers/ide/legacy/hd.c +1 -1
diff -urN linux-2.6.12-rc6/drivers/ide/legacy/hd.c linux-2.6.12-rc6-spinlk/drivers/ide/legacy/hd.c
@@ -41,6 +41,7 @@
 #include <linux/init.h>
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>
+#include <asm/timer.h>
 
 #define REALLY_SLOW_IO
 #include <asm/system.h>
@@ -160,7 +161,6 @@
 
 unsigned long read_timer(void)
 {
-        extern spinlock_t i8253_lock;
 	unsigned long t, flags;
 	int i;
 
drivers/input/gameport/gameport.c +1 -1
diff -urN linux-2.6.12-rc6/drivers/input/gameport/gameport.c linux-2.6.12-rc6-spinlk/drivers/input/gameport/gameport.c
@@ -22,6 +22,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
+#include <asm/timer.h>
 
 /*#include <asm/io.h>*/
 
@@ -66,7 +67,6 @@
 
 static unsigned int get_time_pit(void)
 {
-	extern spinlock_t i8253_lock;
 	unsigned long flags;
 	unsigned int count;
 
drivers/input/joystick/analog.c +1 -1
diff -urN linux-2.6.12-rc6/drivers/input/joystick/analog.c linux-2.6.12-rc6-spinlk/drivers/input/joystick/analog.c
@@ -39,6 +39,7 @@
 #include <linux/input.h>
 #include <linux/gameport.h>
 #include <asm/timex.h>
+#include <asm/timer.h>
 
 #define DRIVER_DESC	"Analog joystick and gamepad driver"
 
@@ -145,7 +146,6 @@
 #define TIME_NAME	(cpu_has_tsc?"TSC":"PIT")
 static unsigned int get_time_pit(void)
 {
-        extern spinlock_t i8253_lock;
         unsigned long flags;
         unsigned int count;
 
include/asm-i386/timer.h +2 -0
diff -urN linux-2.6.12-rc6/include/asm-i386/timer.h linux-2.6.12-rc6-spinlk/include/asm-i386/timer.h
@@ -1,6 +1,7 @@
 #ifndef _ASMi386_TIMER_H
 #define _ASMi386_TIMER_H
 #include <linux/init.h>
+#include <linux/spinlock.h>
 
 /**
  * struct timer_ops - used to define a timer source
@@ -41,6 +42,7 @@
 
 extern struct timer_opts *cur_timer;
 extern int timer_ack;
+extern spinlock_t i8253_lock;
 
 /* list of externed timers */
 extern struct timer_opts timer_none;
#1 lore raw
Quoted 6 lines · Stas Sergeev

Attached one is just a clean-up:
it removes the extern definitions
for the i8253_lock and i8259A_lock,
making the use of the appropriate
headers instead.

A nice cleanup to make, however we cannot include asm/timer.h from generic code, because only a few architectures have such a file.

#2 lore raw

Hello.

Quoted 7 lines · Andrew Morton
Quoted 5 lines

Attached one is just a clean-up:
it removes the extern definitions
for the i8253_lock and i8259A_lock,
making the use of the appropriate
headers instead.

A nice cleanup to make, however we cannot include asm/timer.h from generic code, because only a few architectures have such a file.

OK, what a bugger...
Does the attached one look any better?

Signed-off-by [email protected]
arch/i386/kernel/apic.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/kernel/apic.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/apic.c
@@ -34,6 +34,7 @@
 #include <asm/desc.h>
 #include <asm/arch_hooks.h>
 #include <asm/hpet.h>
+#include <asm/8253pit.h>
 
 #include <mach_apic.h>
 
@@ -857,7 +858,6 @@
  */
 static unsigned int __init get_8254_timer_count(void)
 {
-	extern spinlock_t i8253_lock;
 	unsigned long flags;
 
 	unsigned int count;
arch/i386/kernel/apm.c +1 -2
diff -urN linux-2.6.12-rc6/arch/i386/kernel/apm.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/apm.c
@@ -228,10 +228,10 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/desc.h>
+#include <asm/8253pit.h>
 
 #include "io_ports.h"
 
-extern spinlock_t i8253_lock;
 extern unsigned long get_cmos_time(void);
 extern void machine_real_restart(unsigned char *, int);
 
@@ -1169,7 +1169,6 @@
 {
 #ifdef INIT_TIMER_AFTER_SUSPEND
 	unsigned long	flags;
-	extern spinlock_t i8253_lock;
 
 	spin_lock_irqsave(&i8253_lock, flags);
 	/* set the clock to 100 Hz */
arch/i386/kernel/io_apic.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/kernel/io_apic.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/io_apic.c
@@ -37,6 +37,7 @@
 #include <asm/smp.h>
 #include <asm/desc.h>
 #include <asm/timer.h>
+#include <asm/i8259.h>
 
 #include <mach_apic.h>
 
@@ -1565,7 +1566,6 @@
 
 void /*__init*/ print_PIC(void)
 {
-	extern spinlock_t i8259A_lock;
 	unsigned int v;
 	unsigned long flags;
 
arch/i386/kernel/time.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/kernel/time.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/time.c
@@ -63,12 +63,12 @@
 #include <linux/config.h>
 
 #include <asm/hpet.h>
+#include <asm/i8259.h>
 
 #include <asm/arch_hooks.h>
 
 #include "io_ports.h"
 
-extern spinlock_t i8259A_lock;
 int pit_latch_buggy;              /* extern */
 
 #include "do_timer.h"
arch/i386/kernel/timers/timer_cyclone.c +1 -2
diff -urN linux-2.6.12-rc6/arch/i386/kernel/timers/timer_cyclone.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/timers/timer_cyclone.c
@@ -17,10 +17,9 @@
 #include <asm/io.h>
 #include <asm/pgtable.h>
 #include <asm/fixmap.h>
+#include <asm/8253pit.h>
 #include "io_ports.h"
 
-extern spinlock_t i8253_lock;
-
 /* Number of usecs that the last interrupt was delayed */
 static int delay_at_last_interrupt;
 
arch/i386/kernel/timers/timer_pit.c +2 -3
diff -urN linux-2.6.12-rc6/arch/i386/kernel/timers/timer_pit.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/timers/timer_pit.c
@@ -15,9 +15,9 @@
 #include <asm/smp.h>
 #include <asm/io.h>
 #include <asm/arch_hooks.h>
+#include <asm/8253pit.h>
+#include <asm/i8259.h>
 
-extern spinlock_t i8259A_lock;
-extern spinlock_t i8253_lock;
 #include "do_timer.h"
 #include "io_ports.h"
 
@@ -172,7 +172,6 @@
 
 void setup_pit_timer(void)
 {
-	extern spinlock_t i8253_lock;
 	unsigned long flags;
 
 	spin_lock_irqsave(&i8253_lock, flags);
arch/i386/kernel/timers/timer_tsc.c +1 -2
diff -urN linux-2.6.12-rc6/arch/i386/kernel/timers/timer_tsc.c linux-2.6.12-rc6-spinlk/arch/i386/kernel/timers/timer_tsc.c
@@ -17,6 +17,7 @@
 
 #include <asm/timer.h>
 #include <asm/io.h>
+#include <asm/8253pit.h>
 /* processor.h for distable_tsc flag */
 #include <asm/processor.h>
 
@@ -35,8 +36,6 @@
 
 int tsc_disable __initdata = 0;
 
-extern spinlock_t i8253_lock;
-
 static int use_tsc;
 /* Number of usecs that the last interrupt was delayed */
 static int delay_at_last_interrupt;
arch/i386/mach-voyager/voyager_basic.c +1 -1
diff -urN linux-2.6.12-rc6/arch/i386/mach-voyager/voyager_basic.c linux-2.6.12-rc6-spinlk/arch/i386/mach-voyager/voyager_basic.c
@@ -30,6 +30,7 @@
 #include <linux/irq.h>
 #include <asm/tlbflush.h>
 #include <asm/arch_hooks.h>
+#include <asm/8253pit.h>
 
 /*
  * Power off function, if any
@@ -182,7 +183,6 @@
 		 * and swiftly introduce it to something sharp and
 		 * pointy.  */
 		__u16 val;
-		extern spinlock_t i8253_lock;
 
 		spin_lock(&i8253_lock);
 		
drivers/ide/legacy/hd.c +1 -1
diff -urN linux-2.6.12-rc6/drivers/ide/legacy/hd.c linux-2.6.12-rc6-spinlk/drivers/ide/legacy/hd.c
@@ -41,6 +41,7 @@
 #include <linux/init.h>
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>
+#include <asm/8253pit.h>
 
 #define REALLY_SLOW_IO
 #include <asm/system.h>
@@ -160,7 +161,6 @@
 
 unsigned long read_timer(void)
 {
-        extern spinlock_t i8253_lock;
 	unsigned long t, flags;
 	int i;
 
drivers/input/gameport/gameport.c +1 -1
diff -urN linux-2.6.12-rc6/drivers/input/gameport/gameport.c linux-2.6.12-rc6-spinlk/drivers/input/gameport/gameport.c
@@ -22,6 +22,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
+#include <asm/8253pit.h>
 
 /*#include <asm/io.h>*/
 
@@ -66,7 +67,6 @@
 
 static unsigned int get_time_pit(void)
 {
-	extern spinlock_t i8253_lock;
 	unsigned long flags;
 	unsigned int count;
 
drivers/input/joystick/analog.c +1 -1
diff -urN linux-2.6.12-rc6/drivers/input/joystick/analog.c linux-2.6.12-rc6-spinlk/drivers/input/joystick/analog.c
@@ -39,6 +39,7 @@
 #include <linux/input.h>
 #include <linux/gameport.h>
 #include <asm/timex.h>
+#include <asm/8253pit.h>
 
 #define DRIVER_DESC	"Analog joystick and gamepad driver"
 
@@ -145,7 +146,6 @@
 #define TIME_NAME	(cpu_has_tsc?"TSC":"PIT")
 static unsigned int get_time_pit(void)
 {
-        extern spinlock_t i8253_lock;
         unsigned long flags;
         unsigned int count;
 
include/asm-i386/8253pit.h +2 -0
diff -urN linux-2.6.12-rc6/include/asm-i386/8253pit.h linux-2.6.12-rc6-spinlk/include/asm-i386/8253pit.h
@@ -5,8 +5,10 @@
 #ifndef _8253PIT_H
 #define _8253PIT_H
 
+#include <linux/spinlock.h>
 #include <asm/timex.h>
 
 #define PIT_TICK_RATE 	CLOCK_TICK_RATE
+extern spinlock_t i8253_lock;
 
 #endif
include/asm-alpha/8253pit.h +3 -0
diff -urN linux-2.6.12-rc6/include/asm-alpha/8253pit.h linux-2.6.12-rc6-spinlk/include/asm-alpha/8253pit.h
@@ -5,6 +5,9 @@
 #ifndef _8253PIT_H
 #define _8253PIT_H
 
+#include <linux/spinlock.h>
+
 #define PIT_TICK_RATE 	1193180UL
+extern spinlock_t i8253_lock;
 
 #endif
include/asm-ppc64/8253pit.h +3 -0
diff -urN linux-2.6.12-rc6/include/asm-ppc64/8253pit.h linux-2.6.12-rc6-spinlk/include/asm-ppc64/8253pit.h
@@ -5,6 +5,9 @@
 #ifndef _8253PIT_H
 #define _8253PIT_H
 
+#include <linux/spinlock.h>
+
 #define PIT_TICK_RATE 	1193182UL
+extern spinlock_t i8253_lock;
 
 #endif
include/asm-x86_64/8253pit.h +3 -0
diff -urN linux-2.6.12-rc6/include/asm-x86_64/8253pit.h linux-2.6.12-rc6-spinlk/include/asm-x86_64/8253pit.h
@@ -5,6 +5,9 @@
 #ifndef _8253PIT_H
 #define _8253PIT_H
 
+#include <linux/spinlock.h>
+
 #define PIT_TICK_RATE 	1193182UL
+extern spinlock_t i8253_lock;
 
 #endif
include/asm-ppc/8253pit.h +3 -0
diff -urN linux-2.6.12-rc6/include/asm-ppc/8253pit.h linux-2.6.12-rc6-spinlk/include/asm-ppc/8253pit.h
@@ -5,6 +5,9 @@
 #ifndef _8253PIT_H
 #define _8253PIT_H
 
+#include <linux/spinlock.h>
+
 #define PIT_TICK_RATE 	1193182UL
+extern spinlock_t i8253_lock;
 
 #endif
include/asm-mips/8253pit.h +3 -0
diff -urN linux-2.6.12-rc6/include/asm-mips/8253pit.h linux-2.6.12-rc6-spinlk/include/asm-mips/8253pit.h
@@ -5,6 +5,9 @@
 #ifndef _8253PIT_H
 #define _8253PIT_H
 
+#include <linux/spinlock.h>
+
 #define PIT_TICK_RATE 	1193182UL
+extern spinlock_t i8253_lock;
 
 #endif
#3 lore raw
Quoted 11 lines · Stas Sergeev
Quoted 7 lines · Andrew Morton
Quoted 5 lines

Attached one is just a clean-up:
it removes the extern definitions
for the i8253_lock and i8259A_lock,
making the use of the appropriate
headers instead.

A nice cleanup to make, however we cannot include asm/timer.h from generic code, because only a few architectures have such a file.

OK, what a bugger...
Does the attached one look any better?

Well not really - for example you now have drivers/input/joystick/analog.c including asm/8253pit.h, which not all architectures implement.

The basic problem is that we have generic code referring to an x86-specific lock inside `#ifdef __i386__'.

Perhaps what you could do is to declare those locks in include/asm-i386/hardirq.h and then make sure that all the relevant files include <linux/hardirq.h>. That's a bit of an abuse of hardirq.h, but we don't have a generic "platform.h" place to put things like this.

If abusing hardirq.h offends you then you could make sure that all architectures implement asm/rtc.h (most already do) (just copy include/asm-alpha/rtc.h) and put the declarations in include/asm-i386/rtc.h, which is more appropriate.

Whichever way you go, please check that x86_64 works OK too.

#4 lore raw

Hello.

Quoted 4 lines · Andrew Morton

Well not really - for example you now have drivers/input/joystick/analog.c including asm/8253pit.h, which not all architectures implement. The basic problem is that we have generic code referring to an x86-specific lock inside `#ifdef __i386__'.

In this case - what if I simply include
that <asm/8253pit.h> under the same
#ifdefs that are used for the spin-locks?
Or is it not recommended to #ifdef the
includes?