X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fide%2Farm%2Frapide.c;h=b5b6ed8b82b211fa0ccdd695e3cebc604e5588ad;hb=fadd11c71b5a100fb7560b84a6272b8883082726;hp=890ea3fac3c6feb80bb50f8ced8a392fe9369aed;hpb=5c34202b8bf942da411b6599668a76b07449bbfd;p=linux-2.6 diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c index 890ea3fac3..b5b6ed8b82 100644 --- a/drivers/ide/arm/rapide.c +++ b/drivers/ide/arm/rapide.c @@ -13,43 +13,18 @@ #include -/* - * Something like this really should be in generic code, but isn't. - */ -static ide_hwif_t * -rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq) +static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, + void __iomem *ctrl, unsigned int sz, int irq) { unsigned long port = (unsigned long)base; - ide_hwif_t *hwif; - int index, i; - - for (index = 0; index < MAX_HWIFS; ++index) { - hwif = ide_hwifs + index; - if (hwif->io_ports[IDE_DATA_OFFSET] == port) - goto found; - } - - for (index = 0; index < MAX_HWIFS; ++index) { - hwif = ide_hwifs + index; - if (hwif->io_ports[IDE_DATA_OFFSET] == 0) - goto found; - } - - return NULL; + int i; - found: for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { - hwif->hw.io_ports[i] = port; - hwif->io_ports[i] = port; + hw->io_ports[i] = port; port += sz; } - hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; - hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; - hwif->hw.irq = hwif->irq = irq; - hwif->mmio = 1; - default_hwif_mmiops(hwif); - - return hwif; + hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; + hw->irq = irq; } static int __devinit @@ -58,30 +33,39 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id) ide_hwif_t *hwif; void __iomem *base; int ret; + u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; + hw_regs_t hw; ret = ecard_request_resources(ec); if (ret) goto out; - base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC), - ecard_resource_len(ec, ECARD_RES_MEMC)); + base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); if (!base) { ret = -ENOMEM; goto release; } - hwif = rapide_locate_hwif(base, base + 0x818, 1 << 6, ec->irq); + hwif = ide_find_port((unsigned long)base); if (hwif) { - hwif->hwif_data = base; - hwif->gendev.parent = &ec->dev; - hwif->noprobe = 0; - probe_hwif_init(hwif); - ide_proc_register_port(hwif); + memset(&hw, 0, sizeof(hw)); + rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); + hw.chipset = ide_generic; + hw.dev = &ec->dev; + + ide_init_port_hw(hwif, &hw); + + hwif->mmio = 1; + default_hwif_mmiops(hwif); + + idx[0] = hwif->index; + + ide_device_add(idx); + ecard_set_drvdata(ec, hwif); goto out; } - iounmap(base); release: ecard_release_resources(ec); out: @@ -94,9 +78,8 @@ static void __devexit rapide_remove(struct expansion_card *ec) ecard_set_drvdata(ec, NULL); - /* there must be a better way */ - ide_unregister(hwif - ide_hwifs); - iounmap(hwif->hwif_data); + ide_unregister(hwif->index); + ecard_release_resources(ec); }