Commit 72069dc5 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] fix modular gus shared lock

parent 8bc47ee1
...@@ -26,7 +26,6 @@ static int midi_busy = 0, input_opened = 0; ...@@ -26,7 +26,6 @@ static int midi_busy = 0, input_opened = 0;
static int my_dev; static int my_dev;
static int output_used = 0; static int output_used = 0;
static volatile unsigned char gus_midi_control; static volatile unsigned char gus_midi_control;
static spinlock_t lock=SPIN_LOCK_UNLOCKED;
static void (*midi_input_intr) (int dev, unsigned char data); static void (*midi_input_intr) (int dev, unsigned char data);
static unsigned char tmp_queue[256]; static unsigned char tmp_queue[256];
...@@ -35,6 +34,7 @@ static volatile int qlen; ...@@ -35,6 +34,7 @@ static volatile int qlen;
static volatile unsigned char qhead, qtail; static volatile unsigned char qhead, qtail;
extern int gus_base, gus_irq, gus_dma; extern int gus_base, gus_irq, gus_dma;
extern int *gus_osp; extern int *gus_osp;
extern spinlock_t gus_lock;
static int GUS_MIDI_STATUS(void) static int GUS_MIDI_STATUS(void)
{ {
...@@ -76,7 +76,7 @@ static int dump_to_midi(unsigned char midi_byte) ...@@ -76,7 +76,7 @@ static int dump_to_midi(unsigned char midi_byte)
output_used = 1; output_used = 1;
spin_lock_irqsave(&lock, flags); spin_lock_irqsave(&gus_lock, flags);
if (GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY) if (GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY)
{ {
...@@ -92,7 +92,7 @@ static int dump_to_midi(unsigned char midi_byte) ...@@ -92,7 +92,7 @@ static int dump_to_midi(unsigned char midi_byte)
outb((gus_midi_control), u_MidiControl); outb((gus_midi_control), u_MidiControl);
} }
spin_unlock_irqrestore(&lock,flags); spin_unlock_irqrestore(&gus_lock,flags);
return ok; return ok;
} }
...@@ -113,14 +113,14 @@ static int gus_midi_out(int dev, unsigned char midi_byte) ...@@ -113,14 +113,14 @@ static int gus_midi_out(int dev, unsigned char midi_byte)
/* /*
* Drain the local queue first * Drain the local queue first
*/ */
spin_lock_irqsave(&lock, flags); spin_lock_irqsave(&gus_lock, flags);
while (qlen && dump_to_midi(tmp_queue[qhead])) while (qlen && dump_to_midi(tmp_queue[qhead]))
{ {
qlen--; qlen--;
qhead++; qhead++;
} }
spin_unlock_irqrestore(&lock,flags); spin_unlock_irqrestore(&gus_lock,flags);
/* /*
* Output the byte if the local queue is empty. * Output the byte if the local queue is empty.
...@@ -140,13 +140,13 @@ static int gus_midi_out(int dev, unsigned char midi_byte) ...@@ -140,13 +140,13 @@ static int gus_midi_out(int dev, unsigned char midi_byte)
return 0; /* return 0; /*
* Local queue full * Local queue full
*/ */
spin_lock_irqsave(&lock, flags); spin_lock_irqsave(&gus_lock, flags);
tmp_queue[qtail] = midi_byte; tmp_queue[qtail] = midi_byte;
qlen++; qlen++;
qtail++; qtail++;
spin_unlock_irqrestore(&lock,flags); spin_unlock_irqrestore(&gus_lock,flags);
return 1; return 1;
} }
...@@ -171,14 +171,14 @@ static int gus_midi_buffer_status(int dev) ...@@ -171,14 +171,14 @@ static int gus_midi_buffer_status(int dev)
if (!output_used) if (!output_used)
return 0; return 0;
spin_lock_irqsave(&lock, flags); spin_lock_irqsave(&gus_lock, flags);
if (qlen && dump_to_midi(tmp_queue[qhead])) if (qlen && dump_to_midi(tmp_queue[qhead]))
{ {
qlen--; qlen--;
qhead++; qhead++;
} }
spin_unlock_irqrestore(&lock,flags); spin_unlock_irqrestore(&gus_lock,flags);
return (qlen > 0) || !(GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY); return (qlen > 0) || !(GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY);
} }
...@@ -188,17 +188,17 @@ static int gus_midi_buffer_status(int dev) ...@@ -188,17 +188,17 @@ static int gus_midi_buffer_status(int dev)
static struct midi_operations gus_midi_operations = static struct midi_operations gus_midi_operations =
{ {
owner: THIS_MODULE, .owner = THIS_MODULE,
info: {"Gravis UltraSound Midi", 0, 0, SNDCARD_GUS}, .info = {"Gravis UltraSound Midi", 0, 0, SNDCARD_GUS},
converter: &std_midi_synth, .converter = &std_midi_synth,
in_info: {0}, .in_info = {0},
open: gus_midi_open, .open = gus_midi_open,
close: gus_midi_close, .close = gus_midi_close,
outputc: gus_midi_out, .outputc = gus_midi_out,
start_read: gus_midi_start_read, .start_read = gus_midi_start_read,
end_read: gus_midi_end_read, .end_read = gus_midi_end_read,
kick: gus_midi_kick, .kick = gus_midi_kick,
buffer_status: gus_midi_buffer_status, .buffer_status = gus_midi_buffer_status,
}; };
void __init gus_midi_init(struct address_info *hw_config) void __init gus_midi_init(struct address_info *hw_config)
...@@ -224,7 +224,7 @@ void gus_midi_interrupt(int dummy) ...@@ -224,7 +224,7 @@ void gus_midi_interrupt(int dummy)
volatile unsigned char stat, data; volatile unsigned char stat, data;
int timeout = 10; int timeout = 10;
spin_lock(&lock); spin_lock(&gus_lock);
while (timeout-- > 0 && (stat = GUS_MIDI_STATUS()) & (MIDI_RCV_FULL | MIDI_XMIT_EMPTY)) while (timeout-- > 0 && (stat = GUS_MIDI_STATUS()) & (MIDI_RCV_FULL | MIDI_XMIT_EMPTY))
{ {
...@@ -252,5 +252,5 @@ void gus_midi_interrupt(int dummy) ...@@ -252,5 +252,5 @@ void gus_midi_interrupt(int dummy)
} }
} }
} }
spin_unlock(&lock); spin_unlock(&gus_lock);
} }
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment