linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / sound / oss / cmpci.c
index ea51aaf..7cfbb08 100644 (file)
 #endif
 #ifdef CONFIG_SOUND_CMPCI_JOYSTICK
 #include <linux/gameport.h>
-#include <linux/mutex.h>
-
 #endif
 
 /* --------------------------------------------------------------------- */
@@ -394,7 +392,7 @@ struct cm_state {
        unsigned char fmt, enable;
 
        spinlock_t lock;
-       struct mutex open_mutex;
+       struct semaphore open_sem;
        mode_t open_mode;
        wait_queue_head_t open_wait;
 
@@ -1713,7 +1711,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 = hweight32(val);
+               i = generic_hweight32(val);
                for (j = i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
                        if (!(val & (1 << i)))
                                continue;
@@ -2827,21 +2825,21 @@ static int cm_open(struct inode *inode, struct file *file)
                VALIDATE_STATE(s);
        file->private_data = s;
        /* wait for device to become free */
-       mutex_lock(&s->open_mutex);
+       down(&s->open_sem);
        while (s->open_mode & file->f_mode) {
                if (file->f_flags & O_NONBLOCK) {
-                       mutex_unlock(&s->open_mutex);
+                       up(&s->open_sem);
                        return -EBUSY;
                }
                add_wait_queue(&s->open_wait, &wait);
                __set_current_state(TASK_INTERRUPTIBLE);
-               mutex_unlock(&s->open_mutex);
+               up(&s->open_sem);
                schedule();
                remove_wait_queue(&s->open_wait, &wait);
                set_current_state(TASK_RUNNING);
                if (signal_pending(current))
                        return -ERESTARTSYS;
-               mutex_lock(&s->open_mutex);
+               down(&s->open_sem);
        }
        if (file->f_mode & FMODE_READ) {
                s->status &= ~DO_BIGENDIAN_R;
@@ -2869,7 +2867,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);
-       mutex_unlock(&s->open_mutex);
+       up(&s->open_sem);
        return nonseekable_open(inode, file);
 }
 
@@ -2881,7 +2879,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);
-       mutex_lock(&s->open_mutex);
+       down(&s->open_sem);
        if (file->f_mode & FMODE_WRITE) {
                stop_dac(s);
 
@@ -2905,7 +2903,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));
-       mutex_unlock(&s->open_mutex);
+       up(&s->open_sem);
        wake_up(&s->open_wait);
        unlock_kernel();
        return 0;
@@ -3082,7 +3080,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);
-       mutex_init(&s->open_mutex);
+       init_MUTEX(&s->open_sem);
        spin_lock_init(&s->lock);
        s->magic = CM_MAGIC;
        s->dev = pcidev;
@@ -3122,7 +3120,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id
        wrmixer(s, DSP_MIX_DATARESETIDX, 0);
 
        /* request irq */
-       if ((ret = request_irq(s->irq, cm_interrupt, IRQF_SHARED, "cmpci", s))) {
+       if ((ret = request_irq(s->irq, cm_interrupt, SA_SHIRQ, "cmpci", s))) {
                printk(KERN_ERR "cmpci: irq %u in use\n", s->irq);
                goto err_irq;
        }