Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / sound / oss / forte.c
index c7e23fc..ea1c020 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;
                }
@@ -1265,7 +1265,7 @@ forte_dsp_open (struct inode *inode, struct file *file)
        if (file->f_mode & FMODE_READ)
                forte_channel_init (forte, &forte->rec);
 
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 
@@ -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;
@@ -1438,9 +1439,6 @@ forte_dsp_write (struct file *file, const char __user *buffer, size_t bytes,
        unsigned int i = bytes, sz = 0;
        unsigned long flags;
 
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-
        if (!access_ok (VERIFY_READ, buffer, bytes))
                return -EFAULT;
 
@@ -1546,9 +1544,6 @@ forte_dsp_read (struct file *file, char __user *buffer, size_t bytes,
        unsigned int i = bytes, sz;
        unsigned long flags;
 
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
-
        if (!access_ok (VERIFY_WRITE, buffer, bytes))
                return -EFAULT;
 
@@ -1847,15 +1842,15 @@ forte_proc_read (char *page, char **start, off_t off, int count,
 static int __init 
 forte_proc_init (void)
 {
-       if (!proc_mkdir ("driver/forte", 0))
+       if (!proc_mkdir ("driver/forte", NULL))
                return -EIO;
 
-       if (!create_proc_read_entry ("driver/forte/chip", 0, 0, forte_proc_read, forte)) {
+       if (!create_proc_read_entry ("driver/forte/chip", 0, NULL, forte_proc_read, forte)) {
                remove_proc_entry ("driver/forte", NULL);
                return -EIO;
        }
 
-       if (!create_proc_read_entry("driver/forte/ac97", 0, 0, ac97_read_proc, forte->ac97)) {
+       if (!create_proc_read_entry("driver/forte/ac97", 0, NULL, ac97_read_proc, forte->ac97)) {
                remove_proc_entry ("driver/forte/chip", NULL);
                remove_proc_entry ("driver/forte", NULL);
                return -EIO;
@@ -2017,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);
 
@@ -2031,7 +2026,7 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
        chip->iobase = pci_resource_start (pci_dev, 0);
        chip->irq = pci_dev->irq;
 
-       if (request_irq (chip->irq, forte_interrupt, SA_SHIRQ, DRIVER_NAME,
+       if (request_irq (chip->irq, forte_interrupt, IRQF_SHARED, DRIVER_NAME,
                         chip)) {
                printk (KERN_WARNING PFX "Unable to reserve IRQ");
                ret = -EIO;
@@ -2040,8 +2035,9 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
        
        pci_set_drvdata (pci_dev, chip);
 
-       printk (KERN_INFO PFX "FM801 chip found at 0x%04lX-0x%04lX IRQ %u\n", 
-               chip->iobase, pci_resource_end (pci_dev, 0), chip->irq);
+       printk (KERN_INFO PFX "FM801 chip found at 0x%04lX-0x%16llX IRQ %u\n",
+               chip->iobase, (unsigned long long)pci_resource_end (pci_dev, 0),
+               chip->irq);
 
        /* Power it up */
        if ((ret = forte_chip_init (chip)) == 0)
@@ -2118,12 +2114,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);
 }