Commit 76439c2a authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Takashi Iwai

sound: oss: midibuf: fix sleep_on races

sleep_on is known to be racy and going away because of this. All instances
of interruptible_sleep_on and interruptible_sleep_on_timeout in the midibuf
driver can trivially be replaced with wait_event_interruptible and
wait_event_interruptible_timeout.

[fixed coding style warnings by tiwai]
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7bd6972a
...@@ -86,9 +86,8 @@ static void drain_midi_queue(int dev) ...@@ -86,9 +86,8 @@ static void drain_midi_queue(int dev)
*/ */
if (midi_devs[dev]->buffer_status != NULL) if (midi_devs[dev]->buffer_status != NULL)
while (!signal_pending(current) && midi_devs[dev]->buffer_status(dev)) wait_event_interruptible_timeout(midi_sleeper[dev],
interruptible_sleep_on_timeout(&midi_sleeper[dev], !midi_devs[dev]->buffer_status(dev), HZ/10);
HZ/10);
} }
static void midi_input_intr(int dev, unsigned char data) static void midi_input_intr(int dev, unsigned char data)
...@@ -233,8 +232,8 @@ void MIDIbuf_release(int dev, struct file *file) ...@@ -233,8 +232,8 @@ void MIDIbuf_release(int dev, struct file *file)
* devices * devices
*/ */
while (!signal_pending(current) && DATA_AVAIL(midi_out_buf[dev])) wait_event_interruptible(midi_sleeper[dev],
interruptible_sleep_on(&midi_sleeper[dev]); !DATA_AVAIL(midi_out_buf[dev]));
/* /*
* Sync * Sync
*/ */
...@@ -282,8 +281,8 @@ int MIDIbuf_write(int dev, struct file *file, const char __user *buf, int count) ...@@ -282,8 +281,8 @@ int MIDIbuf_write(int dev, struct file *file, const char __user *buf, int count)
goto out; goto out;
} }
interruptible_sleep_on(&midi_sleeper[dev]); if (wait_event_interruptible(midi_sleeper[dev],
if (signal_pending(current)) SPACE_AVAIL(midi_out_buf[dev])))
{ {
c = -EINTR; c = -EINTR;
goto out; goto out;
...@@ -325,7 +324,8 @@ int MIDIbuf_read(int dev, struct file *file, char __user *buf, int count) ...@@ -325,7 +324,8 @@ int MIDIbuf_read(int dev, struct file *file, char __user *buf, int count)
c = -EAGAIN; c = -EAGAIN;
goto out; goto out;
} }
interruptible_sleep_on_timeout(&input_sleeper[dev], wait_event_interruptible_timeout(input_sleeper[dev],
DATA_AVAIL(midi_in_buf[dev]),
parms[dev].prech_timeout); parms[dev].prech_timeout);
if (signal_pending(current)) if (signal_pending(current))
......
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