From 9e016a719209d95338e314b46c3012cc7feaaeec Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Sat, 2 Feb 2008 19:56:39 +0100 Subject: ide: add ide_deprecated_find_port() helper * Factor out code for finding ide_hwifs[] slot from ide_register_hw() to ide_deprecated_find_port(). * Convert bast-ide, ide-cs and delkin_cb host drivers to use ide_device_add() instead of ide_register_hw() (while at it drop doing "ide_unregister()" loop which tries to unregister _all_ IDE interfaces if useable ide_hwifs[] slot cannot be find). This patch leaves us with only two ide_register_hw() users: - drivers/macintosh/mediabay.c - drivers/ide/ide.c Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/pci/delkin_cb.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'drivers/ide/pci') diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index 4e9ebaa79624..15670801a67f 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c @@ -51,6 +51,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) { @@ -77,12 +78,27 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) 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_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]); + if (hwif == NULL) + goto out_disable; + + i = hwif->index; + + if (hwif->present) + ide_unregister(i, 0, 1); + else if (!hwif->hold) + ide_init_port_data(hwif, i); + + ide_init_port_hw(hwif, &hw); + hwif->quirkproc = &ide_undecoded_slave; + + 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]; @@ -91,6 +107,11 @@ 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_disable_device(dev); + return -ENODEV; } static void -- cgit v1.2.2