diff options
Diffstat (limited to 'sound/oss')
-rw-r--r-- | sound/oss/dmabuf.c | 14 | ||||
-rw-r--r-- | sound/oss/dmasound/dmasound.h | 1 | ||||
-rw-r--r-- | sound/oss/dmasound/dmasound_core.c | 28 | ||||
-rw-r--r-- | sound/oss/midibuf.c | 18 | ||||
-rw-r--r-- | sound/oss/msnd_pinnacle.c | 31 | ||||
-rw-r--r-- | sound/oss/sequencer.c | 16 | ||||
-rw-r--r-- | sound/oss/sleep.h | 18 | ||||
-rw-r--r-- | sound/oss/swarm_cs4297a.c | 14 | ||||
-rw-r--r-- | sound/oss/vwsnd.c | 14 |
9 files changed, 95 insertions, 59 deletions
diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c index 461d94cfecbe..e3f29132d3ac 100644 --- a/sound/oss/dmabuf.c +++ b/sound/oss/dmabuf.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/gfp.h> | 29 | #include <linux/gfp.h> |
30 | #include "sound_config.h" | 30 | #include "sound_config.h" |
31 | #include "sleep.h" | ||
31 | 32 | ||
32 | #define DMAP_FREE_ON_CLOSE 0 | 33 | #define DMAP_FREE_ON_CLOSE 0 |
33 | #define DMAP_KEEP_ON_CLOSE 1 | 34 | #define DMAP_KEEP_ON_CLOSE 1 |
@@ -351,8 +352,7 @@ static void dma_reset_output(int dev) | |||
351 | if (!signal_pending(current) && adev->dmap_out->qlen && | 352 | if (!signal_pending(current) && adev->dmap_out->qlen && |
352 | adev->dmap_out->underrun_count == 0){ | 353 | adev->dmap_out->underrun_count == 0){ |
353 | spin_unlock_irqrestore(&dmap->lock,flags); | 354 | spin_unlock_irqrestore(&dmap->lock,flags); |
354 | interruptible_sleep_on_timeout(&adev->out_sleeper, | 355 | oss_broken_sleep_on(&adev->out_sleeper, dmabuf_timeout(dmap)); |
355 | dmabuf_timeout(dmap)); | ||
356 | spin_lock_irqsave(&dmap->lock,flags); | 356 | spin_lock_irqsave(&dmap->lock,flags); |
357 | } | 357 | } |
358 | adev->dmap_out->flags &= ~(DMA_SYNCING | DMA_ACTIVE); | 358 | adev->dmap_out->flags &= ~(DMA_SYNCING | DMA_ACTIVE); |
@@ -446,7 +446,7 @@ int DMAbuf_sync(int dev) | |||
446 | long t = dmabuf_timeout(dmap); | 446 | long t = dmabuf_timeout(dmap); |
447 | spin_unlock_irqrestore(&dmap->lock,flags); | 447 | spin_unlock_irqrestore(&dmap->lock,flags); |
448 | /* FIXME: not safe may miss events */ | 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 | spin_lock_irqsave(&dmap->lock,flags); | 450 | spin_lock_irqsave(&dmap->lock,flags); |
451 | if (!t) { | 451 | if (!t) { |
452 | adev->dmap_out->flags &= ~DMA_SYNCING; | 452 | adev->dmap_out->flags &= ~DMA_SYNCING; |
@@ -466,7 +466,7 @@ int DMAbuf_sync(int dev) | |||
466 | while (!signal_pending(current) && | 466 | while (!signal_pending(current) && |
467 | adev->d->local_qlen(dev)){ | 467 | adev->d->local_qlen(dev)){ |
468 | spin_unlock_irqrestore(&dmap->lock,flags); | 468 | spin_unlock_irqrestore(&dmap->lock,flags); |
469 | interruptible_sleep_on_timeout(&adev->out_sleeper, | 469 | oss_broken_sleep_on(&adev->out_sleeper, |
470 | dmabuf_timeout(dmap)); | 470 | dmabuf_timeout(dmap)); |
471 | spin_lock_irqsave(&dmap->lock,flags); | 471 | spin_lock_irqsave(&dmap->lock,flags); |
472 | } | 472 | } |
@@ -587,8 +587,7 @@ int DMAbuf_getrdbuffer(int dev, char **buf, int *len, int dontblock) | |||
587 | timeout = dmabuf_timeout(dmap); | 587 | timeout = dmabuf_timeout(dmap); |
588 | 588 | ||
589 | spin_unlock_irqrestore(&dmap->lock,flags); | 589 | spin_unlock_irqrestore(&dmap->lock,flags); |
590 | timeout = interruptible_sleep_on_timeout(&adev->in_sleeper, | 590 | timeout = oss_broken_sleep_on(&adev->in_sleeper, timeout); |
591 | timeout); | ||
592 | if (!timeout) { | 591 | if (!timeout) { |
593 | /* FIXME: include device name */ | 592 | /* FIXME: include device name */ |
594 | err = -EIO; | 593 | err = -EIO; |
@@ -768,8 +767,7 @@ static int output_sleep(int dev, int dontblock) | |||
768 | timeout_value = dmabuf_timeout(dmap); | 767 | timeout_value = dmabuf_timeout(dmap); |
769 | else | 768 | else |
770 | timeout_value = MAX_SCHEDULE_TIMEOUT; | 769 | timeout_value = MAX_SCHEDULE_TIMEOUT; |
771 | timeout_value = interruptible_sleep_on_timeout(&adev->out_sleeper, | 770 | timeout_value = oss_broken_sleep_on(&adev->out_sleeper, timeout_value); |
772 | timeout_value); | ||
773 | if (timeout != MAX_SCHEDULE_TIMEOUT && !timeout_value) { | 771 | if (timeout != MAX_SCHEDULE_TIMEOUT && !timeout_value) { |
774 | printk(KERN_WARNING "Sound: DMA (output) timed out - IRQ/DRQ config error?\n"); | 772 | printk(KERN_WARNING "Sound: DMA (output) timed out - IRQ/DRQ config error?\n"); |
775 | dma_reset_output(dev); | 773 | dma_reset_output(dev); |
diff --git a/sound/oss/dmasound/dmasound.h b/sound/oss/dmasound/dmasound.h index 1308d8d34186..01019f06fa91 100644 --- a/sound/oss/dmasound/dmasound.h +++ b/sound/oss/dmasound/dmasound.h | |||
@@ -239,7 +239,6 @@ struct sound_queue { | |||
239 | int busy, syncing, xruns, died; | 239 | int busy, syncing, xruns, died; |
240 | }; | 240 | }; |
241 | 241 | ||
242 | #define SLEEP(queue) interruptible_sleep_on_timeout(&queue, HZ) | ||
243 | #define WAKE_UP(queue) (wake_up_interruptible(&queue)) | 242 | #define WAKE_UP(queue) (wake_up_interruptible(&queue)) |
244 | 243 | ||
245 | extern struct sound_queue dmasound_write_sq; | 244 | extern struct sound_queue dmasound_write_sq; |
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index bac43b5b6e95..f4ee85a4c42f 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c | |||
@@ -619,15 +619,27 @@ static ssize_t sq_write(struct file *file, const char __user *src, size_t uLeft, | |||
619 | } | 619 | } |
620 | 620 | ||
621 | while (uLeft) { | 621 | while (uLeft) { |
622 | DEFINE_WAIT(wait); | ||
623 | |||
622 | while (write_sq.count >= write_sq.max_active) { | 624 | while (write_sq.count >= write_sq.max_active) { |
625 | prepare_to_wait(&write_sq.action_queue, &wait, TASK_INTERRUPTIBLE); | ||
623 | sq_play(); | 626 | sq_play(); |
624 | if (write_sq.non_blocking) | 627 | if (write_sq.non_blocking) { |
628 | finish_wait(&write_sq.action_queue, &wait); | ||
625 | return uWritten > 0 ? uWritten : -EAGAIN; | 629 | return uWritten > 0 ? uWritten : -EAGAIN; |
626 | SLEEP(write_sq.action_queue); | 630 | } |
627 | if (signal_pending(current)) | 631 | if (write_sq.count < write_sq.max_active) |
632 | break; | ||
633 | |||
634 | schedule_timeout(HZ); | ||
635 | if (signal_pending(current)) { | ||
636 | finish_wait(&write_sq.action_queue, &wait); | ||
628 | return uWritten > 0 ? uWritten : -EINTR; | 637 | return uWritten > 0 ? uWritten : -EINTR; |
638 | } | ||
629 | } | 639 | } |
630 | 640 | ||
641 | finish_wait(&write_sq.action_queue, &wait); | ||
642 | |||
631 | /* Here, we can avoid disabling the interrupt by first | 643 | /* Here, we can avoid disabling the interrupt by first |
632 | * copying and translating the data, and then updating | 644 | * copying and translating the data, and then updating |
633 | * the write_sq variables. Until this is done, the interrupt | 645 | * the write_sq variables. Until this is done, the interrupt |
@@ -707,11 +719,8 @@ static int sq_open2(struct sound_queue *sq, struct file *file, fmode_t mode, | |||
707 | if (file->f_flags & O_NONBLOCK) | 719 | if (file->f_flags & O_NONBLOCK) |
708 | return rc; | 720 | return rc; |
709 | rc = -EINTR; | 721 | rc = -EINTR; |
710 | while (sq->busy) { | 722 | if (wait_event_interruptible(sq->open_queue, !sq->busy)) |
711 | SLEEP(sq->open_queue); | 723 | return rc; |
712 | if (signal_pending(current)) | ||
713 | return rc; | ||
714 | } | ||
715 | rc = 0; | 724 | rc = 0; |
716 | #else | 725 | #else |
717 | /* OSS manual says we will return EBUSY regardless | 726 | /* OSS manual says we will return EBUSY regardless |
@@ -844,7 +853,8 @@ static int sq_fsync(void) | |||
844 | sq_play(); /* there may be an incomplete frame waiting */ | 853 | sq_play(); /* there may be an incomplete frame waiting */ |
845 | 854 | ||
846 | while (write_sq.active) { | 855 | while (write_sq.active) { |
847 | SLEEP(write_sq.sync_queue); | 856 | wait_event_interruptible_timeout(write_sq.sync_queue, |
857 | !write_sq.active, HZ); | ||
848 | if (signal_pending(current)) { | 858 | if (signal_pending(current)) { |
849 | /* While waiting for audio output to drain, an | 859 | /* While waiting for audio output to drain, an |
850 | * interrupt occurred. Stop audio output immediately | 860 | * interrupt occurred. Stop audio output immediately |
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 | ||
94 | static void midi_input_intr(int dev, unsigned char data) | 93 | static 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 */ |
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c index 11ff7c55240c..c23f9f95bfa5 100644 --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c | |||
@@ -664,12 +664,15 @@ static long dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
664 | 664 | ||
665 | static void dsp_write_flush(void) | 665 | static void dsp_write_flush(void) |
666 | { | 666 | { |
667 | int timeout = get_play_delay_jiffies(dev.DAPF.len); | ||
668 | |||
667 | if (!(dev.mode & FMODE_WRITE) || !test_bit(F_WRITING, &dev.flags)) | 669 | if (!(dev.mode & FMODE_WRITE) || !test_bit(F_WRITING, &dev.flags)) |
668 | return; | 670 | return; |
669 | set_bit(F_WRITEFLUSH, &dev.flags); | 671 | set_bit(F_WRITEFLUSH, &dev.flags); |
670 | interruptible_sleep_on_timeout( | 672 | wait_event_interruptible_timeout( |
671 | &dev.writeflush, | 673 | dev.writeflush, |
672 | get_play_delay_jiffies(dev.DAPF.len)); | 674 | !test_bit(F_WRITEFLUSH, &dev.flags), |
675 | timeout); | ||
673 | clear_bit(F_WRITEFLUSH, &dev.flags); | 676 | clear_bit(F_WRITEFLUSH, &dev.flags); |
674 | if (!signal_pending(current)) { | 677 | if (!signal_pending(current)) { |
675 | current->state = TASK_INTERRUPTIBLE; | 678 | current->state = TASK_INTERRUPTIBLE; |
@@ -897,6 +900,7 @@ static int dsp_read(char __user *buf, size_t len) | |||
897 | { | 900 | { |
898 | int count = len; | 901 | int count = len; |
899 | char *page = (char *)__get_free_page(GFP_KERNEL); | 902 | char *page = (char *)__get_free_page(GFP_KERNEL); |
903 | int timeout = get_rec_delay_jiffies(DAR_BUFF_SIZE); | ||
900 | 904 | ||
901 | if (!page) | 905 | if (!page) |
902 | return -ENOMEM; | 906 | return -ENOMEM; |
@@ -936,11 +940,11 @@ static int dsp_read(char __user *buf, size_t len) | |||
936 | 940 | ||
937 | if (count > 0) { | 941 | if (count > 0) { |
938 | set_bit(F_READBLOCK, &dev.flags); | 942 | set_bit(F_READBLOCK, &dev.flags); |
939 | if (!interruptible_sleep_on_timeout( | 943 | if (wait_event_interruptible_timeout( |
940 | &dev.readblock, | 944 | dev.readblock, |
941 | get_rec_delay_jiffies(DAR_BUFF_SIZE))) | 945 | test_bit(F_READBLOCK, &dev.flags), |
946 | timeout) <= 0) | ||
942 | clear_bit(F_READING, &dev.flags); | 947 | clear_bit(F_READING, &dev.flags); |
943 | clear_bit(F_READBLOCK, &dev.flags); | ||
944 | if (signal_pending(current)) { | 948 | if (signal_pending(current)) { |
945 | free_page((unsigned long)page); | 949 | free_page((unsigned long)page); |
946 | return -EINTR; | 950 | return -EINTR; |
@@ -955,6 +959,7 @@ static int dsp_write(const char __user *buf, size_t len) | |||
955 | { | 959 | { |
956 | int count = len; | 960 | int count = len; |
957 | char *page = (char *)__get_free_page(GFP_KERNEL); | 961 | char *page = (char *)__get_free_page(GFP_KERNEL); |
962 | int timeout = get_play_delay_jiffies(DAP_BUFF_SIZE); | ||
958 | 963 | ||
959 | if (!page) | 964 | if (!page) |
960 | return -ENOMEM; | 965 | return -ENOMEM; |
@@ -995,10 +1000,10 @@ static int dsp_write(const char __user *buf, size_t len) | |||
995 | 1000 | ||
996 | if (count > 0) { | 1001 | if (count > 0) { |
997 | set_bit(F_WRITEBLOCK, &dev.flags); | 1002 | set_bit(F_WRITEBLOCK, &dev.flags); |
998 | interruptible_sleep_on_timeout( | 1003 | wait_event_interruptible_timeout( |
999 | &dev.writeblock, | 1004 | dev.writeblock, |
1000 | get_play_delay_jiffies(DAP_BUFF_SIZE)); | 1005 | test_bit(F_WRITEBLOCK, &dev.flags), |
1001 | clear_bit(F_WRITEBLOCK, &dev.flags); | 1006 | timeout); |
1002 | if (signal_pending(current)) { | 1007 | if (signal_pending(current)) { |
1003 | free_page((unsigned long)page); | 1008 | free_page((unsigned long)page); |
1004 | return -EINTR; | 1009 | return -EINTR; |
@@ -1044,7 +1049,7 @@ static __inline__ void eval_dsp_msg(register WORD wMessage) | |||
1044 | clear_bit(F_WRITING, &dev.flags); | 1049 | clear_bit(F_WRITING, &dev.flags); |
1045 | } | 1050 | } |
1046 | 1051 | ||
1047 | if (test_bit(F_WRITEBLOCK, &dev.flags)) | 1052 | if (test_and_clear_bit(F_WRITEBLOCK, &dev.flags)) |
1048 | wake_up_interruptible(&dev.writeblock); | 1053 | wake_up_interruptible(&dev.writeblock); |
1049 | break; | 1054 | break; |
1050 | 1055 | ||
@@ -1055,7 +1060,7 @@ static __inline__ void eval_dsp_msg(register WORD wMessage) | |||
1055 | 1060 | ||
1056 | pack_DARQ_to_DARF(dev.last_recbank); | 1061 | pack_DARQ_to_DARF(dev.last_recbank); |
1057 | 1062 | ||
1058 | if (test_bit(F_READBLOCK, &dev.flags)) | 1063 | if (test_and_clear_bit(F_READBLOCK, &dev.flags)) |
1059 | wake_up_interruptible(&dev.readblock); | 1064 | wake_up_interruptible(&dev.readblock); |
1060 | break; | 1065 | break; |
1061 | 1066 | ||
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 4ff60a6427d9..9b9f7d385134 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "sound_config.h" | 19 | #include "sound_config.h" |
20 | 20 | ||
21 | #include "midi_ctrl.h" | 21 | #include "midi_ctrl.h" |
22 | #include "sleep.h" | ||
22 | 23 | ||
23 | static int sequencer_ok; | 24 | static int sequencer_ok; |
24 | static struct sound_timer_operations *tmr; | 25 | static struct sound_timer_operations *tmr; |
@@ -100,8 +101,7 @@ int sequencer_read(int dev, struct file *file, char __user *buf, int count) | |||
100 | return -EAGAIN; | 101 | return -EAGAIN; |
101 | } | 102 | } |
102 | 103 | ||
103 | interruptible_sleep_on_timeout(&midi_sleeper, | 104 | oss_broken_sleep_on(&midi_sleeper, pre_event_timeout); |
104 | pre_event_timeout); | ||
105 | spin_lock_irqsave(&lock,flags); | 105 | spin_lock_irqsave(&lock,flags); |
106 | if (!iqlen) | 106 | if (!iqlen) |
107 | { | 107 | { |
@@ -343,7 +343,7 @@ static int seq_queue(unsigned char *note, char nonblock) | |||
343 | /* | 343 | /* |
344 | * Sleep until there is enough space on the queue | 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 | if (qlen >= SEQ_MAX_QUEUE) | 348 | if (qlen >= SEQ_MAX_QUEUE) |
349 | { | 349 | { |
@@ -1122,8 +1122,7 @@ static void seq_drain_midi_queues(void) | |||
1122 | */ | 1122 | */ |
1123 | 1123 | ||
1124 | if (n) | 1124 | if (n) |
1125 | interruptible_sleep_on_timeout(&seq_sleeper, | 1125 | oss_broken_sleep_on(&seq_sleeper, HZ/10); |
1126 | HZ/10); | ||
1127 | } | 1126 | } |
1128 | } | 1127 | } |
1129 | 1128 | ||
@@ -1145,8 +1144,7 @@ void sequencer_release(int dev, struct file *file) | |||
1145 | while (!signal_pending(current) && qlen > 0) | 1144 | while (!signal_pending(current) && qlen > 0) |
1146 | { | 1145 | { |
1147 | seq_sync(); | 1146 | seq_sync(); |
1148 | interruptible_sleep_on_timeout(&seq_sleeper, | 1147 | oss_broken_sleep_on(&seq_sleeper, 3*HZ); |
1149 | 3*HZ); | ||
1150 | /* Extra delay */ | 1148 | /* Extra delay */ |
1151 | } | 1149 | } |
1152 | } | 1150 | } |
@@ -1201,7 +1199,7 @@ static int seq_sync(void) | |||
1201 | seq_startplay(); | 1199 | seq_startplay(); |
1202 | 1200 | ||
1203 | if (qlen > 0) | 1201 | if (qlen > 0) |
1204 | interruptible_sleep_on_timeout(&seq_sleeper, HZ); | 1202 | oss_broken_sleep_on(&seq_sleeper, HZ); |
1205 | return qlen; | 1203 | return qlen; |
1206 | } | 1204 | } |
1207 | 1205 | ||
@@ -1224,7 +1222,7 @@ static void midi_outc(int dev, unsigned char data) | |||
1224 | 1222 | ||
1225 | spin_lock_irqsave(&lock,flags); | 1223 | spin_lock_irqsave(&lock,flags); |
1226 | while (n && !midi_devs[dev]->outputc(dev, data)) { | 1224 | while (n && !midi_devs[dev]->outputc(dev, data)) { |
1227 | interruptible_sleep_on_timeout(&seq_sleeper, HZ/25); | 1225 | oss_broken_sleep_on(&seq_sleeper, HZ/25); |
1228 | n--; | 1226 | n--; |
1229 | } | 1227 | } |
1230 | spin_unlock_irqrestore(&lock,flags); | 1228 | spin_unlock_irqrestore(&lock,flags); |
diff --git a/sound/oss/sleep.h b/sound/oss/sleep.h new file mode 100644 index 000000000000..a20fc925a5ce --- /dev/null +++ b/sound/oss/sleep.h | |||
@@ -0,0 +1,18 @@ | |||
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 | } | ||
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c index 7d8803a00b79..f851fd0e199c 100644 --- a/sound/oss/swarm_cs4297a.c +++ b/sound/oss/swarm_cs4297a.c | |||
@@ -90,6 +90,8 @@ | |||
90 | #include <asm/sibyte/sb1250_mac.h> | 90 | #include <asm/sibyte/sb1250_mac.h> |
91 | #include <asm/sibyte/sb1250.h> | 91 | #include <asm/sibyte/sb1250.h> |
92 | 92 | ||
93 | #include "sleep.h" | ||
94 | |||
93 | struct cs4297a_state; | 95 | struct cs4297a_state; |
94 | 96 | ||
95 | static DEFINE_MUTEX(swarm_cs4297a_mutex); | 97 | static DEFINE_MUTEX(swarm_cs4297a_mutex); |
@@ -748,7 +750,7 @@ static int serdma_reg_access(struct cs4297a_state *s, u64 data) | |||
748 | /* Since a writer has the DSP open, we have to mux the | 750 | /* Since a writer has the DSP open, we have to mux the |
749 | request in */ | 751 | request in */ |
750 | s->reg_request = data; | 752 | s->reg_request = data; |
751 | interruptible_sleep_on(&s->dma_dac.reg_wait); | 753 | oss_broken_sleep_on(&s->dma_dac.reg_wait, MAX_SCHEDULE_TIMEOUT); |
752 | /* XXXKW how can I deal with the starvation case where | 754 | /* XXXKW how can I deal with the starvation case where |
753 | the opener isn't writing? */ | 755 | the opener isn't writing? */ |
754 | } else { | 756 | } else { |
@@ -790,7 +792,7 @@ static int cs4297a_read_ac97(struct cs4297a_state *s, u32 offset, | |||
790 | if (serdma_reg_access(s, (0xCLL << 60) | (1LL << 47) | ((u64)(offset & 0x7F) << 40))) | 792 | if (serdma_reg_access(s, (0xCLL << 60) | (1LL << 47) | ((u64)(offset & 0x7F) << 40))) |
791 | return -1; | 793 | return -1; |
792 | 794 | ||
793 | interruptible_sleep_on(&s->dma_adc.reg_wait); | 795 | oss_broken_sleep_on(&s->dma_adc.reg_wait, MAX_SCHEDULE_TIMEOUT); |
794 | *value = s->read_value; | 796 | *value = s->read_value; |
795 | CS_DBGOUT(CS_AC97, 2, | 797 | CS_DBGOUT(CS_AC97, 2, |
796 | printk(KERN_INFO "cs4297a: rdr reg %x -> %x\n", s->read_reg, s->read_value)); | 798 | printk(KERN_INFO "cs4297a: rdr reg %x -> %x\n", s->read_reg, s->read_value)); |
@@ -1740,7 +1742,7 @@ static ssize_t cs4297a_read(struct file *file, char *buffer, size_t count, | |||
1740 | start_adc(s); | 1742 | start_adc(s); |
1741 | if (file->f_flags & O_NONBLOCK) | 1743 | if (file->f_flags & O_NONBLOCK) |
1742 | return ret ? ret : -EAGAIN; | 1744 | return ret ? ret : -EAGAIN; |
1743 | interruptible_sleep_on(&s->dma_adc.wait); | 1745 | oss_broken_sleep_on(&s->dma_adc.wait, MAX_SCHEDULE_TIMEOUT); |
1744 | if (signal_pending(current)) | 1746 | if (signal_pending(current)) |
1745 | return ret ? ret : -ERESTARTSYS; | 1747 | return ret ? ret : -ERESTARTSYS; |
1746 | continue; | 1748 | continue; |
@@ -1836,7 +1838,7 @@ static ssize_t cs4297a_write(struct file *file, const char *buffer, | |||
1836 | start_dac(s); | 1838 | start_dac(s); |
1837 | if (file->f_flags & O_NONBLOCK) | 1839 | if (file->f_flags & O_NONBLOCK) |
1838 | return ret ? ret : -EAGAIN; | 1840 | return ret ? ret : -EAGAIN; |
1839 | interruptible_sleep_on(&d->wait); | 1841 | oss_broken_sleep_on(&d->wait, MAX_SCHEDULE_TIMEOUT); |
1840 | if (signal_pending(current)) | 1842 | if (signal_pending(current)) |
1841 | return ret ? ret : -ERESTARTSYS; | 1843 | return ret ? ret : -ERESTARTSYS; |
1842 | continue; | 1844 | continue; |
@@ -2452,7 +2454,7 @@ static int cs4297a_locked_open(struct inode *inode, struct file *file) | |||
2452 | return -EBUSY; | 2454 | return -EBUSY; |
2453 | } | 2455 | } |
2454 | mutex_unlock(&s->open_sem_dac); | 2456 | mutex_unlock(&s->open_sem_dac); |
2455 | interruptible_sleep_on(&s->open_wait_dac); | 2457 | oss_broken_sleep_on(&s->open_wait_dac, MAX_SCHEDULE_TIMEOUT); |
2456 | 2458 | ||
2457 | if (signal_pending(current)) { | 2459 | if (signal_pending(current)) { |
2458 | printk("open - sig pending\n"); | 2460 | printk("open - sig pending\n"); |
@@ -2469,7 +2471,7 @@ static int cs4297a_locked_open(struct inode *inode, struct file *file) | |||
2469 | return -EBUSY; | 2471 | return -EBUSY; |
2470 | } | 2472 | } |
2471 | mutex_unlock(&s->open_sem_adc); | 2473 | mutex_unlock(&s->open_sem_adc); |
2472 | interruptible_sleep_on(&s->open_wait_adc); | 2474 | oss_broken_sleep_on(&s->open_wait_adc, MAX_SCHEDULE_TIMEOUT); |
2473 | 2475 | ||
2474 | if (signal_pending(current)) { | 2476 | if (signal_pending(current)) { |
2475 | printk("open - sig pending\n"); | 2477 | printk("open - sig pending\n"); |
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 4bbcc0fcd4eb..a077e9c69a5e 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c | |||
@@ -2921,6 +2921,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2921 | vwsnd_dev_t *devc; | 2921 | vwsnd_dev_t *devc; |
2922 | int minor = iminor(inode); | 2922 | int minor = iminor(inode); |
2923 | int sw_samplefmt; | 2923 | int sw_samplefmt; |
2924 | DEFINE_WAIT(wait); | ||
2924 | 2925 | ||
2925 | DBGE("(inode=0x%p, file=0x%p)\n", inode, file); | 2926 | DBGE("(inode=0x%p, file=0x%p)\n", inode, file); |
2926 | 2927 | ||
@@ -2937,21 +2938,26 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) | |||
2937 | } | 2938 | } |
2938 | 2939 | ||
2939 | mutex_lock(&devc->open_mutex); | 2940 | mutex_lock(&devc->open_mutex); |
2940 | while (devc->open_mode & file->f_mode) { | 2941 | while (1) { |
2942 | prepare_to_wait(&devc->open_wait, &wait, TASK_INTERRUPTIBLE); | ||
2943 | if (!(devc->open_mode & file->f_mode)) | ||
2944 | break; | ||
2945 | |||
2941 | mutex_unlock(&devc->open_mutex); | 2946 | mutex_unlock(&devc->open_mutex); |
2947 | mutex_unlock(&vwsnd_mutex); | ||
2942 | if (file->f_flags & O_NONBLOCK) { | 2948 | if (file->f_flags & O_NONBLOCK) { |
2943 | DEC_USE_COUNT; | 2949 | DEC_USE_COUNT; |
2944 | mutex_unlock(&vwsnd_mutex); | ||
2945 | return -EBUSY; | 2950 | return -EBUSY; |
2946 | } | 2951 | } |
2947 | interruptible_sleep_on(&devc->open_wait); | 2952 | schedule(); |
2948 | if (signal_pending(current)) { | 2953 | if (signal_pending(current)) { |
2949 | DEC_USE_COUNT; | 2954 | DEC_USE_COUNT; |
2950 | mutex_unlock(&vwsnd_mutex); | ||
2951 | return -ERESTARTSYS; | 2955 | return -ERESTARTSYS; |
2952 | } | 2956 | } |
2957 | mutex_lock(&vwsnd_mutex); | ||
2953 | mutex_lock(&devc->open_mutex); | 2958 | mutex_lock(&devc->open_mutex); |
2954 | } | 2959 | } |
2960 | finish_wait(&devc->open_wait, &wait); | ||
2955 | devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); | 2961 | devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); |
2956 | mutex_unlock(&devc->open_mutex); | 2962 | mutex_unlock(&devc->open_mutex); |
2957 | 2963 | ||