]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/delkin_cb.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / delkin_cb.c
index 27e47fc97100248a05c6232f84eb7b717fee253d..b9e457996d0e2f36034f209772f0c58afa8f9a89 100644 (file)
  *  License.  See the file COPYING in the main directory of this archive for
  *  more details.
  */
-#include <linux/autoconf.h>
+
 #include <linux/types.h>
 #include <linux/module.h>
-#include <linux/mm.h>
-#include <linux/blkdev.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+
 #include <asm/io.h>
 
 /*
@@ -44,6 +43,10 @@ static const u8 setup[] = {
        0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
 };
 
+static const struct ide_port_ops delkin_cb_port_ops = {
+       .quirkproc              = ide_undecoded_slave,
+};
+
 static int __devinit
 delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
 {
@@ -52,6 +55,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
        ide_hwif_t *hwif = NULL;
        ide_drive_t *drive;
        int i, rc;
+       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
        rc = pci_enable_device(dev);
        if (rc) {
@@ -71,19 +75,29 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
                if (setup[i])
                        outb(setup[i], base + i);
        }
-       pci_release_regions(dev);       /* IDE layer handles regions itself */
 
        memset(&hw, 0, sizeof(hw));
        ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
        hw.irq = dev->irq;
        hw.chipset = ide_pci;           /* this enables IRQ sharing */
 
-       rc = ide_register_hw(&hw, &ide_undecoded_slave, &hwif);
-       if (rc < 0) {
-               printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
-               pci_disable_device(dev);
-               return -ENODEV;
-       }
+       hwif = ide_find_port();
+       if (hwif == NULL)
+               goto out_disable;
+
+       i = hwif->index;
+
+       ide_init_port_data(hwif, i);
+       ide_init_port_hw(hwif, &hw);
+       hwif->port_ops = &delkin_cb_port_ops;
+
+       idx[0] = i;
+
+       ide_device_add(idx, NULL);
+
+       if (!hwif->present)
+               goto out_disable;
+
        pci_set_drvdata(dev, hwif);
        hwif->dev = &dev->dev;
        drive = &hwif->drives[0];
@@ -92,6 +106,12 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
                drive->unmask   = 1;
        }
        return 0;
+
+out_disable:
+       printk(KERN_ERR "delkin_cb: no IDE devices found\n");
+       pci_release_regions(dev);
+       pci_disable_device(dev);
+       return -ENODEV;
 }
 
 static void
@@ -99,8 +119,9 @@ delkin_cb_remove (struct pci_dev *dev)
 {
        ide_hwif_t *hwif = pci_get_drvdata(dev);
 
-       if (hwif)
-               ide_unregister(hwif->index);
+       ide_unregister(hwif);
+
+       pci_release_regions(dev);
        pci_disable_device(dev);
 }