]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - sound/oss/soundcard.c
sound: sequencer: clean up remove bogus check
[linux-2.6.git] / sound / oss / soundcard.c
index 8fb8e7f995563993660243d2befd3502ca407b94..fde7c12fe5da9eac43384068c7c761b14cee193c 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/ctype.h>
 #include <linux/stddef.h>
 #include <linux/kmod.h>
+#include <linux/kernel.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <linux/wait.h>
@@ -43,6 +44,7 @@
 #include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/mm.h>
+#include <linux/device.h>
 
 /*
  * This ought to be moved into include/asm/dma.h
@@ -54,7 +56,7 @@
 /*
  * Table for permanently allocated memory (used when unloading the module)
  */
-void *          sound_mem_blocks[1024];
+void *          sound_mem_blocks[MAX_MEM_BLOCKS];
 int             sound_nblocks = 0;
 
 /* Persistent DMA buffers */
@@ -141,7 +143,7 @@ static int get_mixer_levels(void __user * arg)
 
 static ssize_t sound_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        int ret = -EINVAL;
 
        /*
@@ -174,7 +176,7 @@ static ssize_t sound_read(struct file *file, char __user *buf, size_t count, lof
 
 static ssize_t sound_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
        int ret = -EINVAL;
        
        lock_kernel();
@@ -326,11 +328,11 @@ static int sound_mixer_ioctl(int mixdev, unsigned int cmd, void __user *arg)
        return mixer_devs[mixdev]->ioctl(mixdev, cmd, arg);
 }
 
-static int sound_ioctl(struct inode *inode, struct file *file,
-                      unsigned int cmd, unsigned long arg)
+static long sound_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        int len = 0, dtype;
-       int dev = iminor(inode);
+       int dev = iminor(file->f_dentry->d_inode);
+       long ret = -EINVAL;
        void __user *p = (void __user *)arg;
 
        if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) {
@@ -351,6 +353,7 @@ static int sound_ioctl(struct inode *inode, struct file *file,
        if (cmd == OSS_GETVERSION)
                return __put_user(SOUND_VERSION, (int __user *)p);
        
+       lock_kernel();
        if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 &&   /* Mixer ioctl */
            (dev & 0x0f) != SND_DEV_CTL) {              
                dtype = dev & 0x0f;
@@ -358,24 +361,31 @@ static int sound_ioctl(struct inode *inode, struct file *file,
                case SND_DEV_DSP:
                case SND_DEV_DSP16:
                case SND_DEV_AUDIO:
-                       return sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev,
+                       ret = sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev,
                                                 cmd, p);
-                       
+                       break;                  
                default:
-                       return sound_mixer_ioctl(dev >> 4, cmd, p);
+                       ret = sound_mixer_ioctl(dev >> 4, cmd, p);
+                       break;
                }
+               unlock_kernel();
+               return ret;
        }
+
        switch (dev & 0x0f) {
        case SND_DEV_CTL:
                if (cmd == SOUND_MIXER_GETLEVELS)
-                       return get_mixer_levels(p);
-               if (cmd == SOUND_MIXER_SETLEVELS)
-                       return set_mixer_levels(p);
-               return sound_mixer_ioctl(dev >> 4, cmd, p);
+                       ret = get_mixer_levels(p);
+               else if (cmd == SOUND_MIXER_SETLEVELS)
+                       ret = set_mixer_levels(p);
+               else
+                       ret = sound_mixer_ioctl(dev >> 4, cmd, p);
+               break;
 
        case SND_DEV_SEQ:
        case SND_DEV_SEQ2:
-               return sequencer_ioctl(dev, file, cmd, p);
+               ret = sequencer_ioctl(dev, file, cmd, p);
+               break;
 
        case SND_DEV_DSP:
        case SND_DEV_DSP16:
@@ -388,12 +398,13 @@ static int sound_ioctl(struct inode *inode, struct file *file,
                break;
 
        }
-       return -EINVAL;
+       unlock_kernel();
+       return ret;
 }
 
 static unsigned int sound_poll(struct file *file, poll_table * wait)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int dev = iminor(inode);
 
        DEB(printk("sound_poll(dev=%d)\n", dev));
@@ -418,7 +429,7 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma)
        int dev_class;
        unsigned long size;
        struct dma_buffparms *dmap = NULL;
-       int dev = iminor(file->f_dentry->d_inode);
+       int dev = iminor(file->f_path.dentry->d_inode);
 
        dev_class = dev & 0x0f;
        dev >>= 4;
@@ -482,13 +493,13 @@ static int sound_mmap(struct file *file, struct vm_area_struct *vma)
        return 0;
 }
 
-struct file_operations oss_sound_fops = {
+const struct file_operations oss_sound_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = sound_read,
        .write          = sound_write,
        .poll           = sound_poll,
-       .ioctl          = sound_ioctl,
+       .unlocked_ioctl = sound_ioctl,
        .mmap           = sound_mmap,
        .open           = sound_open,
        .release        = sound_release,
@@ -557,9 +568,9 @@ static int __init oss_init(void)
        /* Protecting the innocent */
        sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
 
-       for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
+       for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
                device_create(sound_class, NULL,
-                             MKDEV(SOUND_MAJOR, dev_list[i].minor),
+                             MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL,
                              "%s", dev_list[i].name);
 
                if (!dev_list[i].num)
@@ -567,11 +578,12 @@ static int __init oss_init(void)
 
                for (j = 1; j < *dev_list[i].num; j++)
                        device_create(sound_class, NULL,
-                                     MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
-                                     "%s%d", dev_list[i].name, j);
+                                     MKDEV(SOUND_MAJOR,
+                                           dev_list[i].minor + (j*0x10)),
+                                     NULL, "%s%d", dev_list[i].name, j);
        }
 
-       if (sound_nblocks >= 1024)
+       if (sound_nblocks >= MAX_MEM_BLOCKS - 1)
                printk(KERN_ERR "Sound warning: Deallocation table was too small.\n");
        
        return 0;
@@ -581,7 +593,7 @@ static void __exit oss_cleanup(void)
 {
        int i, j;
 
-       for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
+       for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
                device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor));
                if (!dev_list[i].num)
                        continue;