patch-2.4.0-test7 linux/drivers/sound/emu10k1/emuadxmg.c

Next file: linux/drivers/sound/emu10k1/hwaccess.c
Previous file: linux/drivers/sound/emu10k1/emu_wrapper.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test6/linux/drivers/sound/emu10k1/emuadxmg.c linux/drivers/sound/emu10k1/emuadxmg.c
@@ -44,14 +44,15 @@
 	/* Convert bytes to pages */
 	numpages = (size / EMUPAGESIZE) + ((size % EMUPAGESIZE) ? 1 : 0);
 
-	while (index < (MAXPAGES - RESERVED - 1)) {
+	spin_lock_irqsave(&card->lock, flags);
+
+	while (index < (MAXPAGES - 1)) {
 		if (pagetable[index] & 0x8000) {
 			/* This block of pages is in use, jump to the start of the next block. */
 			index += (pagetable[index] & 0x7fff);
 		} else {
 			/* Found free block */
 			if (pagetable[index] >= numpages) {
-				spin_lock_irqsave(&card->lock, flags);
 
 				/* Block is large enough */
 
@@ -71,6 +72,8 @@
 			}
 		}
 	}
+
+	spin_unlock_irqrestore(&card->lock, flags);
 
 	return -1;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)