fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / ide / pci / cs5530.c
index 7544904..9bf5fdf 100644 (file)
@@ -14,7 +14,6 @@
  *     CS5530 documentation available from National Semiconductor.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
-#include "cs5530.h"
-
-#if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-
-static u8 cs5530_proc = 0;
-
-static struct pci_dev *bmide_dev;
-
-static int cs5530_get_info (char *buffer, char **addr, off_t offset, int count)
-{
-       char *p = buffer;
-       unsigned long bibma = pci_resource_start(bmide_dev, 4);
-       u8  c0 = 0, c1 = 0;
-
-       /*
-        * at that point bibma+0x2 et bibma+0xa are byte registers
-        * to investigate:
-        */
-
-       c0 = inb_p((u16)bibma + 0x02);
-       c1 = inb_p((u16)bibma + 0x0a);
-
-       p += sprintf(p, "\n                                "
-                       "Cyrix 5530 Chipset.\n");
-       p += sprintf(p, "--------------- Primary Channel "
-                       "---------------- Secondary Channel "
-                       "-------------\n");
-       p += sprintf(p, "                %sabled "
-                       "                        %sabled\n",
-                       (c0&0x80) ? "dis" : " en",
-                       (c1&0x80) ? "dis" : " en");
-       p += sprintf(p, "--------------- drive0 --------- drive1 "
-                       "-------- drive0 ---------- drive1 ------\n");
-       p += sprintf(p, "DMA enabled:    %s              %s "
-                       "            %s               %s\n",
-                       (c0&0x20) ? "yes" : "no ",
-                       (c0&0x40) ? "yes" : "no ",
-                       (c1&0x20) ? "yes" : "no ",
-                       (c1&0x40) ? "yes" : "no " );
-
-       p += sprintf(p, "UDMA\n");
-       p += sprintf(p, "DMA\n");
-       p += sprintf(p, "PIO\n");
-
-       return p-buffer;
-}
-#endif /* DISPLAY_CS5530_TIMINGS && CONFIG_PROC_FS */
-
 /**
  *     cs5530_xfer_set_mode    -       set a new transfer mode at the drive
  *     @drive: drive to tune
@@ -267,37 +216,29 @@ static int cs5530_config_dma (ide_drive_t *drive)
  *     Initialize the cs5530 bridge for reliable IDE DMA operation.
  */
 
-static unsigned int __init init_chipset_cs5530 (struct pci_dev *dev, const char *name)
+static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name)
 {
        struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
        unsigned long flags;
 
-#if defined(DISPLAY_CS5530_TIMINGS) && defined(CONFIG_PROC_FS)
-       if (!cs5530_proc) {
-               cs5530_proc = 1;
-               bmide_dev = dev;
-               ide_pci_create_host_proc("cs5530", cs5530_get_info);
-       }
-#endif /* DISPLAY_CS5530_TIMINGS && CONFIG_PROC_FS */
-
        dev = NULL;
-       while ((dev = pci_find_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) {
+       while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) {
                switch (dev->device) {
                        case PCI_DEVICE_ID_CYRIX_PCI_MASTER:
-                               master_0 = dev;
+                               master_0 = pci_dev_get(dev);
                                break;
                        case PCI_DEVICE_ID_CYRIX_5530_LEGACY:
-                               cs5530_0 = dev;
+                               cs5530_0 = pci_dev_get(dev);
                                break;
                }
        }
        if (!master_0) {
                printk(KERN_ERR "%s: unable to locate PCI MASTER function\n", name);
-               return 0;
+               goto out;
        }
        if (!cs5530_0) {
                printk(KERN_ERR "%s: unable to locate CS5530 LEGACY function\n", name);
-               return 0;
+               goto out;
        }
 
        spin_lock_irqsave(&ide_lock, flags);
@@ -355,6 +296,9 @@ static unsigned int __init init_chipset_cs5530 (struct pci_dev *dev, const char
 
        spin_unlock_irqrestore(&ide_lock, flags);
 
+out:
+       pci_dev_put(master_0);
+       pci_dev_put(cs5530_0);
        return 0;
 }
 
@@ -366,7 +310,7 @@ static unsigned int __init init_chipset_cs5530 (struct pci_dev *dev, const char
  *     performs channel-specific pre-initialization before drive probing.
  */
 
-static void __init init_hwif_cs5530 (ide_hwif_t *hwif)
+static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
 {
        unsigned long basereg;
        u32 d0_timings;
@@ -404,13 +348,18 @@ static void __init init_hwif_cs5530 (ide_hwif_t *hwif)
        hwif->drives[1].autodma = hwif->autodma;
 }
 
+static ide_pci_device_t cs5530_chipset __devinitdata = {
+       .name           = "CS5530",
+       .init_chipset   = init_chipset_cs5530,
+       .init_hwif      = init_hwif_cs5530,
+       .channels       = 2,
+       .autodma        = AUTODMA,
+       .bootable       = ON_BOARD,
+};
+
 static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-       ide_pci_device_t *d = &cs5530_chipsets[id->driver_data];
-       if (dev->device != d->device)
-               BUG();
-       ide_setup_pci_device(dev, d);
-       return 0;
+       return ide_setup_pci_device(dev, &cs5530_chipset);
 }
 
 static struct pci_device_id cs5530_pci_tbl[] = {
@@ -425,7 +374,7 @@ static struct pci_driver driver = {
        .probe          = cs5530_init_one,
 };
 
-static int cs5530_ide_init(void)
+static int __init cs5530_ide_init(void)
 {
        return ide_pci_register_driver(&driver);
 }