# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.992   -> 1.995  
#	  sound/oss/ad1848.c	1.16    -> 1.19   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/02/11	mulix@alhambra.mulix.org	1.993
# remove the per adapter spinlock and use a static shared spinlock shared between all adapters
# --------------------------------------------
# 03/02/11	mulix@alhambra.mulix.org	1.994
# no need to initialize the lock again in ad1848_init
# --------------------------------------------
# 03/02/11	mulix@alhambra.mulix.org	1.995
# remove extraneous semicolon. 
# --------------------------------------------
#
diff -Nru a/sound/oss/ad1848.c b/sound/oss/ad1848.c
--- a/sound/oss/ad1848.c	Tue Feb 11 16:08:43 2003
+++ b/sound/oss/ad1848.c	Tue Feb 11 16:08:43 2003
@@ -60,7 +60,6 @@
 
 typedef struct
 {
-	spinlock_t	lock;
 	int             base;
 	int             irq;
 	int             dma1, dma2;
@@ -120,6 +119,7 @@
 }
 ad1848_port_info;
 
+static spinlock_t ad1848_lock = SPIN_LOCK_UNLOCKED;
 static struct address_info cfg;
 static int nr_ad1848_devs;
 
@@ -216,7 +216,7 @@
 	while (timeout > 0 && inb(devc->base) == 0x80)	/*Are we initializing */
 		timeout--;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	
 	if(reg < 32)
 	{
@@ -233,7 +233,7 @@
 		outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc));
 		x = inb(io_Indexed_Data(devc));
 	}
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 
 	return x;
 }
@@ -246,7 +246,7 @@
 	while (timeout > 0 && inb(devc->base) == 0x80)	/* Are we initializing */
 		timeout--;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	
 	if(reg < 32)
 	{
@@ -263,7 +263,7 @@
 		outb(((unsigned char) (xra & 0xff)), io_Indexed_Data(devc));
 		outb((unsigned char) (data & 0xff), io_Indexed_Data(devc));
 	}
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void wait_for_calibration(ad1848_info * devc)
@@ -326,17 +326,17 @@
 	while (timeout > 0 && inb(devc->base) == 0x80)	/*Are we initializing */
 		timeout--;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	devc->MCE_bit = 0x40;
 	prev = inb(io_Index_Addr(devc));
 	if (prev & 0x40)
 	{
-		spin_unlock_irqrestore(&devc->lock,flags);
+		spin_unlock_irqrestore(&ad1848_lock,flags);
 		return;
 	}
 	outb((devc->MCE_bit), io_Index_Addr(devc));
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad_leave_MCE(ad1848_info * devc)
@@ -348,7 +348,7 @@
 	while (timeout > 0 && inb(devc->base) == 0x80)	/*Are we initializing */
 		timeout--;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	acal = ad_read(devc, 9);
 
@@ -358,13 +358,13 @@
 
 	if ((prev & 0x40) == 0)	/* Not in MCE mode */
 	{
-		spin_unlock_irqrestore(&devc->lock,flags);
+		spin_unlock_irqrestore(&ad1848_lock,flags);
 		return;
 	}
 	outb((0x00), io_Index_Addr(devc));	/* Clear the MCE bit */
 	if (acal & 0x08)	/* Auto calibration is enabled */
 		wait_for_calibration(devc);
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static int ad1848_set_recmask(ad1848_info * devc, int mask)
@@ -985,10 +985,10 @@
 	devc = (ad1848_info *) audio_devs[dev]->devc;
 	portc = (ad1848_port_info *) audio_devs[dev]->portc;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	if (portc->open_mode || (devc->open_mode & mode))
 	{
-		spin_unlock_irqrestore(&devc->lock,flags);
+		spin_unlock_irqrestore(&ad1848_lock,flags);
 		return -EBUSY;
 	}
 	devc->dual_dma = 0;
@@ -1007,7 +1007,7 @@
 		devc->record_dev = dev;
 	if (mode & OPEN_WRITE)
 		devc->playback_dev = dev;
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 /*
  * Mute output until the playback really starts. This decreases clicking (hope so).
  */
@@ -1024,7 +1024,7 @@
 
 	DEB(printk("ad1848_close(void)\n"));
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	devc->intr_active = 0;
 	ad1848_halt(dev);
@@ -1034,7 +1034,7 @@
 	portc->open_mode = 0;
 
 	ad_unmute(devc);
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad1848_output_block(int dev, unsigned long buf, int count, int intrflag)
@@ -1068,7 +1068,7 @@
 			 * Auto DMA mode on. No need to react
 			 */
 	}
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	ad_write(devc, 15, (unsigned char) (cnt & 0xff));
 	ad_write(devc, 14, (unsigned char) ((cnt >> 8) & 0xff));
@@ -1076,7 +1076,7 @@
 	devc->xfer_count = cnt;
 	devc->audio_mode |= PCM_ENABLE_OUTPUT;
 	devc->intr_active = 1;
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad1848_start_input(int dev, unsigned long buf, int count, int intrflag)
@@ -1109,7 +1109,7 @@
 			 * Auto DMA mode on. No need to react
 			 */
 	}
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	if (devc->model == MD_1848)
 	{
@@ -1127,7 +1127,7 @@
 	devc->xfer_count = cnt;
 	devc->audio_mode |= PCM_ENABLE_INPUT;
 	devc->intr_active = 1;
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static int ad1848_prepare_for_output(int dev, int bsize, int bcount)
@@ -1140,7 +1140,7 @@
 
 	ad_mute(devc);
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	fs = portc->speed_bits | (portc->format_bits << 5);
 
 	if (portc->channels > 1)
@@ -1184,7 +1184,7 @@
 	ad_leave_MCE(devc);	/*
 				 * Starts the calibration process.
 				 */
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 	devc->xfer_count = 0;
 
 #ifndef EXCLUDE_TIMERS
@@ -1209,7 +1209,7 @@
 	if (devc->audio_mode)
 		return 0;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	fs = portc->speed_bits | (portc->format_bits << 5);
 
 	if (portc->channels > 1)
@@ -1297,7 +1297,7 @@
 	ad_leave_MCE(devc);	/*
 				 * Starts the calibration process.
 				 */
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 	devc->xfer_count = 0;
 
 #ifndef EXCLUDE_TIMERS
@@ -1336,7 +1336,7 @@
 	if (!(ad_read(devc, 9) & 0x02))
 		return;		/* Capture not enabled */
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	ad_mute(devc);
 
@@ -1361,7 +1361,7 @@
 
 	devc->audio_mode &= ~PCM_ENABLE_INPUT;
 
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad1848_halt_output(int dev)
@@ -1372,7 +1372,7 @@
 	if (!(ad_read(devc, 9) & 0x01))
 		return;		/* Playback not enabled */
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	ad_mute(devc);
 	{
@@ -1397,7 +1397,7 @@
 
 	devc->audio_mode &= ~PCM_ENABLE_OUTPUT;
 
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad1848_trigger(int dev, int state)
@@ -1407,7 +1407,7 @@
 	unsigned long   flags;
 	unsigned char   tmp, old;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	state &= devc->audio_mode;
 
 	tmp = old = ad_read(devc, 9);
@@ -1432,7 +1432,7 @@
 		  ad_write(devc, 9, tmp);
 		  ad_unmute(devc);
 	}
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad1848_init_hw(ad1848_info * devc)
@@ -1969,7 +1969,6 @@
 
 	ad1848_port_info *portc = NULL;
 
-	spin_lock_init(&devc->lock);
 	devc->irq = (irq > 0) ? irq : 0;
 	devc->open_mode = 0;
 	devc->timer_ticks = 0;
@@ -2238,7 +2237,7 @@
 		if (devc->model == MD_C930)
 		{		/* 82C930 has interrupt status register in MAD16 register MC11 */
 
-			spin_lock(&devc->lock);
+			spin_lock(&ad1848_lock);
 
 			/* 0xe0e is C930 address port
 			 * 0xe0f is C930 data port
@@ -2247,7 +2246,7 @@
 			c930_stat = inb(0xe0f);
 			outb((~c930_stat), 0xe0f);
 
-			spin_unlock(&devc->lock);
+			spin_unlock(&ad1848_lock);
 
 			alt_stat = (c930_stat << 2) & 0x30;
 		}
@@ -2723,7 +2722,7 @@
 	unsigned long   xtal_nsecs;	/* nanoseconds per xtal oscillator tick */
 	unsigned long   divider;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	/*
 	 * Length of the timer interval (in nanoseconds) depends on the
@@ -2755,7 +2754,7 @@
 	ad_write(devc, 20, divider & 0xff);	/* Set lower bits */
 	ad_write(devc, 16, ad_read(devc, 16) | 0x40);	/* Start the timer */
 	devc->timer_running = 1;
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 
 	return current_interval = (divider * xtal_nsecs + 500) / 1000;
 }
@@ -2776,10 +2775,10 @@
 	unsigned long   flags;
 	ad1848_info    *devc = (ad1848_info *) audio_devs[dev]->devc;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	ad_write(devc, 16, ad_read(devc, 16) & ~0x40);
 	devc->timer_running = 0;
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static void ad1848_tmr_restart(int dev)
@@ -2790,10 +2789,10 @@
 	if (current_interval == 0)
 		return;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	ad_write(devc, 16, ad_read(devc, 16) | 0x40);
 	devc->timer_running = 1;
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 }
 
 static struct sound_lowlev_timer ad1848_tmr =
@@ -2821,11 +2820,11 @@
 {
 	unsigned long flags;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 
 	ad_mute(devc);
 	
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 	return 0;
 }
 
@@ -2834,7 +2833,7 @@
 	unsigned long flags;
 	int mixer_levels[32], i;
 
-	spin_lock_irqsave(&devc->lock,flags);
+	spin_lock_irqsave(&ad1848_lock,flags);
 	
 	/* Thinkpad is a bit more of PITA than normal. The BIOS tends to
 	   restore it in a different config to the one we use.  Need to
@@ -2860,7 +2859,7 @@
 		bits = interrupt_bits[devc->irq];
 		if (bits == -1) {
 			printk(KERN_ERR "MSS: Bad IRQ %d\n", devc->irq);
-			spin_unlock_irqrestore(&devc->lock,flags);
+			spin_unlock_irqrestore(&ad1848_lock,flags);
 			return -1;
 		}
 
@@ -2875,7 +2874,7 @@
 		outb((bits | dma_bits[devc->dma1] | dma2_bit), config_port);
 	}
 
-	spin_unlock_irqrestore(&devc->lock,flags);
+	spin_unlock_irqrestore(&ad1848_lock,flags);
 	return 0;
 }
 
