ChangeSet 1.2181.25.26, 2005/03/22 09:11:47+01:00, [EMAIL PROTECTED]
[ALSA] rawmidi - fix locking in drop_output and drain_input
RawMidi Midlevel
The comments in snd_rawmidi_drop_output and snd_rawmidi_drain_input
are wrong -- interrupts _are_ enabled, and spinlocks _are_ required.
So remove the comments and add spinlocks.
Signed-off-by: Clemens Ladisch <[EMAIL PROTECTED]>
rawmidi.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff -Nru a/sound/core/rawmidi.c b/sound/core/rawmidi.c
--- a/sound/core/rawmidi.c 2005-03-30 16:14:43 -08:00
+++ b/sound/core/rawmidi.c 2005-03-30 16:14:43 -08:00
@@ -136,14 +136,15 @@
int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream)
{
+ unsigned long flags;
snd_rawmidi_runtime_t *runtime = substream->runtime;
snd_rawmidi_trigger(substream, 0);
runtime->drain = 0;
- /* interrupts are not enabled at this moment,
- so spinlock is not required */
+ spin_lock_irqsave(&runtime->lock, flags);
runtime->appl_ptr = runtime->hw_ptr = 0;
runtime->avail = runtime->buffer_size;
+ spin_unlock_irqrestore(&runtime->lock, flags);
return 0;
}
@@ -178,13 +179,15 @@
int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream)
{
+ unsigned long flags;
snd_rawmidi_runtime_t *runtime = substream->runtime;
snd_rawmidi_trigger(substream, 0);
runtime->drain = 0;
- /* interrupts aren't enabled at this moment, so spinlock isn't needed */
+ spin_lock_irqsave(&runtime->lock, flags);
runtime->appl_ptr = runtime->hw_ptr = 0;
runtime->avail = 0;
+ spin_unlock_irqrestore(&runtime->lock, flags);
return 0;
}
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html