Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / oss / cmpci.c
index 34720e6..de60a05 100644 (file)
 #include <linux/smp_lock.h>
 #include <linux/bitops.h>
 #include <linux/wait.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/io.h>
 #include <asm/page.h>
 #endif
 #ifdef CONFIG_SOUND_CMPCI_JOYSTICK
 #include <linux/gameport.h>
+#include <linux/mutex.h>
+
 #endif
 
 /* --------------------------------------------------------------------- */
@@ -391,7 +394,7 @@ struct cm_state {
        unsigned char fmt, enable;
 
        spinlock_t lock;
-       struct semaphore open_sem;
+       struct mutex open_mutex;
        mode_t open_mode;
        wait_queue_head_t open_wait;
 
@@ -1710,7 +1713,7 @@ static int mixer_ioctl(struct cm_state *s, unsigned int cmd, unsigned long arg)
        case SOUND_MIXER_RECSRC: /* Arg contains a bit for each recording source */
                if (get_user(val, p))
                        return -EFAULT;
-               i = generic_hweight32(val);
+               i = hweight32(val);
                for (j = i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
                        if (!(val & (1 << i)))
                                continue;
@@ -2824,21 +2827,21 @@ static int cm_open(struct inode *inode, struct file *file)
                VALIDATE_STATE(s);
        file->private_data = s;
        /* wait for device to become free */
-       down(&s->open_sem);
+       mutex_lock(&s->open_mutex);
        while (s->open_mode & file->f_mode) {
                if (file->f_flags & O_NONBLOCK) {
-                       up(&s->open_sem);
+                       mutex_unlock(&s->open_mutex);
                        return -EBUSY;
                }
                add_wait_queue(&s->open_wait, &wait);
                __set_current_state(TASK_INTERRUPTIBLE);
-               up(&s->open_sem);
+               mutex_unlock(&s->open_mutex);
                schedule();
                remove_wait_queue(&s->open_wait, &wait);
                set_current_state(TASK_RUNNING);
                if (signal_pending(current))
                        return -ERESTARTSYS;
-               down(&s->open_sem);
+               mutex_lock(&s->open_mutex);
        }
        if (file->f_mode & FMODE_READ) {
                s->status &= ~DO_BIGENDIAN_R;
@@ -2866,7 +2869,7 @@ static int cm_open(struct inode *inode, struct file *file)
        }
        set_fmt(s, fmtm, fmts);
        s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
-       up(&s->open_sem);
+       mutex_unlock(&s->open_mutex);
        return nonseekable_open(inode, file);
 }
 
@@ -2878,7 +2881,7 @@ static int cm_release(struct inode *inode, struct file *file)
        lock_kernel();
        if (file->f_mode & FMODE_WRITE)
                drain_dac(s, file->f_flags & O_NONBLOCK);
-       down(&s->open_sem);
+       mutex_lock(&s->open_mutex);
        if (file->f_mode & FMODE_WRITE) {
                stop_dac(s);
 
@@ -2902,7 +2905,7 @@ static int cm_release(struct inode *inode, struct file *file)
                s->status &= ~DO_BIGENDIAN_R;
        }
        s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
-       up(&s->open_sem);
+       mutex_unlock(&s->open_mutex);
        wake_up(&s->open_wait);
        unlock_kernel();
        return 0;
@@ -3058,7 +3061,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id
                return -ENODEV;
        if (pcidev->irq == 0)
                return -ENODEV;
-       i = pci_set_dma_mask(pcidev, 0xffffffff);
+       i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK);
        if (i) {
                printk(KERN_WARNING "cmpci: architecture does not support 32bit PCI busmaster DMA\n");
                return i;
@@ -3079,7 +3082,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id
        init_waitqueue_head(&s->dma_adc.wait);
        init_waitqueue_head(&s->dma_dac.wait);
        init_waitqueue_head(&s->open_wait);
-       init_MUTEX(&s->open_sem);
+       mutex_init(&s->open_mutex);
        spin_lock_init(&s->lock);
        s->magic = CM_MAGIC;
        s->dev = pcidev;
@@ -3365,7 +3368,7 @@ static struct pci_driver cm_driver = {
 static int __init init_cmpci(void)
 {
        printk(KERN_INFO "cmpci: version $Revision: 6.82 $ time " __TIME__ " " __DATE__ "\n");
-       return pci_module_init(&cm_driver);
+       return pci_register_driver(&cm_driver);
 }
 
 static void __exit cleanup_cmpci(void)