mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	torvalds@osdl.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [patch 2.6.10-bk1 2/5] pci-ide: clean up error path in do_ide_setup_pci_device
Date: Thu, 30 Dec 2004 01:04:55 +0100	[thread overview]
Message-ID: <20041230000455.GA2217@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20041230000302.GA4267@electric-eye.fr.zoreil.com>

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@fr.zoreil.com>

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)

_

  reply	other threads:[~2004-12-30  0:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-27 14:37 PATCH: 2.6.10 - Incorrect return from PCI ide controller Alan Cox
2004-12-28 20:55 ` Francois Romieu
2004-12-28 21:15   ` Bartlomiej Zolnierkiewicz
2004-12-29  0:09     ` Francois Romieu
2004-12-30  0:03     ` [patch 2.6.10-bk1 1/5] pci-ide: propagation of error code in ide setup Francois Romieu
2004-12-30  0:04       ` Francois Romieu [this message]
2004-12-30  0:06         ` [patch 2.6.10-bk1 3/5] pci-ide: propagate the error status in ide_pci_enable/ide_setup_pci_controller Francois Romieu
2004-12-30  0:07           ` [patch 2.6.10-bk1 4/5] pci-ide: fix the incorrect returns for the generic driver Francois Romieu
2004-12-30  0:09             ` [patch 2.6.10-bk1 5/5] pci-ide: make device drivers code aware of the changes made to ide_setup_pci_device{s} Francois Romieu
2004-12-30  0:21               ` colophon Francois Romieu
2004-12-28 22:12   ` PATCH: 2.6.10 - Incorrect return from PCI ide controller Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041230000455.GA2217@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=bzolnier@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®