Commit d5ee49df authored by Peter Wächtler's avatar Peter Wächtler Committed by Linus Torvalds

[PATCH] oss/pas2_midi.c - convert cli to spinlocks

parent 8737c96b
...@@ -14,10 +14,13 @@ ...@@ -14,10 +14,13 @@
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/spinlock.h>
#include "sound_config.h" #include "sound_config.h"
#include "pas2.h" #include "pas2.h"
extern spinlock_t lock;
static int midi_busy = 0, input_opened = 0; static int midi_busy = 0, input_opened = 0;
static int my_dev; static int my_dev;
...@@ -48,12 +51,11 @@ static int pas_midi_open(int dev, int mode, ...@@ -48,12 +51,11 @@ static int pas_midi_open(int dev, int mode,
pas_write(0x20 | 0x40, pas_write(0x20 | 0x40,
0x178b); 0x178b);
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
if ((err = pas_set_intr(0x10)) < 0) if ((err = pas_set_intr(0x10)) < 0)
{ {
restore_flags(flags); spin_unlock_irqrestore(&lock, flags);
return err; return err;
} }
/* /*
...@@ -81,7 +83,7 @@ static int pas_midi_open(int dev, int mode, ...@@ -81,7 +83,7 @@ static int pas_midi_open(int dev, int mode,
pas_write(0xff, 0x1B88); pas_write(0xff, 0x1B88);
restore_flags(flags); spin_unlock_irqrestore(&lock, flags);
midi_busy = 1; midi_busy = 1;
qlen = qhead = qtail = 0; qlen = qhead = qtail = 0;
...@@ -131,8 +133,7 @@ static int pas_midi_out(int dev, unsigned char midi_byte) ...@@ -131,8 +133,7 @@ static int pas_midi_out(int dev, unsigned char midi_byte)
* Drain the local queue first * Drain the local queue first
*/ */
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
while (qlen && dump_to_midi(tmp_queue[qhead])) while (qlen && dump_to_midi(tmp_queue[qhead]))
{ {
...@@ -140,7 +141,7 @@ static int pas_midi_out(int dev, unsigned char midi_byte) ...@@ -140,7 +141,7 @@ static int pas_midi_out(int dev, unsigned char midi_byte)
qhead++; qhead++;
} }
restore_flags(flags); spin_unlock_irqrestore(&lock, flags);
/* /*
* Output the byte if the local queue is empty. * Output the byte if the local queue is empty.
...@@ -157,14 +158,13 @@ static int pas_midi_out(int dev, unsigned char midi_byte) ...@@ -157,14 +158,13 @@ static int pas_midi_out(int dev, unsigned char midi_byte)
if (qlen >= 256) if (qlen >= 256)
return 0; /* Local queue full */ return 0; /* Local queue full */
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
tmp_queue[qtail] = midi_byte; tmp_queue[qtail] = midi_byte;
qlen++; qlen++;
qtail++; qtail++;
restore_flags(flags); spin_unlock_irqrestore(&lock, flags);
return 1; return 1;
} }
...@@ -226,7 +226,6 @@ void pas_midi_interrupt(void) ...@@ -226,7 +226,6 @@ void pas_midi_interrupt(void)
{ {
unsigned char stat; unsigned char stat;
int i, incount; int i, incount;
unsigned long flags;
stat = pas_read(0x1B88); stat = pas_read(0x1B88);
...@@ -245,8 +244,7 @@ void pas_midi_interrupt(void) ...@@ -245,8 +244,7 @@ void pas_midi_interrupt(void)
} }
if (stat & (0x08 | 0x10)) if (stat & (0x08 | 0x10))
{ {
save_flags(flags); spin_lock(&lock);/* called in irq context */
cli();
while (qlen && dump_to_midi(tmp_queue[qhead])) while (qlen && dump_to_midi(tmp_queue[qhead]))
{ {
...@@ -254,7 +252,7 @@ void pas_midi_interrupt(void) ...@@ -254,7 +252,7 @@ void pas_midi_interrupt(void)
qhead++; qhead++;
} }
restore_flags(flags); spin_unlock(&lock);
} }
if (stat & 0x40) if (stat & 0x40)
{ {
......
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