aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2014-01-02 07:07:48 -0500
committerTakashi Iwai <tiwai@suse.de>2014-01-14 10:11:44 -0500
commit76439c2ac686c547ca2f53bfe964c100e697ff4a (patch)
tree150ef40cb55992118fc5aa52cae5ace82c3e9608 /sound/oss
parent7bd6972a921e148beea54919a00aa7b0bf046ff1 (diff)
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: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/oss')
-rw-r--r--sound/oss/midibuf.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c
index 8cdb2cfe65c8..8f45cd999965 100644
--- a/sound/oss/midibuf.c
+++ b/sound/oss/midibuf.c
@@ -86,9 +86,8 @@ static void drain_midi_queue(int dev)
86 */ 86 */
87 87
88 if (midi_devs[dev]->buffer_status != NULL) 88 if (midi_devs[dev]->buffer_status != NULL)
89 while (!signal_pending(current) && midi_devs[dev]->buffer_status(dev)) 89 wait_event_interruptible_timeout(midi_sleeper[dev],
90 interruptible_sleep_on_timeout(&midi_sleeper[dev], 90 !midi_devs[dev]->buffer_status(dev), HZ/10);
91 HZ/10);
92} 91}
93 92
94static void midi_input_intr(int dev, unsigned char data) 93static void midi_input_intr(int dev, unsigned char data)
@@ -233,8 +232,8 @@ void MIDIbuf_release(int dev, struct file *file)
233 * devices 232 * devices
234 */ 233 */
235 234
236 while (!signal_pending(current) && DATA_AVAIL(midi_out_buf[dev])) 235 wait_event_interruptible(midi_sleeper[dev],
237 interruptible_sleep_on(&midi_sleeper[dev]); 236 !DATA_AVAIL(midi_out_buf[dev]));
238 /* 237 /*
239 * Sync 238 * Sync
240 */ 239 */
@@ -282,8 +281,8 @@ int MIDIbuf_write(int dev, struct file *file, const char __user *buf, int count)
282 goto out; 281 goto out;
283 } 282 }
284 283
285 interruptible_sleep_on(&midi_sleeper[dev]); 284 if (wait_event_interruptible(midi_sleeper[dev],
286 if (signal_pending(current)) 285 SPACE_AVAIL(midi_out_buf[dev])))
287 { 286 {
288 c = -EINTR; 287 c = -EINTR;
289 goto out; 288 goto out;
@@ -325,8 +324,9 @@ int MIDIbuf_read(int dev, struct file *file, char __user *buf, int count)
325 c = -EAGAIN; 324 c = -EAGAIN;
326 goto out; 325 goto out;
327 } 326 }
328 interruptible_sleep_on_timeout(&input_sleeper[dev], 327 wait_event_interruptible_timeout(input_sleeper[dev],
329 parms[dev].prech_timeout); 328 DATA_AVAIL(midi_in_buf[dev]),
329 parms[dev].prech_timeout);
330 330
331 if (signal_pending(current)) 331 if (signal_pending(current))
332 c = -EINTR; /* The user is getting restless */ 332 c = -EINTR; /* The user is getting restless */