diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2000-07-15 03:32:22 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2000-07-15 03:32:22 +0000 |
commit | f1da2c3860e301527d56a1ef0b56c649ee7c4b1b (patch) | |
tree | 562b5d2e8b9cb62eb983d78ff6bcf9789e08fcf6 /drivers/sound | |
parent | 00f11569ac8ca73cbcdef8822de1583e79aee571 (diff) |
Merge with Linux 2.4.0-test5-pre1. This works again on Origin UP.
The IP22 cache bugs which are plaguing some machines are still unfixed.
Diffstat (limited to 'drivers/sound')
-rw-r--r-- | drivers/sound/cmpci.c | 29 | ||||
-rw-r--r-- | drivers/sound/dmasound/dmasound_core.c | 7 | ||||
-rw-r--r-- | drivers/sound/emu10k1/audio.c | 12 | ||||
-rw-r--r-- | drivers/sound/emu10k1/midi.c | 7 | ||||
-rw-r--r-- | drivers/sound/es1370.c | 49 | ||||
-rw-r--r-- | drivers/sound/es1371.c | 49 | ||||
-rw-r--r-- | drivers/sound/esssolo1.c | 29 | ||||
-rw-r--r-- | drivers/sound/i810_audio.c | 26 | ||||
-rw-r--r-- | drivers/sound/maestro.c | 26 | ||||
-rw-r--r-- | drivers/sound/msnd.h | 11 | ||||
-rw-r--r-- | drivers/sound/msnd_pinnacle.c | 72 | ||||
-rw-r--r-- | drivers/sound/sonicvibes.c | 29 | ||||
-rw-r--r-- | drivers/sound/soundcard.c | 13 | ||||
-rw-r--r-- | drivers/sound/trident.c | 34 | ||||
-rw-r--r-- | drivers/sound/via82cxxx_audio.c | 3 | ||||
-rw-r--r-- | drivers/sound/vwsnd.c | 37 | ||||
-rw-r--r-- | drivers/sound/wavfront.c | 3 |
17 files changed, 256 insertions, 180 deletions
diff --git a/drivers/sound/cmpci.c b/drivers/sound/cmpci.c index 3b5639054..cc55d508e 100644 --- a/drivers/sound/cmpci.c +++ b/drivers/sound/cmpci.c @@ -114,6 +114,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <asm/hardirq.h> @@ -1397,29 +1398,35 @@ static int cm_mmap(struct file *file, struct vm_area_struct *vma) { struct cm_state *s = (struct cm_state *)file->private_data; struct dmabuf *db; - int ret; + int ret = -EINVAL; unsigned long size; VALIDATE_STATE(s); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf(s, 1)) != 0) - return ret; + goto out; db = &s->dma_dac; } else if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf(s, 0)) != 0) - return ret; + goto out; db = &s->dma_adc; } else - return -EINVAL; + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << db->buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; db->mapped = 1; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int cm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -1771,6 +1778,7 @@ static int cm_release(struct inode *inode, struct file *file) struct cm_state *s = (struct cm_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); @@ -1785,6 +1793,7 @@ static int cm_release(struct inode *inode, struct file *file) s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } @@ -2021,6 +2030,7 @@ static int cm_midi_release(struct inode *inode, struct file *file) VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) { __set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&s->midi.owait, &wait); @@ -2058,6 +2068,7 @@ static int cm_midi_release(struct inode *inode, struct file *file) spin_unlock_irqrestore(&s->lock, flags); up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } @@ -2212,6 +2223,7 @@ static int cm_dmfm_release(struct inode *inode, struct file *file) unsigned int regb; VALIDATE_STATE(s); + lock_kernel(); down(&s->open_sem); s->open_mode &= ~FMODE_DMFM; for (regb = 0xb0; regb < 0xb9; regb++) { @@ -2222,6 +2234,7 @@ static int cm_dmfm_release(struct inode *inode, struct file *file) } up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } diff --git a/drivers/sound/dmasound/dmasound_core.c b/drivers/sound/dmasound/dmasound_core.c index da60c783b..1d8804b36 100644 --- a/drivers/sound/dmasound/dmasound_core.c +++ b/drivers/sound/dmasound/dmasound_core.c @@ -111,6 +111,7 @@ #include <linux/sound.h> #include <linux/init.h> #include <linux/soundcard.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> @@ -501,8 +502,10 @@ static int mixer_open(struct inode *inode, struct file *file) static int mixer_release(struct inode *inode, struct file *file) { + lock_kernel(); mixer.busy = 0; dmasound.mach.release(); + unlock_kernel(); return 0; } static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd, @@ -905,6 +908,7 @@ static int sq_release(struct inode *inode, struct file *file) { int rc = 0; + lock_kernel(); if (write_sq.busy) rc = sq_fsync(file, file->f_dentry); dmasound.soft = dmasound.dsp; @@ -923,6 +927,7 @@ static int sq_release(struct inode *inode, struct file *file) /* Wake up a process waiting for the queue being released. * Note: There may be several processes waiting for a call * to open() returning. */ + unlock_kernel(); return rc; } @@ -1141,8 +1146,10 @@ static int state_open(struct inode *inode, struct file *file) static int state_release(struct inode *inode, struct file *file) { + lock_kernel(); state.busy = 0; dmasound.mach.release(); + unlock_kernel(); return 0; } diff --git a/drivers/sound/emu10k1/audio.c b/drivers/sound/emu10k1/audio.c index 06f84dfc3..9e2ee24d1 100644 --- a/drivers/sound/emu10k1/audio.c +++ b/drivers/sound/emu10k1/audio.c @@ -36,6 +36,8 @@ #include "cardwi.h" #include "recmgr.h" #include "audio.h" +#include <linux/sched.h> +#include <linux/smp_lock.h> static void calculate_ofrag(struct woinst *); static void calculate_ifrag(struct wiinst *); @@ -890,6 +892,7 @@ static int emu10k1_audio_mmap(struct file *file, struct vm_area_struct *vma) if (vma_get_pgoff(vma) != 0) return -ENXIO; + lock_kernel(); if (vma->vm_flags & VM_WRITE) { struct woinst *woinst = wave_dev->woinst; struct wave_out *wave_out; @@ -907,6 +910,7 @@ static int emu10k1_audio_mmap(struct file *file, struct vm_area_struct *vma) if (emu10k1_waveout_open(wave_dev) != CTSTATUS_SUCCESS) { spin_unlock_irqrestore(&woinst->lock, flags); ERROR(); + unlock_kernel(); return -EINVAL; } @@ -921,12 +925,14 @@ static int emu10k1_audio_mmap(struct file *file, struct vm_area_struct *vma) if (size > (PAGE_SIZE * wave_out->wavexferbuf->numpages)) { spin_unlock_irqrestore(&woinst->lock, flags); + unlock_kernel(); return -EINVAL; } for (i = 0; i < wave_out->wavexferbuf->numpages; i++) { if (remap_page_range(vma->vm_start + (i * PAGE_SIZE), virt_to_phys(wave_out->pagetable[i]), PAGE_SIZE, vma->vm_page_prot)) { spin_unlock_irqrestore(&woinst->lock, flags); + unlock_kernel(); return -EAGAIN; } } @@ -944,6 +950,7 @@ static int emu10k1_audio_mmap(struct file *file, struct vm_area_struct *vma) wiinst->mapped = 1; spin_unlock_irqrestore(&wiinst->lock, flags); } + unlock_kernel(); return 0; } @@ -1098,9 +1105,11 @@ static int emu10k1_audio_open(struct inode *inode, struct file *file) static int emu10k1_audio_release(struct inode *inode, struct file *file) { struct emu10k1_wavedevice *wave_dev = (struct emu10k1_wavedevice *) file->private_data; - struct emu10k1_card *card = wave_dev->card; + struct emu10k1_card *card; unsigned long flags; + lock_kernel(); + card = wave_dev->card; DPF(2, "emu10k1_audio_release()\n"); if (file->f_mode & FMODE_WRITE) { @@ -1171,6 +1180,7 @@ static int emu10k1_audio_release(struct inode *inode, struct file *file) kfree(wave_dev); wake_up_interruptible(&card->open_wait); + unlock_kernel(); return 0; } diff --git a/drivers/sound/emu10k1/midi.c b/drivers/sound/emu10k1/midi.c index 04b1424a8..d7e0a4a87 100644 --- a/drivers/sound/emu10k1/midi.c +++ b/drivers/sound/emu10k1/midi.c @@ -32,6 +32,8 @@ #define __NO_VERSION__ #include <linux/module.h> +#include <linux/sched.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include "hwaccess.h" @@ -183,8 +185,10 @@ static int emu10k1_midi_open(struct inode *inode, struct file *file) static int emu10k1_midi_release(struct inode *inode, struct file *file) { struct emu10k1_mididevice *midi_dev = (struct emu10k1_mididevice *) file->private_data; - struct emu10k1_card *card = midi_dev->card; + struct emu10k1_card *card; + lock_kernel(); + card = midi_dev->card; DPF(2, "emu10k1_midi_release()\n"); if (file->f_mode & FMODE_WRITE) { @@ -227,6 +231,7 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file) card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE)); up(&card->open_sem); wake_up_interruptible(&card->open_wait); + unlock_kernel(); return 0; } diff --git a/drivers/sound/es1370.c b/drivers/sound/es1370.c index 47d1d875f..ae004f10f 100644 --- a/drivers/sound/es1370.c +++ b/drivers/sound/es1370.c @@ -149,6 +149,7 @@ #include <linux/malloc.h> #include <linux/soundcard.h> #include <linux/pci.h> +#include <linux/smp_lock.h> #include <asm/io.h> #include <asm/dma.h> #include <linux/init.h> @@ -1306,24 +1307,38 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma) unsigned long size; VALIDATE_STATE(s); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { - if ((ret = prog_dmabuf_dac2(s)) != 0) + if ((ret = prog_dmabuf_dac2(s)) != 0) { + unlock_kernel(); return ret; + } db = &s->dma_dac2; } else if (vma->vm_flags & VM_READ) { - if ((ret = prog_dmabuf_adc(s)) != 0) + if ((ret = prog_dmabuf_adc(s)) != 0) { + unlock_kernel(); return ret; + } db = &s->dma_adc; - } else + } else { + unlock_kernel(); return -EINVAL; - if (vma->vm_pgoff != 0) + } + if (vma->vm_pgoff != 0) { + unlock_kernel(); return -EINVAL; + } size = vma->vm_end - vma->vm_start; - if (size > (PAGE_SIZE << db->buforder)) + if (size > (PAGE_SIZE << db->buforder)) { + unlock_kernel(); return -EINVAL; - if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) + } + if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) { + unlock_kernel(); return -EAGAIN; + } db->mapped = 1; + unlock_kernel(); return 0; } @@ -1717,6 +1732,7 @@ static int es1370_release(struct inode *inode, struct file *file) struct es1370_state *s = (struct es1370_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac2(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); @@ -1733,6 +1749,7 @@ static int es1370_release(struct inode *inode, struct file *file) wake_up(&s->open_wait); up(&s->open_sem); return 0; + unlock_kernel(); } static /*const*/ struct file_operations es1370_audio_fops = { @@ -1850,17 +1867,23 @@ static int es1370_mmap_dac(struct file *file, struct vm_area_struct *vma) VALIDATE_STATE(s); if (!(vma->vm_flags & VM_WRITE)) return -EINVAL; + lock_kernel(); if ((ret = prog_dmabuf_dac1(s)) != 0) - return ret; + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << s->dma_dac1.buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; s->dma_dac1.mapped = 1; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int es1370_ioctl_dac(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -2122,6 +2145,7 @@ static int es1370_release_dac(struct inode *inode, struct file *file) struct es1370_state *s = (struct es1370_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); drain_dac1(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); stop_dac1(s); @@ -2129,6 +2153,7 @@ static int es1370_release_dac(struct inode *inode, struct file *file) s->open_mode &= ~FMODE_DAC; wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } @@ -2366,6 +2391,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file) VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) { add_wait_queue(&s->midi.owait, &wait); for (;;) { @@ -2399,6 +2425,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file) spin_unlock_irqrestore(&s->lock, flags); wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } diff --git a/drivers/sound/es1371.c b/drivers/sound/es1371.c index 109ac71c0..58d7923ab 100644 --- a/drivers/sound/es1371.c +++ b/drivers/sound/es1371.c @@ -121,6 +121,7 @@ #include <linux/bitops.h> #include <linux/proc_fs.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <linux/ac97_codec.h> #include <asm/io.h> #include <asm/dma.h> @@ -1494,24 +1495,38 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma) unsigned long size; VALIDATE_STATE(s); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { - if ((ret = prog_dmabuf_dac2(s)) != 0) + if ((ret = prog_dmabuf_dac2(s)) != 0) { + unlock_kernel(); return ret; + } db = &s->dma_dac2; } else if (vma->vm_flags & VM_READ) { - if ((ret = prog_dmabuf_adc(s)) != 0) + if ((ret = prog_dmabuf_adc(s)) != 0) { + unlock_kernel(); return ret; + } db = &s->dma_adc; - } else + } else { + unlock_kernel(); return -EINVAL; - if (vma->vm_pgoff != 0) + } + if (vma->vm_pgoff != 0) { + unlock_kernel(); return -EINVAL; + } size = vma->vm_end - vma->vm_start; - if (size > (PAGE_SIZE << db->buforder)) + if (size > (PAGE_SIZE << db->buforder)) { + unlock_kernel(); return -EINVAL; - if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) + } + if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) { + unlock_kernel(); return -EAGAIN; + } db->mapped = 1; + unlock_kernel(); return 0; } @@ -1903,6 +1918,7 @@ static int es1371_release(struct inode *inode, struct file *file) struct es1371_state *s = (struct es1371_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac2(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); @@ -1917,6 +1933,7 @@ static int es1371_release(struct inode *inode, struct file *file) s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } @@ -2035,17 +2052,23 @@ static int es1371_mmap_dac(struct file *file, struct vm_area_struct *vma) VALIDATE_STATE(s); if (!(vma->vm_flags & VM_WRITE)) return -EINVAL; + lock_kernel(); if ((ret = prog_dmabuf_dac1(s)) != 0) - return ret; + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << s->dma_dac1.buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; s->dma_dac1.mapped = 1; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int es1371_ioctl_dac(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -2297,6 +2320,7 @@ static int es1371_release_dac(struct inode *inode, struct file *file) struct es1371_state *s = (struct es1371_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); drain_dac1(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); stop_dac1(s); @@ -2304,6 +2328,7 @@ static int es1371_release_dac(struct inode *inode, struct file *file) s->open_mode &= ~FMODE_DAC; up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } @@ -2540,6 +2565,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file) unsigned count, tmo; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) { add_wait_queue(&s->midi.owait, &wait); for (;;) { @@ -2573,6 +2599,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file) spin_unlock_irqrestore(&s->lock, flags); up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } diff --git a/drivers/sound/esssolo1.c b/drivers/sound/esssolo1.c index cfc89d3ee..e2e0c3b12 100644 --- a/drivers/sound/esssolo1.c +++ b/drivers/sound/esssolo1.c @@ -90,6 +90,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <asm/hardirq.h> @@ -1192,29 +1193,35 @@ static int solo1_mmap(struct file *file, struct vm_area_struct *vma) { struct solo1_state *s = (struct solo1_state *)file->private_data; struct dmabuf *db; - int ret; + int ret = -EINVAL; unsigned long size; VALIDATE_STATE(s); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf_dac(s)) != 0) - return ret; + goto out; db = &s->dma_dac; } else if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf_adc(s)) != 0) - return ret; + goto out; db = &s->dma_adc; } else - return -EINVAL; + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << db->buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; db->mapped = 1; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int solo1_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -1510,6 +1517,7 @@ static int solo1_release(struct inode *inode, struct file *file) struct solo1_state *s = (struct solo1_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); @@ -1527,6 +1535,7 @@ static int solo1_release(struct inode *inode, struct file *file) s->open_mode &= ~(FMODE_READ | FMODE_WRITE); wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } @@ -1881,6 +1890,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file) VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) { add_wait_queue(&s->midi.owait, &wait); for (;;) { @@ -1914,6 +1924,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file) spin_unlock_irqrestore(&s->lock, flags); wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } @@ -2083,6 +2094,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file) unsigned int regb; VALIDATE_STATE(s); + lock_kernel(); down(&s->open_sem); s->open_mode &= ~FMODE_DMFM; for (regb = 0xb0; regb < 0xb9; regb++) { @@ -2094,6 +2106,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file) release_region(s->sbbase, FMSYNTH_EXTENT); wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } diff --git a/drivers/sound/i810_audio.c b/drivers/sound/i810_audio.c index f04636a65..792f670af 100644 --- a/drivers/sound/i810_audio.c +++ b/drivers/sound/i810_audio.c @@ -76,6 +76,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <linux/ac97_codec.h> #include <asm/uaccess.h> #include <asm/hardirq.h> @@ -1227,29 +1228,34 @@ static int i810_mmap(struct file *file, struct vm_area_struct *vma) { struct i810_state *state = (struct i810_state *)file->private_data; struct dmabuf *dmabuf = &state->dmabuf; - int ret; + int ret = -EINVAL; unsigned long size; + lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf(state, 0)) != 0) - return ret; + goto out; } else if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf(state, 1)) != 0) - return ret; + goto out; } else - return -EINVAL; + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << dmabuf->buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(dmabuf->rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; dmabuf->mapped = 1; - - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int i810_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -1608,6 +1614,7 @@ static int i810_release(struct inode *inode, struct file *file) struct i810_state *state = (struct i810_state *)file->private_data; struct dmabuf *dmabuf = &state->dmabuf; + lock_kernel(); if (file->f_mode & FMODE_WRITE) { i810_clear_tail(state); drain_dac(state, file->f_flags & O_NONBLOCK); @@ -1632,6 +1639,7 @@ static int i810_release(struct inode *inode, struct file *file) kfree(state->card->states[state->virt]); state->card->states[state->virt] = NULL; + unlock_kernel(); return 0; } diff --git a/drivers/sound/maestro.c b/drivers/sound/maestro.c index cd5a2bc27..cc54f784c 100644 --- a/drivers/sound/maestro.c +++ b/drivers/sound/maestro.c @@ -197,6 +197,8 @@ #include <linux/version.h> #include <linux/module.h> +#include <linux/sched.h> +#include <linux/smp_lock.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) @@ -2422,13 +2424,14 @@ static int ess_mmap(struct file *file, struct vm_area_struct *vma) { struct ess_state *s = (struct ess_state *)file->private_data; struct dmabuf *db; - int ret; + int ret = -EINVAL; unsigned long size; VALIDATE_STATE(s); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf(s, 1)) != 0) - return ret; + goto out; db = &s->dma_dac; } else #if 0 @@ -2436,20 +2439,25 @@ static int ess_mmap(struct file *file, struct vm_area_struct *vma) we can turn this back on. */ if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf(s, 0)) != 0) - return ret; + goto out; db = &s->dma_adc; } else #endif - return -EINVAL; + goto out; + ret = -EINVAL; if (SILLY_OFFSET(vma) != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << db->buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; db->mapped = 1; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int ess_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -2985,6 +2993,7 @@ ess_release(struct inode *inode, struct file *file) struct ess_state *s = (struct ess_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); @@ -3006,6 +3015,7 @@ ess_release(struct inode *inode, struct file *file) } up(&s->open_sem); wake_up(&s->open_wait); + unlock_kernel(); return 0; } diff --git a/drivers/sound/msnd.h b/drivers/sound/msnd.h index 219a6bfe0..7b361921e 100644 --- a/drivers/sound/msnd.h +++ b/drivers/sound/msnd.h @@ -160,13 +160,6 @@ # define inb inb_p #endif -#ifdef LINUX20 -# define __initfunc(f) f -# define __initdata /* nothing */ -# define spin_lock_irqsave(junk,flags) do { save_flags(flags); cli(); } while (0) -# define spin_unlock_irqrestore(junk,flags) do { restore_flags(flags); } while (0) -#endif - /* JobQueueStruct */ #define JQS_wStart 0x00 #define JQS_wSize 0x02 @@ -236,9 +229,7 @@ typedef struct multisound_dev { wait_queue_head_t writeblock; wait_queue_head_t readblock; wait_queue_head_t writeflush; -#ifndef LINUX20 spinlock_t lock; -#endif int nresets; unsigned long recsrc; int left_levels[16]; @@ -250,8 +241,6 @@ typedef struct multisound_dev { int rec_sample_size, rec_sample_rate, rec_channels; int rec_ndelay; BYTE bCurrentMidiPatch; - void (*inc_ref)(void); - void (*dec_ref)(void); /* Digital audio FIFOs */ msnd_fifo DAPF, DARF; diff --git a/drivers/sound/msnd_pinnacle.c b/drivers/sound/msnd_pinnacle.c index b220433ce..91c7d2306 100644 --- a/drivers/sound/msnd_pinnacle.c +++ b/drivers/sound/msnd_pinnacle.c @@ -35,16 +35,12 @@ #include <linux/config.h> #include <linux/version.h> -#if LINUX_VERSION_CODE < 0x020101 -# define LINUX20 -#endif #include <linux/module.h> #include <linux/malloc.h> #include <linux/types.h> #include <linux/delay.h> -#ifndef LINUX20 -# include <linux/init.h> -#endif +#include <linux/init.h> +#include <linux/smp_lock.h> #include <asm/irq.h> #include <asm/io.h> #include "sound_config.h" @@ -747,16 +743,6 @@ static void set_default_audio_parameters(void) set_default_rec_audio_parameters(); } -static void mod_inc_ref(void) -{ - MOD_INC_USE_COUNT; -} - -static void mod_dec_ref(void) -{ - MOD_DEC_USE_COUNT; -} - static int dev_open(struct inode *inode, struct file *file) { int minor = MINOR(inode->i_rdev); @@ -789,43 +775,23 @@ static int dev_open(struct inode *inode, struct file *file) } else err = -EINVAL; - if (err >= 0) - mod_inc_ref(); - return err; } -#ifdef LINUX20 -static void dev_release(struct inode *inode, struct file *file) -#else static int dev_release(struct inode *inode, struct file *file) -#endif { int minor = MINOR(inode->i_rdev); -#ifndef LINUX20 int err = 0; -#endif - if (minor == dev.dsp_minor) { -#ifndef LINUX20 - err = -#endif - dsp_release(file); - } + lock_kernel(); + if (minor == dev.dsp_minor) + err = dsp_release(file); else if (minor == dev.mixer_minor) { /* nothing */ - } -#ifndef LINUX20 - else + } else err = -EINVAL; - - if (err >= 0) -#endif - mod_dec_ref(); - -#ifndef LINUX20 + unlock_kernel(); return err; -#endif } static __inline__ int pack_DARQ_to_DARF(register int bank) @@ -1002,30 +968,18 @@ static int dsp_write(const char *buf, size_t len) return len - count; } -#ifdef LINUX20 -static int dev_read(struct inode *inode, struct file *file, char *buf, int count) -{ - int minor = MINOR(inode->i_rdev); -#else static ssize_t dev_read(struct file *file, char *buf, size_t count, loff_t *off) { int minor = MINOR(file->f_dentry->d_inode->i_rdev); -#endif if (minor == dev.dsp_minor) return dsp_read(buf, count); else return -EINVAL; } -#ifdef LINUX20 -static int dev_write(struct inode *inode, struct file *file, const char *buf, int count) -{ - int minor = MINOR(inode->i_rdev); -#else static ssize_t dev_write(struct file *file, const char *buf, size_t count, loff_t *off) { int minor = MINOR(file->f_dentry->d_inode->i_rdev); -#endif if (minor == dev.dsp_minor) return dsp_write(buf, count); else @@ -1042,15 +996,8 @@ static __inline__ void eval_dsp_msg(register WORD wMessage) if (pack_DAPF_to_DAPQ(0) <= 0) { if (!test_bit(F_WRITEBLOCK, &dev.flags)) { -#ifdef LINUX20 - if (test_bit(F_WRITEFLUSH, &dev.flags)) { - clear_bit(F_WRITEFLUSH, &dev.flags); - wake_up_interruptible(&dev.writeflush); - } -#else if (test_and_clear_bit(F_WRITEFLUSH, &dev.flags)) wake_up_interruptible(&dev.writeflush); -#endif } clear_bit(F_WRITING, &dev.flags); } @@ -1122,6 +1069,7 @@ static void intr(int irq, void *dev_id, struct pt_regs *regs) } static struct file_operations dev_fileops = { + owner: THIS_MODULE, read: dev_read, write: dev_write, ioctl: dev_ioctl, @@ -1881,8 +1829,6 @@ int __init msnd_pinnacle_init(void) dev.recsrc = 0; dev.dspq_data_buff = DSPQ_DATA_BUFF; dev.dspq_buff_size = DSPQ_BUFF_SIZE; - dev.inc_ref = mod_inc_ref; - dev.dec_ref = mod_dec_ref; if (write_ndelay == -1) write_ndelay = CONFIG_MSND_WRITE_NDELAY; if (write_ndelay) @@ -1898,9 +1844,7 @@ int __init msnd_pinnacle_init(void) init_waitqueue_head(&dev.writeflush); msnd_fifo_init(&dev.DAPF); msnd_fifo_init(&dev.DARF); -#ifndef LINUX20 spin_lock_init(&dev.lock); -#endif printk(KERN_INFO LOGNAME ": %u byte audio FIFOs (x2)\n", dev.fifosize); if ((err = msnd_fifo_alloc(&dev.DAPF, dev.fifosize)) < 0) { printk(KERN_ERR LOGNAME ": Couldn't allocate write FIFO\n"); diff --git a/drivers/sound/sonicvibes.c b/drivers/sound/sonicvibes.c index c9c66a73f..8a082552a 100644 --- a/drivers/sound/sonicvibes.c +++ b/drivers/sound/sonicvibes.c @@ -108,6 +108,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <asm/uaccess.h> #include <asm/hardirq.h> @@ -1509,29 +1510,35 @@ static int sv_mmap(struct file *file, struct vm_area_struct *vma) { struct sv_state *s = (struct sv_state *)file->private_data; struct dmabuf *db; - int ret; + int ret = -EINVAL; unsigned long size; VALIDATE_STATE(s); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf(s, 1)) != 0) - return ret; + goto out; db = &s->dma_dac; } else if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf(s, 0)) != 0) - return ret; + goto out; db = &s->dma_adc; } else - return -EINVAL; + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << db->buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; db->mapped = 1; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int sv_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -1907,6 +1914,7 @@ static int sv_release(struct inode *inode, struct file *file) struct sv_state *s = (struct sv_state *)file->private_data; VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) drain_dac(s, file->f_flags & O_NONBLOCK); down(&s->open_sem); @@ -1921,6 +1929,7 @@ static int sv_release(struct inode *inode, struct file *file) s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE); wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } @@ -2167,6 +2176,7 @@ static int sv_midi_release(struct inode *inode, struct file *file) VALIDATE_STATE(s); + lock_kernel(); if (file->f_mode & FMODE_WRITE) { add_wait_queue(&s->midi.owait, &wait); for (;;) { @@ -2200,6 +2210,7 @@ static int sv_midi_release(struct inode *inode, struct file *file) spin_unlock_irqrestore(&s->lock, flags); wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } @@ -2363,6 +2374,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file) unsigned int regb; VALIDATE_STATE(s); + lock_kernel(); down(&s->open_sem); s->open_mode &= ~FMODE_DMFM; for (regb = 0xb0; regb < 0xb9; regb++) { @@ -2373,6 +2385,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file) } wake_up(&s->open_wait); up(&s->open_sem); + unlock_kernel(); return 0; } diff --git a/drivers/sound/soundcard.c b/drivers/sound/soundcard.c index 0351fe7ce..d56b8f77f 100644 --- a/drivers/sound/soundcard.c +++ b/drivers/sound/soundcard.c @@ -270,6 +270,7 @@ static int sound_release(struct inode *inode, struct file *file) { int dev = MINOR(inode->i_rdev); + lock_kernel(); DEB(printk("sound_release(dev=%d)\n", dev)); switch (dev & 0x0f) { case SND_DEV_CTL: @@ -297,6 +298,7 @@ static int sound_release(struct inode *inode, struct file *file) notifier_call_chain(&sound_locker, 0, 0); lock_depth--; + unlock_kernel(); return 0; } @@ -449,29 +451,35 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma) printk(KERN_ERR "Sound: mmap() not supported for other than audio devices\n"); return -EINVAL; } + lock_kernel(); if (vma->vm_flags & VM_WRITE) /* Map write and read/write to the output buf */ dmap = audio_devs[dev]->dmap_out; else if (vma->vm_flags & VM_READ) dmap = audio_devs[dev]->dmap_in; else { printk(KERN_ERR "Sound: Undefined mmap() access\n"); + unlock_kernel(); return -EINVAL; } if (dmap == NULL) { printk(KERN_ERR "Sound: mmap() error. dmap == NULL\n"); + unlock_kernel(); return -EIO; } if (dmap->raw_buf == NULL) { printk(KERN_ERR "Sound: mmap() called when raw_buf == NULL\n"); + unlock_kernel(); return -EIO; } if (dmap->mapping_flags) { printk(KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n"); + unlock_kernel(); return -EIO; } if (vma->vm_pgoff != 0) { printk(KERN_ERR "Sound: mmap() offset must be 0.\n"); + unlock_kernel(); return -EINVAL; } size = vma->vm_end - vma->vm_start; @@ -481,8 +489,10 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma) } if (remap_page_range(vma->vm_start, virt_to_phys(dmap->raw_buf), vma->vm_end - vma->vm_start, - vma->vm_page_prot)) + vma->vm_page_prot)) { + unlock_kernel(); return -EAGAIN; + } dmap->mapping_flags |= DMA_MAP_MAPPED; @@ -492,6 +502,7 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma) memset(dmap->raw_buf, dmap->neutral_byte, dmap->bytes_in_use); + unlock_kernel(); return 0; } diff --git a/drivers/sound/trident.c b/drivers/sound/trident.c index 6e2b70791..f19cb1740 100644 --- a/drivers/sound/trident.c +++ b/drivers/sound/trident.c @@ -107,6 +107,7 @@ #include <linux/init.h> #include <linux/poll.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <linux/ac97_codec.h> #include <asm/uaccess.h> #include <asm/hardirq.h> @@ -1560,30 +1561,35 @@ static int trident_mmap(struct file *file, struct vm_area_struct *vma) { struct trident_state *state = (struct trident_state *)file->private_data; struct dmabuf *dmabuf = &state->dmabuf; - int ret; + int ret = -EINVAL; unsigned long size; VALIDATE_STATE(state); + lock_kernel(); if (vma->vm_flags & VM_WRITE) { if ((ret = prog_dmabuf(state, 0)) != 0) - return ret; + goto out; } else if (vma->vm_flags & VM_READ) { if ((ret = prog_dmabuf(state, 1)) != 0) - return ret; - } else - return -EINVAL; + goto out; + } else + goto out; + ret = -EINVAL; if (vma->vm_pgoff != 0) - return -EINVAL; + goto out; size = vma->vm_end - vma->vm_start; if (size > (PAGE_SIZE << dmabuf->buforder)) - return -EINVAL; + goto out; + ret = -EAGAIN; if (remap_page_range(vma->vm_start, virt_to_phys(dmabuf->rawbuf), size, vma->vm_page_prot)) - return -EAGAIN; + goto out; dmabuf->mapped = 1; - - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int trident_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) @@ -2009,9 +2015,12 @@ static int trident_open(struct inode *inode, struct file *file) static int trident_release(struct inode *inode, struct file *file) { struct trident_state *state = (struct trident_state *)file->private_data; - struct trident_card *card = state->card; - struct dmabuf *dmabuf = &state->dmabuf; + struct trident_card *card; + struct dmabuf *dmabuf; + lock_kernel(); + card = state->card; + dmabuf = &state->dmabuf; VALIDATE_STATE(state); if (file->f_mode & FMODE_WRITE) { @@ -2038,6 +2047,7 @@ static int trident_release(struct inode *inode, struct file *file) /* we're covered by the open_sem */ up(&card->open_sem); + unlock_kernel(); return 0; } diff --git a/drivers/sound/via82cxxx_audio.c b/drivers/sound/via82cxxx_audio.c index ab14427d6..be3b1c9ca 100644 --- a/drivers/sound/via82cxxx_audio.c +++ b/drivers/sound/via82cxxx_audio.c @@ -30,6 +30,7 @@ #include <linux/poll.h> #include <linux/soundcard.h> #include <linux/ac97_codec.h> +#include <linux/smp_lock.h> #include <asm/io.h> #include <asm/delay.h> #include <asm/uaccess.h> @@ -2207,6 +2208,7 @@ static int via_dsp_release(struct inode *inode, struct file *file) card = file->private_data; assert (card != NULL); + lock_kernel(); if (file->f_mode & FMODE_READ) via_chan_free (card, &card->ch_in); @@ -2220,6 +2222,7 @@ static int via_dsp_release(struct inode *inode, struct file *file) spin_unlock_irqrestore (&card->lock, flags); wake_up (&card->open_wait); + unlock_kernel(); DPRINTK("EXIT, returning 0\n"); return 0; diff --git a/drivers/sound/vwsnd.c b/drivers/sound/vwsnd.c index 19cca5ee0..d46abd569 100644 --- a/drivers/sound/vwsnd.c +++ b/drivers/sound/vwsnd.c @@ -84,10 +84,9 @@ * Locking Notes * * INC_USE_COUNT and DEC_USE_COUNT keep track of the number of - * open descriptors to this driver. When the driver is compiled - * as a module, they call MOD_{INC,DEC}_USE_COUNT; otherwise they - * bump vwsnd_use_count. The global device list, vwsnd_dev_list, - * is immutable when the IN_USE is true. + * open descriptors to this driver. They store it in vwsnd_use_count. + * The global device list, vwsnd_dev_list, is immutable when the IN_USE + * is true. * * devc->open_lock is a semaphore that is used to enforce the * single reader/single writer rule for /dev/audio. The rule is @@ -141,6 +140,7 @@ #include <linux/module.h> #include <linux/stddef.h> #include <linux/spinlock.h> +#include <linux/smp_lock.h> #include <asm/fixmap.h> #include <asm/cobalt.h> #include <asm/semaphore.h> @@ -1517,22 +1517,12 @@ typedef struct vwsnd_dev { static vwsnd_dev_t *vwsnd_dev_list; /* linked list of all devices */ -#ifdef MODULE - -# define INC_USE_COUNT MOD_INC_USE_COUNT -# define DEC_USE_COUNT MOD_DEC_USE_COUNT -# define IN_USE MOD_IN_USE - -#else - static atomic_t vwsnd_use_count = ATOMIC_INIT(0); # define INC_USE_COUNT (atomic_inc(&vwsnd_use_count)) # define DEC_USE_COUNT (atomic_dec(&vwsnd_use_count)) # define IN_USE (atomic_read(&vwsnd_use_count) != 0) -#endif - /* * Lithium can only DMA multiples of 32 bytes. Its DMA buffer may * be up to 8 Kb. This driver always uses 8 Kb. @@ -2998,6 +2988,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) vwsnd_port_t *wport = NULL, *rport = NULL; int err = 0; + lock_kernel(); down(&devc->io_sema); { DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); @@ -3023,13 +3014,14 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file) } up(&devc->open_sema); wake_up(&devc->open_wait); - DBGDO(if (IN_USE)) /* see hack in vwsnd_mixer_release() */ - DEC_USE_COUNT; + DEC_USE_COUNT; DBGR(); + unlock_kernel(); return err; } static struct file_operations vwsnd_audio_fops = { + owner: THIS_MODULE, llseek: vwsnd_audio_llseek, read: vwsnd_audio_read, write: vwsnd_audio_write, @@ -3069,15 +3061,7 @@ static int vwsnd_mixer_open(struct inode *inode, struct file *file) static int vwsnd_mixer_release(struct inode *inode, struct file *file) { DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); - - /* - * hack -- opening/closing the mixer device zeroes use count - * so driver can be unloaded. - * Use only while debugging module, and then use it carefully. - */ - - DBGDO(while (IN_USE)) - DEC_USE_COUNT; + DEC_USE_COUNT; return 0; } @@ -3234,6 +3218,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, } static struct file_operations vwsnd_mixer_fops = { + owner: THIS_MODULE, llseek: vwsnd_mixer_llseek, ioctl: vwsnd_mixer_ioctl, open: vwsnd_mixer_open, @@ -3429,8 +3414,6 @@ static int unload_vwsnd(struct address_info *hw_config) DBGE("()\n"); - if (IN_USE) - return -EBUSY; devcp = &vwsnd_dev_list; while ((devc = *devcp)) { if (devc->audio_minor == hw_config->slots[0]) { diff --git a/drivers/sound/wavfront.c b/drivers/sound/wavfront.c index a8f826031..3fb7cce2e 100644 --- a/drivers/sound/wavfront.c +++ b/drivers/sound/wavfront.c @@ -67,6 +67,7 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/sched.h> +#include <linux/smp_lock.h> #include <linux/ptrace.h> #include <linux/fcntl.h> #include <linux/ioport.h> @@ -1959,8 +1960,10 @@ wavefront_open (struct inode *inode, struct file *file) static int wavefront_release(struct inode *inode, struct file *file) { + lock_kernel(); dev.opened = 0; dev.debug = 0; + unlock_kernel(); return 0; } |