Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sound: oss: remove last sleep_on users

There are three files in oss for which I could not find an easy way to
replace interruptible_sleep_on_timeout with a non-racy version. This
patch instead just adds a private implementation of the function, now
named oss_broken_sleep_on, and changes over the remaining users in
sound/oss/ so we can remove the global interface.

[fixed coding style warnings by tiwai]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Arnd Bergmann and committed by
Takashi Iwai
cdef2e5f 1a1e0a80

+39 -23
+6 -8
sound/oss/dmabuf.c
··· 28 28 #include <linux/mm.h> 29 29 #include <linux/gfp.h> 30 30 #include "sound_config.h" 31 + #include "sleep.h" 31 32 32 33 #define DMAP_FREE_ON_CLOSE 0 33 34 #define DMAP_KEEP_ON_CLOSE 1 ··· 352 351 if (!signal_pending(current) && adev->dmap_out->qlen && 353 352 adev->dmap_out->underrun_count == 0){ 354 353 spin_unlock_irqrestore(&dmap->lock,flags); 355 - interruptible_sleep_on_timeout(&adev->out_sleeper, 356 - dmabuf_timeout(dmap)); 354 + oss_broken_sleep_on(&adev->out_sleeper, dmabuf_timeout(dmap)); 357 355 spin_lock_irqsave(&dmap->lock,flags); 358 356 } 359 357 adev->dmap_out->flags &= ~(DMA_SYNCING | DMA_ACTIVE); ··· 446 446 long t = dmabuf_timeout(dmap); 447 447 spin_unlock_irqrestore(&dmap->lock,flags); 448 448 /* FIXME: not safe may miss events */ 449 - t = interruptible_sleep_on_timeout(&adev->out_sleeper, t); 449 + t = oss_broken_sleep_on(&adev->out_sleeper, t); 450 450 spin_lock_irqsave(&dmap->lock,flags); 451 451 if (!t) { 452 452 adev->dmap_out->flags &= ~DMA_SYNCING; ··· 466 466 while (!signal_pending(current) && 467 467 adev->d->local_qlen(dev)){ 468 468 spin_unlock_irqrestore(&dmap->lock,flags); 469 - interruptible_sleep_on_timeout(&adev->out_sleeper, 469 + oss_broken_sleep_on(&adev->out_sleeper, 470 470 dmabuf_timeout(dmap)); 471 471 spin_lock_irqsave(&dmap->lock,flags); 472 472 } ··· 587 587 timeout = dmabuf_timeout(dmap); 588 588 589 589 spin_unlock_irqrestore(&dmap->lock,flags); 590 - timeout = interruptible_sleep_on_timeout(&adev->in_sleeper, 591 - timeout); 590 + timeout = oss_broken_sleep_on(&adev->in_sleeper, timeout); 592 591 if (!timeout) { 593 592 /* FIXME: include device name */ 594 593 err = -EIO; ··· 767 768 timeout_value = dmabuf_timeout(dmap); 768 769 else 769 770 timeout_value = MAX_SCHEDULE_TIMEOUT; 770 - timeout_value = interruptible_sleep_on_timeout(&adev->out_sleeper, 771 - timeout_value); 771 + timeout_value = oss_broken_sleep_on(&adev->out_sleeper, timeout_value); 772 772 if (timeout != MAX_SCHEDULE_TIMEOUT && !timeout_value) { 773 773 printk(KERN_WARNING "Sound: DMA (output) timed out - IRQ/DRQ config error?\n"); 774 774 dma_reset_output(dev);
+7 -9
sound/oss/sequencer.c
··· 19 19 #include "sound_config.h" 20 20 21 21 #include "midi_ctrl.h" 22 + #include "sleep.h" 22 23 23 24 static int sequencer_ok; 24 25 static struct sound_timer_operations *tmr; ··· 101 100 return -EAGAIN; 102 101 } 103 102 104 - interruptible_sleep_on_timeout(&midi_sleeper, 105 - pre_event_timeout); 103 + oss_broken_sleep_on(&midi_sleeper, pre_event_timeout); 106 104 spin_lock_irqsave(&lock,flags); 107 105 if (!iqlen) 108 106 { ··· 343 343 /* 344 344 * Sleep until there is enough space on the queue 345 345 */ 346 - interruptible_sleep_on(&seq_sleeper); 346 + oss_broken_sleep_on(&seq_sleeper, MAX_SCHEDULE_TIMEOUT); 347 347 } 348 348 if (qlen >= SEQ_MAX_QUEUE) 349 349 { ··· 1122 1122 */ 1123 1123 1124 1124 if (n) 1125 - interruptible_sleep_on_timeout(&seq_sleeper, 1126 - HZ/10); 1125 + oss_broken_sleep_on(&seq_sleeper, HZ/10); 1127 1126 } 1128 1127 } 1129 1128 ··· 1144 1145 while (!signal_pending(current) && qlen > 0) 1145 1146 { 1146 1147 seq_sync(); 1147 - interruptible_sleep_on_timeout(&seq_sleeper, 1148 - 3*HZ); 1148 + oss_broken_sleep_on(&seq_sleeper, 3*HZ); 1149 1149 /* Extra delay */ 1150 1150 } 1151 1151 } ··· 1199 1201 seq_startplay(); 1200 1202 1201 1203 if (qlen > 0) 1202 - interruptible_sleep_on_timeout(&seq_sleeper, HZ); 1204 + oss_broken_sleep_on(&seq_sleeper, HZ); 1203 1205 return qlen; 1204 1206 } 1205 1207 ··· 1222 1224 1223 1225 spin_lock_irqsave(&lock,flags); 1224 1226 while (n && !midi_devs[dev]->outputc(dev, data)) { 1225 - interruptible_sleep_on_timeout(&seq_sleeper, HZ/25); 1227 + oss_broken_sleep_on(&seq_sleeper, HZ/25); 1226 1228 n--; 1227 1229 } 1228 1230 spin_unlock_irqrestore(&lock,flags);
+18
sound/oss/sleep.h
··· 1 + #include <linux/wait.h> 2 + 3 + /* 4 + * Do not use. This is a replacement for the old 5 + * "interruptible_sleep_on_timeout" function that has been 6 + * deprecated for ages. All users should instead try to use 7 + * wait_event_interruptible_timeout. 8 + */ 9 + 10 + static inline long 11 + oss_broken_sleep_on(wait_queue_head_t *q, long timeout) 12 + { 13 + DEFINE_WAIT(wait); 14 + prepare_to_wait(q, &wait, TASK_INTERRUPTIBLE); 15 + timeout = schedule_timeout(timeout); 16 + finish_wait(q, &wait); 17 + return timeout; 18 + }
+8 -6
sound/oss/swarm_cs4297a.c
··· 90 90 #include <asm/sibyte/sb1250_mac.h> 91 91 #include <asm/sibyte/sb1250.h> 92 92 93 + #include "sleep.h" 94 + 93 95 struct cs4297a_state; 94 96 95 97 static DEFINE_MUTEX(swarm_cs4297a_mutex); ··· 750 748 /* Since a writer has the DSP open, we have to mux the 751 749 request in */ 752 750 s->reg_request = data; 753 - interruptible_sleep_on(&s->dma_dac.reg_wait); 751 + oss_broken_sleep_on(&s->dma_dac.reg_wait, MAX_SCHEDULE_TIMEOUT); 754 752 /* XXXKW how can I deal with the starvation case where 755 753 the opener isn't writing? */ 756 754 } else { ··· 792 790 if (serdma_reg_access(s, (0xCLL << 60) | (1LL << 47) | ((u64)(offset & 0x7F) << 40))) 793 791 return -1; 794 792 795 - interruptible_sleep_on(&s->dma_adc.reg_wait); 793 + oss_broken_sleep_on(&s->dma_adc.reg_wait, MAX_SCHEDULE_TIMEOUT); 796 794 *value = s->read_value; 797 795 CS_DBGOUT(CS_AC97, 2, 798 796 printk(KERN_INFO "cs4297a: rdr reg %x -> %x\n", s->read_reg, s->read_value)); ··· 1742 1740 start_adc(s); 1743 1741 if (file->f_flags & O_NONBLOCK) 1744 1742 return ret ? ret : -EAGAIN; 1745 - interruptible_sleep_on(&s->dma_adc.wait); 1743 + oss_broken_sleep_on(&s->dma_adc.wait, MAX_SCHEDULE_TIMEOUT); 1746 1744 if (signal_pending(current)) 1747 1745 return ret ? ret : -ERESTARTSYS; 1748 1746 continue; ··· 1838 1836 start_dac(s); 1839 1837 if (file->f_flags & O_NONBLOCK) 1840 1838 return ret ? ret : -EAGAIN; 1841 - interruptible_sleep_on(&d->wait); 1839 + oss_broken_sleep_on(&d->wait, MAX_SCHEDULE_TIMEOUT); 1842 1840 if (signal_pending(current)) 1843 1841 return ret ? ret : -ERESTARTSYS; 1844 1842 continue; ··· 2454 2452 return -EBUSY; 2455 2453 } 2456 2454 mutex_unlock(&s->open_sem_dac); 2457 - interruptible_sleep_on(&s->open_wait_dac); 2455 + oss_broken_sleep_on(&s->open_wait_dac, MAX_SCHEDULE_TIMEOUT); 2458 2456 2459 2457 if (signal_pending(current)) { 2460 2458 printk("open - sig pending\n"); ··· 2471 2469 return -EBUSY; 2472 2470 } 2473 2471 mutex_unlock(&s->open_sem_adc); 2474 - interruptible_sleep_on(&s->open_wait_adc); 2472 + oss_broken_sleep_on(&s->open_wait_adc, MAX_SCHEDULE_TIMEOUT); 2475 2473 2476 2474 if (signal_pending(current)) { 2477 2475 printk("open - sig pending\n");