Commit bc518ba4 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: line6: Reduce superfluous spinlock in midi.c

The midi_transmit_lock is used always inside the send_urb_lock, thus
it doesn't play any role.  Let's kill it.  Also, rename
"send_urb_lock" as a more simple name "lock" since this is the only
lock for midi.
Tested-by: default avatarChris Rorvick <chris@rorvick.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b55004f9
...@@ -45,12 +45,9 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream) ...@@ -45,12 +45,9 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
line6_rawmidi_substream_midi(substream)->line6; line6_rawmidi_substream_midi(substream)->line6;
struct snd_line6_midi *line6midi = line6->line6midi; struct snd_line6_midi *line6midi = line6->line6midi;
struct midi_buffer *mb = &line6midi->midibuf_out; struct midi_buffer *mb = &line6midi->midibuf_out;
unsigned long flags;
unsigned char chunk[LINE6_FALLBACK_MAXPACKETSIZE]; unsigned char chunk[LINE6_FALLBACK_MAXPACKETSIZE];
int req, done; int req, done;
spin_lock_irqsave(&line6->line6midi->midi_transmit_lock, flags);
for (;;) { for (;;) {
req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size); req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size);
done = snd_rawmidi_transmit_peek(substream, chunk, req); done = snd_rawmidi_transmit_peek(substream, chunk, req);
...@@ -71,8 +68,6 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream) ...@@ -71,8 +68,6 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
send_midi_async(line6, chunk, done); send_midi_async(line6, chunk, done);
} }
spin_unlock_irqrestore(&line6->line6midi->midi_transmit_lock, flags);
} }
/* /*
...@@ -92,7 +87,7 @@ static void midi_sent(struct urb *urb) ...@@ -92,7 +87,7 @@ static void midi_sent(struct urb *urb)
if (status == -ESHUTDOWN) if (status == -ESHUTDOWN)
return; return;
spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags); spin_lock_irqsave(&line6->line6midi->lock, flags);
num = --line6->line6midi->num_active_send_urbs; num = --line6->line6midi->num_active_send_urbs;
if (num == 0) { if (num == 0) {
...@@ -103,12 +98,12 @@ static void midi_sent(struct urb *urb) ...@@ -103,12 +98,12 @@ static void midi_sent(struct urb *urb)
if (num == 0) if (num == 0)
wake_up(&line6->line6midi->send_wait); wake_up(&line6->line6midi->send_wait);
spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags); spin_unlock_irqrestore(&line6->line6midi->lock, flags);
} }
/* /*
Send an asynchronous MIDI message. Send an asynchronous MIDI message.
Assumes that line6->line6midi->send_urb_lock is held Assumes that line6->line6midi->lock is held
(i.e., this function is serialized). (i.e., this function is serialized).
*/ */
static int send_midi_async(struct usb_line6 *line6, unsigned char *data, static int send_midi_async(struct usb_line6 *line6, unsigned char *data,
...@@ -166,12 +161,12 @@ static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream, ...@@ -166,12 +161,12 @@ static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream,
line6_rawmidi_substream_midi(substream)->line6; line6_rawmidi_substream_midi(substream)->line6;
line6->line6midi->substream_transmit = substream; line6->line6midi->substream_transmit = substream;
spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags); spin_lock_irqsave(&line6->line6midi->lock, flags);
if (line6->line6midi->num_active_send_urbs == 0) if (line6->line6midi->num_active_send_urbs == 0)
line6_midi_transmit(substream); line6_midi_transmit(substream);
spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags); spin_unlock_irqrestore(&line6->line6midi->lock, flags);
} }
static void line6_midi_output_drain(struct snd_rawmidi_substream *substream) static void line6_midi_output_drain(struct snd_rawmidi_substream *substream)
...@@ -281,8 +276,7 @@ int line6_init_midi(struct usb_line6 *line6) ...@@ -281,8 +276,7 @@ int line6_init_midi(struct usb_line6 *line6)
rmidi->private_free = snd_line6_midi_free; rmidi->private_free = snd_line6_midi_free;
init_waitqueue_head(&line6midi->send_wait); init_waitqueue_head(&line6midi->send_wait);
spin_lock_init(&line6midi->send_urb_lock); spin_lock_init(&line6midi->lock);
spin_lock_init(&line6midi->midi_transmit_lock);
line6midi->line6 = line6; line6midi->line6 = line6;
err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0); err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0);
......
...@@ -39,15 +39,10 @@ struct snd_line6_midi { ...@@ -39,15 +39,10 @@ struct snd_line6_midi {
*/ */
int num_active_send_urbs; int num_active_send_urbs;
/**
Spin lock to protect updates of send_urb.
*/
spinlock_t send_urb_lock;
/** /**
Spin lock to protect MIDI buffer handling. Spin lock to protect MIDI buffer handling.
*/ */
spinlock_t midi_transmit_lock; spinlock_t lock;
/** /**
Wait queue for MIDI transmission. Wait queue for MIDI transmission.
......
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