Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / sound / oss / ymfpci.c
index 13bcc76..bf90c12 100644 (file)
@@ -99,7 +99,7 @@ static void ymfpci_disable_dsp(ymfpci_t *unit);
 static void ymfpci_download_image(ymfpci_t *codec);
 static void ymf_memload(ymfpci_t *unit);
 
-static spinlock_t ymf_devs_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(ymf_devs_lock);
 static LIST_HEAD(ymf_devs);
 
 /*
@@ -107,14 +107,15 @@ static LIST_HEAD(ymf_devs);
  */
 
 static struct pci_device_id ymf_id_tbl[] = {
-#define DEV(v, d, data) \
-  { PCI_VENDOR_ID_##v, PCI_DEVICE_ID_##v##_##d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)data }
-       DEV (YAMAHA, 724,  "YMF724"),
-       DEV (YAMAHA, 724F, "YMF724F"),
-       DEV (YAMAHA, 740,  "YMF740"),
-       DEV (YAMAHA, 740C, "YMF740C"),
-       DEV (YAMAHA, 744,  "YMF744"),
-       DEV (YAMAHA, 754,  "YMF754"),
+#define DEV(dev, data) \
+       { PCI_VENDOR_ID_YAMAHA, dev, PCI_ANY_ID, PCI_ANY_ID, 0, 0, \
+               (unsigned long)data }
+       DEV (PCI_DEVICE_ID_YAMAHA_724,  "YMF724"),
+       DEV (PCI_DEVICE_ID_YAMAHA_724F, "YMF724F"),
+       DEV (PCI_DEVICE_ID_YAMAHA_740,  "YMF740"),
+       DEV (PCI_DEVICE_ID_YAMAHA_740C, "YMF740C"),
+       DEV (PCI_DEVICE_ID_YAMAHA_744,  "YMF744"),
+       DEV (PCI_DEVICE_ID_YAMAHA_754,  "YMF754"),
 #undef DEV
        { }
 };
@@ -124,11 +125,6 @@ MODULE_DEVICE_TABLE(pci, ymf_id_tbl);
  *  common I/O routines
  */
 
-static inline u8 ymfpci_readb(ymfpci_t *codec, u32 offset)
-{
-       return readb(codec->reg_area_virt + offset);
-}
-
 static inline void ymfpci_writeb(ymfpci_t *codec, u32 offset, u8 val)
 {
        writeb(val, codec->reg_area_virt + offset);
@@ -334,7 +330,7 @@ static int alloc_dmabuf(ymfpci_t *unit, struct ymf_dmabuf *dmabuf)
        dmabuf->dma_addr = dma_addr;
        dmabuf->buforder = order;
 
-       /* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+       /* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
        mapend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
        for (map = virt_to_page(rawbuf); map <= mapend; map++)
                set_bit(PG_reserved, &map->flags);
@@ -1545,7 +1541,8 @@ static int ymf_mmap(struct file *file, struct vm_area_struct *vma)
        size = vma->vm_end - vma->vm_start;
        if (size > (PAGE_SIZE << dmabuf->buforder))
                return -EINVAL;
-       if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+       if (remap_pfn_range(vma, vma->vm_start,
+                            virt_to_phys(dmabuf->rawbuf) >> PAGE_SHIFT,
                             size, vma->vm_page_prot))
                return -EAGAIN;
        dmabuf->mapped = 1;
@@ -1921,10 +1918,10 @@ static int ymf_open(struct inode *inode, struct file *file)
        if (unit == NULL)
                return -ENODEV;
 
-       down(&unit->open_sem);
+       mutex_lock(&unit->open_mutex);
 
        if ((state = ymf_state_alloc(unit)) == NULL) {
-               up(&unit->open_sem);
+               mutex_unlock(&unit->open_mutex);
                return -ENOMEM;
        }
        list_add_tail(&state->chain, &unit->states);
@@ -1959,7 +1956,7 @@ static int ymf_open(struct inode *inode, struct file *file)
        ymfpci_writeb(unit, YDSXGR_TIMERCTRL,
            (YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN));
 #endif
-       up(&unit->open_sem);
+       mutex_unlock(&unit->open_mutex);
 
        return nonseekable_open(inode, file);
 
@@ -1977,7 +1974,7 @@ out_nodma:
        list_del(&state->chain);
        kfree(state);
 
-       up(&unit->open_sem);
+       mutex_unlock(&unit->open_mutex);
        return err;
 }
 
@@ -1990,7 +1987,7 @@ static int ymf_release(struct inode *inode, struct file *file)
        ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0);
 #endif
 
-       down(&unit->open_sem);
+       mutex_lock(&unit->open_mutex);
 
        /*
         * XXX Solve the case of O_NONBLOCK close - don't deallocate here.
@@ -2007,7 +2004,7 @@ static int ymf_release(struct inode *inode, struct file *file)
        file->private_data = NULL;      /* Can you tell I programmed Solaris */
        kfree(state);
 
-       up(&unit->open_sem);
+       mutex_unlock(&unit->open_mutex);
 
        return 0;
 }
@@ -2078,7 +2075,7 @@ static /*const*/ struct file_operations ymf_mixer_fops = {
 /*
  */
 
-static int ymf_suspend(struct pci_dev *pcidev, u32 unused)
+static int ymf_suspend(struct pci_dev *pcidev, pm_message_t unused)
 {
        struct ymf_unit *unit = pci_get_drvdata(pcidev);
        unsigned long flags;
@@ -2503,8 +2500,8 @@ static int ymf_ac97_init(ymfpci_t *unit, int num_ac97)
 # ifdef MODULE
 static int mpu_io;
 static int synth_io;
-MODULE_PARM(mpu_io, "i");
-MODULE_PARM(synth_io, "i");
+module_param(mpu_io, int, 0);
+module_param(synth_io, int, 0);
 # else
 static int mpu_io     = 0x330;
 static int synth_io   = 0x388;
@@ -2535,7 +2532,7 @@ static int __devinit ymf_probe_one(struct pci_dev *pcidev, const struct pci_devi
        spin_lock_init(&codec->reg_lock);
        spin_lock_init(&codec->voice_lock);
        spin_lock_init(&codec->ac97_lock);
-       init_MUTEX(&codec->open_sem);
+       mutex_init(&codec->open_mutex);
        INIT_LIST_HEAD(&codec->states);
        codec->pci = pcidev;
 
@@ -2683,7 +2680,7 @@ static struct pci_driver ymfpci_driver = {
 
 static int __init ymf_init_module(void)
 {
-       return pci_module_init(&ymfpci_driver);
+       return pci_register_driver(&ymfpci_driver);
 }
 
 static void __exit ymf_cleanup_module (void)