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 / forte.c
index ac4bada..0294eec 100644 (file)
@@ -43,9 +43,9 @@
 #include <linux/interrupt.h>
 
 #include <linux/proc_fs.h>
+#include <linux/mutex.h>
 
 #include <asm/uaccess.h>
-#include <asm/hardirq.h>
 #include <asm/io.h>
 
 #define DRIVER_NAME    "forte"
@@ -186,7 +186,7 @@ struct forte_chip {
        unsigned long           iobase;
        int                     irq;
 
-       struct semaphore        open_sem;       /* Device access */
+       struct mutex            open_mutex;     /* Device access */
        spinlock_t              lock;           /* State */
 
        spinlock_t              ac97_lock;
@@ -239,7 +239,7 @@ forte_ac97_wait (struct forte_chip *chip)
  * @reg:       register to read
  */
 
-u16
+static u16
 forte_ac97_read (struct ac97_codec *codec, u8 reg)
 {
        u16 ret = 0;
@@ -284,7 +284,7 @@ forte_ac97_read (struct ac97_codec *codec, u8 reg)
  * @val:       value to write
  */
 
-void
+static void
 forte_ac97_write (struct ac97_codec *codec, u8 reg, u16 val)
 {
        struct forte_chip *chip = codec->private_data;
@@ -1243,13 +1243,13 @@ forte_dsp_open (struct inode *inode, struct file *file)
        struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */
 
        if (file->f_flags & O_NONBLOCK) {
-               if (down_trylock (&chip->open_sem)) {
+               if (!mutex_trylock(&chip->open_mutex)) {
                        DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__);
                        return -EAGAIN;
                }
        }
        else {
-               if (down_interruptible (&chip->open_sem)) {
+               if (mutex_lock_interruptible(&chip->open_mutex)) {
                        DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__);
                        return -ERESTARTSYS;
                }
@@ -1303,7 +1303,7 @@ forte_dsp_release (struct inode *inode, struct file *file)
                spin_unlock_irq (&chip->lock);
        }
 
-       up (&chip->open_sem);
+       mutex_unlock(&chip->open_mutex);
 
        return ret;
 }
@@ -1410,7 +1410,8 @@ forte_dsp_mmap (struct file *file, struct vm_area_struct *vma)
                 goto out;
        }
 
-        if (remap_page_range (vma, vma->vm_start, virt_to_phys (channel->buf),
+        if (remap_pfn_range(vma, vma->vm_start,
+                             virt_to_phys(channel->buf) >> PAGE_SHIFT,
                              size, vma->vm_page_prot)) {
                DPRINTK ("%s: remap el a no worko\n", __FUNCTION__);
                ret = -EAGAIN;
@@ -2011,7 +2012,7 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
        memset (chip, 0, sizeof (struct forte_chip));
        chip->pci_dev = pci_dev;
 
-       init_MUTEX(&chip->open_sem);
+       mutex_init(&chip->open_mutex);
        spin_lock_init (&chip->lock);
        spin_lock_init (&chip->ac97_lock);
 
@@ -2112,12 +2113,7 @@ forte_init_module (void)
 {
        printk (KERN_INFO PFX DRIVER_VERSION "\n");
 
-       if (!pci_register_driver (&forte_pci_driver)) {
-               pci_unregister_driver (&forte_pci_driver);
-               return -ENODEV;
-       }
-
-       return 0;
+       return pci_register_driver (&forte_pci_driver);
 }