[patch 2.6.10-bk1 2/5] pci-ide: clean up error path in do_ide_setup_pci_device

From: Francois Romieu
Date: Wed Dec 29 2004 - 19:12:55 EST


Clean up error path in do_ide_setup_pci_device.

ide_setup_pci_controller() puts the device in a PCI enabled state.
The patch adds a small helper to balance it when things go wrong.

Actually the helper does not *exactly* balance the setup: if it can
not do a better job, ide_setup_pci_controller() may only enable some
BARS whereas the new counterpart will try to disable everything.

Signed-off-by: Francois Romieu <romieu@xxxxxxxxxxxxx>

diff -puN drivers/ide/setup-pci.c~ata-020 drivers/ide/setup-pci.c
--- linux-2.6.10-bk1/drivers/ide/setup-pci.c~ata-020 2004-12-29 23:42:44.511302710 +0100
+++ linux-2.6.10-bk1-romieu/drivers/ide/setup-pci.c 2004-12-29 23:42:44.514302222 +0100
@@ -542,6 +542,13 @@ static int ide_setup_pci_controller(stru
return 0;
}

+static void ide_release_pci_controller(struct pci_dev *dev, ide_pci_device_t *d,
+ int noisy)
+{
+ /* Balance ide_pci_enable() */
+ pci_disable_device(dev);
+}
+
/**
* ide_pci_setup_ports - configure ports/devices on PCI IDE
* @dev: PCI device
@@ -672,7 +679,7 @@ static int do_ide_setup_pci_device (stru
*/
ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0;
if (ret < 0)
- goto out;
+ goto err_release_pci_controller;
pciirq = ret;
} else if (tried_config) {
if (noisy)
@@ -687,7 +694,7 @@ static int do_ide_setup_pci_device (stru
if (d->init_chipset) {
ret = d->init_chipset(dev, d->name);
if (ret < 0)
- goto out;
+ goto err_release_pci_controller;
}
if (noisy)
#ifdef __sparc__
@@ -705,6 +712,10 @@ static int do_ide_setup_pci_device (stru
ide_pci_setup_ports(dev, d, pciirq, index);
out:
return ret;
+
+err_release_pci_controller:
+ ide_release_pci_controller(dev, d, noisy);
+ goto out;
}

int ide_setup_pci_device (struct pci_dev *dev, ide_pci_device_t *d)

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/