ide: cleanup setting hwif->mmio flag
[cascardo/linux.git] / drivers / ide / pci / delkin_cb.c
index 46f4a88..c7b7e04 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  linux/drivers/ide/pci/delkin_cb.c
- *
  *  Created 20 Oct 2004 by Mark Lord
  *
  *  Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
  *  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>
 
 /*
@@ -46,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)
 {
@@ -54,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) {
@@ -73,27 +75,47 @@ 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_with_fixup(&hw, 0, &hwif, ide_undecoded_slave);
-       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;
+
+       if (hwif->present)
+               ide_unregister(i);
+       else
+               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->pci_dev = dev;
+       hwif->dev = &dev->dev;
        drive = &hwif->drives[0];
        if (drive->present) {
                drive->io_32bit = 1;
                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
@@ -103,6 +125,8 @@ delkin_cb_remove (struct pci_dev *dev)
 
        if (hwif)
                ide_unregister(hwif->index);
+
+       pci_release_regions(dev);
        pci_disable_device(dev);
 }