public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Andrew Morton <akpm@osdl.org>,
	Reuben Farrelly <reuben-news@reub.net>,
	Hanno Meyer-Thurow <h.mth@web.de>,
	USB development list <linux-usb-devel@lists.sourceforge.net>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH (as387)] UHCI: check return code from pci_register_driver
Date: Mon, 4 Oct 2004 13:10:16 -0700	[thread overview]
Message-ID: <20041004201016.GA29771@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0410041125290.1358-100000@ida.rowland.org>

On Mon, Oct 04, 2004 at 11:33:35AM -0400, Alan Stern wrote:
> Greg:
> 
> This is all your fault!  :-)
> 
> The patch below fixes the problem in which the UHCI driver doesn't
> properly check the return code from pci_register_driver().

Yeah, it's all my fault, what else is new...

Anyway, no, my change to the uhci (and ohci and ehci drivers) is ok,
it's just that pci_register_driver() is incorrect :)

Here's a fix for it, that lets the USB host controllers work properly.
Now PCI works like the other bus drivers.  As we had no idea of how many
devices bound to the driver, this function was just lying and returning
"1".  What a stinker.

I'll add this to my trees, and I've gone through and audited all callers
of this function to now work properly (there were some pretty strange
ideas of what to do on an error returned from this function...)

Alan, these error messages lead me to believe that the error recovery
code in the uhci driver doesn't quite work properly, as even if the
register of the pci driver fails, we shouldn't error out with this mess,
right?

thanks,

greg k-h


===== pci-driver.c 1.46 vs edited =====
--- 1.46/drivers/pci/pci-driver.c	2004-09-29 23:09:23 -07:00
+++ edited/pci-driver.c	2004-10-04 11:11:20 -07:00
@@ -396,13 +396,13 @@
  * @drv: the driver structure to register
  * 
  * Adds the driver structure to the list of registered drivers.
- * Returns a negative value on error. The driver remains registered
- * even if no device was claimed during registration.
+ * Returns a negative value on error, otherwise 0. 
+ * If no error occured, the driver remains registered even if 
+ * no device was claimed during registration.
  */
-int
-pci_register_driver(struct pci_driver *drv)
+int pci_register_driver(struct pci_driver *drv)
 {
-	int count = 0;
+	int error;
 
 	/* initialize common driver fields */
 	drv->driver.name = drv->name;
@@ -414,13 +414,12 @@
 	pci_init_dynids(&drv->dynids);
 
 	/* register with core */
-	count = driver_register(&drv->driver);
+	error = driver_register(&drv->driver);
 
-	if (count >= 0) {
+	if (!error)
 		pci_populate_driver_dir(drv);
-	}
 
-	return count ? count : 1;
+	return error;
 }
 
 /**

      parent reply	other threads:[~2004-10-04 20:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20041001225636.76224a2c.akpm@osdl.org>
2004-10-04 15:33 ` [PATCH (as387)] UHCI: check return code from pci_register_driver Alan Stern
2004-10-04 19:16   ` Reuben Farrelly
2004-10-04 20:10   ` Greg KH [this message]

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=20041004201016.GA29771@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@osdl.org \
    --cc=h.mth@web.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=reuben-news@reub.net \
    --cc=stern@rowland.harvard.edu \
    /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