aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss/soundcard.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-25 11:32:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-25 11:32:05 -0400
commit33081adf8b89d5a716d7e1c60171768d39795b39 (patch)
tree275de58bbbb5f7ddffcdc087844cfc7fbe4315be /sound/oss/soundcard.c
parentc55960499f810357a29659b32d6ea594abee9237 (diff)
parent506ecbca71d07fa327dd986be1682e90885678ee (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (365 commits) ALSA: hda - Disable sticky PCM stream assignment for AD codecs ALSA: usb - Creative USB X-Fi volume knob support ALSA: ca0106: Use card specific dac id for mute controls. ALSA: ca0106: Allow different sound cards to use different SPI channel mappings. ALSA: ca0106: Create a nice spot for mapping channels to dacs. ALSA: ca0106: Move enabling of front dac out of hardcoded setup sequence. ALSA: ca0106: Pull out dac powering routine into separate function. ALSA: ca0106 - add Sound Blaster 5.1vx info. ASoC: tlv320dac33: Use usleep_range for delays ALSA: usb-audio: add Novation Launchpad support ALSA: hda - Add workarounds for CT-IBG controllers ALSA: hda - Fix wrong TLV mute bit for STAC/IDT codecs ASoC: tpa6130a2: Error handling for broken chip ASoC: max98088: Staticise m98088_eq_band ASoC: soc-core: Fix codec->name memory leak ALSA: hda - Apply ideapad quirk to Acer laptops with Cxt5066 ALSA: hda - Add some workarounds for Creative IBG ALSA: hda - Fix wrong SPDIF NID assignment for CA0110 ALSA: hda - Fix codec rename rules for ALC662-compatible codecs ALSA: hda - Add alc_init_jacks() call to other codecs ...
Diffstat (limited to 'sound/oss/soundcard.c')
-rw-r--r--sound/oss/soundcard.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 07f803e6d203..46c0d03dbecc 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -40,7 +40,7 @@
40#include <linux/major.h> 40#include <linux/major.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/proc_fs.h> 42#include <linux/proc_fs.h>
43#include <linux/smp_lock.h> 43#include <linux/mutex.h>
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/device.h> 46#include <linux/device.h>
@@ -56,6 +56,7 @@
56 * Table for permanently allocated memory (used when unloading the module) 56 * Table for permanently allocated memory (used when unloading the module)
57 */ 57 */
58void * sound_mem_blocks[MAX_MEM_BLOCKS]; 58void * sound_mem_blocks[MAX_MEM_BLOCKS];
59static DEFINE_MUTEX(soundcard_mutex);
59int sound_nblocks = 0; 60int sound_nblocks = 0;
60 61
61/* Persistent DMA buffers */ 62/* Persistent DMA buffers */
@@ -151,7 +152,7 @@ static ssize_t sound_read(struct file *file, char __user *buf, size_t count, lof
151 * big one anyway, we might as well bandage here.. 152 * big one anyway, we might as well bandage here..
152 */ 153 */
153 154
154 lock_kernel(); 155 mutex_lock(&soundcard_mutex);
155 156
156 DEB(printk("sound_read(dev=%d, count=%d)\n", dev, count)); 157 DEB(printk("sound_read(dev=%d, count=%d)\n", dev, count));
157 switch (dev & 0x0f) { 158 switch (dev & 0x0f) {
@@ -169,7 +170,7 @@ static ssize_t sound_read(struct file *file, char __user *buf, size_t count, lof
169 case SND_DEV_MIDIN: 170 case SND_DEV_MIDIN:
170 ret = MIDIbuf_read(dev, file, buf, count); 171 ret = MIDIbuf_read(dev, file, buf, count);
171 } 172 }
172 unlock_kernel(); 173 mutex_unlock(&soundcard_mutex);
173 return ret; 174 return ret;
174} 175}
175 176
@@ -178,7 +179,7 @@ static ssize_t sound_write(struct file *file, const char __user *buf, size_t cou
178 int dev = iminor(file->f_path.dentry->d_inode); 179 int dev = iminor(file->f_path.dentry->d_inode);
179 int ret = -EINVAL; 180 int ret = -EINVAL;
180 181
181 lock_kernel(); 182 mutex_lock(&soundcard_mutex);
182 DEB(printk("sound_write(dev=%d, count=%d)\n", dev, count)); 183 DEB(printk("sound_write(dev=%d, count=%d)\n", dev, count));
183 switch (dev & 0x0f) { 184 switch (dev & 0x0f) {
184 case SND_DEV_SEQ: 185 case SND_DEV_SEQ:
@@ -196,7 +197,7 @@ static ssize_t sound_write(struct file *file, const char __user *buf, size_t cou
196 ret = MIDIbuf_write(dev, file, buf, count); 197 ret = MIDIbuf_write(dev, file, buf, count);
197 break; 198 break;
198 } 199 }
199 unlock_kernel(); 200 mutex_unlock(&soundcard_mutex);
200 return ret; 201 return ret;
201} 202}
202 203
@@ -210,7 +211,7 @@ static int sound_open(struct inode *inode, struct file *file)
210 printk(KERN_ERR "Invalid minor device %d\n", dev); 211 printk(KERN_ERR "Invalid minor device %d\n", dev);
211 return -ENXIO; 212 return -ENXIO;
212 } 213 }
213 lock_kernel(); 214 mutex_lock(&soundcard_mutex);
214 switch (dev & 0x0f) { 215 switch (dev & 0x0f) {
215 case SND_DEV_CTL: 216 case SND_DEV_CTL:
216 dev >>= 4; 217 dev >>= 4;
@@ -247,15 +248,15 @@ static int sound_open(struct inode *inode, struct file *file)
247 retval = -ENXIO; 248 retval = -ENXIO;
248 } 249 }
249 250
250 unlock_kernel(); 251 mutex_unlock(&soundcard_mutex);
251 return 0; 252 return retval;
252} 253}
253 254
254static int sound_release(struct inode *inode, struct file *file) 255static int sound_release(struct inode *inode, struct file *file)
255{ 256{
256 int dev = iminor(inode); 257 int dev = iminor(inode);
257 258
258 lock_kernel(); 259 mutex_lock(&soundcard_mutex);
259 DEB(printk("sound_release(dev=%d)\n", dev)); 260 DEB(printk("sound_release(dev=%d)\n", dev));
260 switch (dev & 0x0f) { 261 switch (dev & 0x0f) {
261 case SND_DEV_CTL: 262 case SND_DEV_CTL:
@@ -280,7 +281,7 @@ static int sound_release(struct inode *inode, struct file *file)
280 default: 281 default:
281 printk(KERN_ERR "Sound error: Releasing unknown device 0x%02x\n", dev); 282 printk(KERN_ERR "Sound error: Releasing unknown device 0x%02x\n", dev);
282 } 283 }
283 unlock_kernel(); 284 mutex_unlock(&soundcard_mutex);
284 285
285 return 0; 286 return 0;
286} 287}
@@ -354,7 +355,7 @@ static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
354 if (cmd == OSS_GETVERSION) 355 if (cmd == OSS_GETVERSION)
355 return __put_user(SOUND_VERSION, (int __user *)p); 356 return __put_user(SOUND_VERSION, (int __user *)p);
356 357
357 lock_kernel(); 358 mutex_lock(&soundcard_mutex);
358 if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 && /* Mixer ioctl */ 359 if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 && /* Mixer ioctl */
359 (dev & 0x0f) != SND_DEV_CTL) { 360 (dev & 0x0f) != SND_DEV_CTL) {
360 dtype = dev & 0x0f; 361 dtype = dev & 0x0f;
@@ -369,7 +370,7 @@ static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
369 ret = sound_mixer_ioctl(dev >> 4, cmd, p); 370 ret = sound_mixer_ioctl(dev >> 4, cmd, p);
370 break; 371 break;
371 } 372 }
372 unlock_kernel(); 373 mutex_unlock(&soundcard_mutex);
373 return ret; 374 return ret;
374 } 375 }
375 376
@@ -399,7 +400,7 @@ static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
399 break; 400 break;
400 401
401 } 402 }
402 unlock_kernel(); 403 mutex_unlock(&soundcard_mutex);
403 return ret; 404 return ret;
404} 405}
405 406
@@ -439,35 +440,35 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma)
439 printk(KERN_ERR "Sound: mmap() not supported for other than audio devices\n"); 440 printk(KERN_ERR "Sound: mmap() not supported for other than audio devices\n");
440 return -EINVAL; 441 return -EINVAL;
441 } 442 }
442 lock_kernel(); 443 mutex_lock(&soundcard_mutex);
443 if (vma->vm_flags & VM_WRITE) /* Map write and read/write to the output buf */ 444 if (vma->vm_flags & VM_WRITE) /* Map write and read/write to the output buf */
444 dmap = audio_devs[dev]->dmap_out; 445 dmap = audio_devs[dev]->dmap_out;
445 else if (vma->vm_flags & VM_READ) 446 else if (vma->vm_flags & VM_READ)
446 dmap = audio_devs[dev]->dmap_in; 447 dmap = audio_devs[dev]->dmap_in;
447 else { 448 else {
448 printk(KERN_ERR "Sound: Undefined mmap() access\n"); 449 printk(KERN_ERR "Sound: Undefined mmap() access\n");
449 unlock_kernel(); 450 mutex_unlock(&soundcard_mutex);
450 return -EINVAL; 451 return -EINVAL;
451 } 452 }
452 453
453 if (dmap == NULL) { 454 if (dmap == NULL) {
454 printk(KERN_ERR "Sound: mmap() error. dmap == NULL\n"); 455 printk(KERN_ERR "Sound: mmap() error. dmap == NULL\n");
455 unlock_kernel(); 456 mutex_unlock(&soundcard_mutex);
456 return -EIO; 457 return -EIO;
457 } 458 }
458 if (dmap->raw_buf == NULL) { 459 if (dmap->raw_buf == NULL) {
459 printk(KERN_ERR "Sound: mmap() called when raw_buf == NULL\n"); 460 printk(KERN_ERR "Sound: mmap() called when raw_buf == NULL\n");
460 unlock_kernel(); 461 mutex_unlock(&soundcard_mutex);
461 return -EIO; 462 return -EIO;
462 } 463 }
463 if (dmap->mapping_flags) { 464 if (dmap->mapping_flags) {
464 printk(KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n"); 465 printk(KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n");
465 unlock_kernel(); 466 mutex_unlock(&soundcard_mutex);
466 return -EIO; 467 return -EIO;
467 } 468 }
468 if (vma->vm_pgoff != 0) { 469 if (vma->vm_pgoff != 0) {
469 printk(KERN_ERR "Sound: mmap() offset must be 0.\n"); 470 printk(KERN_ERR "Sound: mmap() offset must be 0.\n");
470 unlock_kernel(); 471 mutex_unlock(&soundcard_mutex);
471 return -EINVAL; 472 return -EINVAL;
472 } 473 }
473 size = vma->vm_end - vma->vm_start; 474 size = vma->vm_end - vma->vm_start;
@@ -478,7 +479,7 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma)
478 if (remap_pfn_range(vma, vma->vm_start, 479 if (remap_pfn_range(vma, vma->vm_start,
479 virt_to_phys(dmap->raw_buf) >> PAGE_SHIFT, 480 virt_to_phys(dmap->raw_buf) >> PAGE_SHIFT,
480 vma->vm_end - vma->vm_start, vma->vm_page_prot)) { 481 vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
481 unlock_kernel(); 482 mutex_unlock(&soundcard_mutex);
482 return -EAGAIN; 483 return -EAGAIN;
483 } 484 }
484 485
@@ -490,7 +491,7 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma)
490 memset(dmap->raw_buf, 491 memset(dmap->raw_buf,
491 dmap->neutral_byte, 492 dmap->neutral_byte,
492 dmap->bytes_in_use); 493 dmap->bytes_in_use);
493 unlock_kernel(); 494 mutex_unlock(&soundcard_mutex);
494 return 0; 495 return 0;
495} 496}
496 497