[ide] 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: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 85cb671e
...@@ -542,6 +542,13 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in ...@@ -542,6 +542,13 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in
return 0; 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 * ide_pci_setup_ports - configure ports/devices on PCI IDE
* @dev: PCI device * @dev: PCI device
...@@ -672,7 +679,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, ...@@ -672,7 +679,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
*/ */
ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0; ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0;
if (ret < 0) if (ret < 0)
goto out; goto err_release_pci_controller;
pciirq = ret; pciirq = ret;
} else if (tried_config) { } else if (tried_config) {
if (noisy) if (noisy)
...@@ -687,7 +694,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, ...@@ -687,7 +694,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
if (d->init_chipset) { if (d->init_chipset) {
ret = d->init_chipset(dev, d->name); ret = d->init_chipset(dev, d->name);
if (ret < 0) if (ret < 0)
goto out; goto err_release_pci_controller;
} }
if (noisy) if (noisy)
#ifdef __sparc__ #ifdef __sparc__
...@@ -705,6 +712,10 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d, ...@@ -705,6 +712,10 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
ide_pci_setup_ports(dev, d, pciirq, index); ide_pci_setup_ports(dev, d, pciirq, index);
out: out:
return ret; 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) int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment