]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/mips/swarm.c
ide: add struct ide_host (take 3)
[linux-2.6-omap-h63xx.git] / drivers / ide / mips / swarm.c
index 52fee3d2771a7ce7bfdb95592e44b898d9288417..b12d9d2248315913f7ed1bad49fa7aa74cd6f338 100644 (file)
@@ -61,28 +61,26 @@ static struct resource swarm_ide_resource = {
 
 static struct platform_device *swarm_ide_dev;
 
+static const struct ide_port_info swarm_port_info = {
+       .name                   = DRV_NAME,
+       .host_flags             = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
+};
+
 /*
  * swarm_ide_probe - if the board header indicates the existence of
  * Generic Bus IDE, allocate a HWIF for it.
  */
 static int __devinit swarm_ide_probe(struct device *dev)
 {
-       ide_hwif_t *hwif;
        u8 __iomem *base;
+       struct ide_host *host;
        phys_t offset, size;
-       hw_regs_t hw;
        int i;
-       u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
+       hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
 
        if (!SIBYTE_HAVE_IDE)
                return -ENODEV;
 
-       hwif = ide_find_port();
-       if (hwif == NULL) {
-               printk(KERN_ERR DRV_NAME ": no free slot for interface\n");
-               return -ENOMEM;
-       }
-
        base = ioremap(A_IO_EXT_BASE, 0x800);
        offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
        size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
@@ -109,10 +107,6 @@ static int __devinit swarm_ide_probe(struct device *dev)
 
        base = ioremap(offset, size);
 
-       /* Setup MMIO ops.  */
-       hwif->host_flags = IDE_HFLAG_MMIO;
-       default_hwif_mmiops(hwif);
-
        for (i = 0; i <= 7; i++)
                hw.io_ports_array[i] =
                                (unsigned long)(base + ((0x1f0 + i) << 5));
@@ -121,15 +115,19 @@ static int __devinit swarm_ide_probe(struct device *dev)
        hw.irq = K_INT_GB_IDE;
        hw.chipset = ide_generic;
 
-       ide_init_port_hw(hwif, &hw);
-
-       idx[0] = hwif->index;
+       host = ide_host_alloc(&swarm_port_info, hws);
+       if (host == NULL)
+               goto err;
 
-       ide_device_add(idx, NULL);
+       ide_host_register(host, &swarm_port_info, hws);
 
-       dev_set_drvdata(dev, hwif);
+       dev_set_drvdata(dev, host);
 
        return 0;
+err:
+       release_resource(&swarm_ide_resource);
+       iounmap(base);
+       return -ENOMEM;
 }
 
 static struct device_driver swarm_ide_driver = {