mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Adam Belay <ambx1@neo.rr.com>
Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela <perex@suse.cz>,
	Matthieu Castet <castet.matthieu@free.fr>,
	Li Shaohua <shaohua.li@intel.com>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH 9/9] PNP: adjust pnp_register_driver signature
Date: Thu, 2 Mar 2006 16:09:57 -0700	[thread overview]
Message-ID: <200603021609.57333.bjorn.helgaas@hp.com> (raw)
In-Reply-To: <200603021601.27467.bjorn.helgaas@hp.com>

Remove the assumption that pnp_register_driver() returns the number of
devices claimed.  Returning the count is unreliable because devices may
be hot-plugged in the future.

This changes the convention to "zero for success, or a negative error
value," which matches pci_register_driver(), acpi_bus_register_driver(),
and platform_driver_register().

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work-mm4/drivers/pnp/driver.c
===================================================================
--- work-mm4.orig/drivers/pnp/driver.c	2006-03-02 12:40:45.000000000 -0700
+++ work-mm4/drivers/pnp/driver.c	2006-03-02 12:46:49.000000000 -0700
@@ -201,31 +201,14 @@
 	.resume = pnp_bus_resume,
 };
 
-
-static int count_devices(struct device * dev, void * c)
-{
-	int * count = c;
-	(*count)++;
-	return 0;
-}
-
 int pnp_register_driver(struct pnp_driver *drv)
 {
-	int count;
-
 	pnp_dbg("the driver '%s' has been registered", drv->name);
 
 	drv->driver.name = drv->name;
 	drv->driver.bus = &pnp_bus_type;
 
-	count = driver_register(&drv->driver);
-
-	/* get the number of initial matches */
-	if (count >= 0){
-		count = 0;
-		driver_for_each_device(&drv->driver, NULL, &count, count_devices);
-	}
-	return count;
+	return driver_register(&drv->driver);
 }
 
 void pnp_unregister_driver(struct pnp_driver *drv)
Index: work-mm4/drivers/pnp/card.c
===================================================================
--- work-mm4.orig/drivers/pnp/card.c	2006-03-02 12:40:45.000000000 -0700
+++ work-mm4/drivers/pnp/card.c	2006-03-02 12:46:49.000000000 -0700
@@ -47,7 +47,7 @@
 {
 	dev->card_link = NULL;
 }
- 
+
 static void card_remove_first(struct pnp_dev * dev)
 {
 	struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver);
@@ -373,7 +373,7 @@
 
 int pnp_register_card_driver(struct pnp_card_driver * drv)
 {
-	int count;
+	int error;
 	struct list_head *pos, *temp;
 
 	drv->link.name = drv->name;
@@ -384,21 +384,19 @@
 	drv->link.suspend = drv->suspend ? card_suspend : NULL;
 	drv->link.resume = drv->resume ? card_resume : NULL;
 
-	count = pnp_register_driver(&drv->link);
-	if (count < 0)
-		return count;
+	error = pnp_register_driver(&drv->link);
+	if (error < 0)
+		return error;
 
 	spin_lock(&pnp_lock);
 	list_add_tail(&drv->global_list, &pnp_card_drivers);
 	spin_unlock(&pnp_lock);
 
-	count = 0;
-
 	list_for_each_safe(pos,temp,&pnp_cards){
 		struct pnp_card *card = list_entry(pos, struct pnp_card, global_list);
-		count += card_probe(card,drv);
+		card_probe(card,drv);
 	}
-	return count;
+	return 0;
 }
 
 /**
Index: work-mm4/Documentation/pnp.txt
===================================================================
--- work-mm4.orig/Documentation/pnp.txt	2006-03-02 12:40:45.000000000 -0700
+++ work-mm4/Documentation/pnp.txt	2006-03-02 12:48:01.000000000 -0700
@@ -115,6 +115,9 @@
 pnp_register_driver
 - adds a PnP driver to the Plug and Play Layer
 - this includes driver model integration
+- returns zero for success or a negative error number for failure; count
+  calls to the .add() method if you need to know how many devices bind to
+  the driver
 
 pnp_unregister_driver
 - removes a PnP driver from the Plug and Play Layer

  parent reply	other threads:[~2006-03-02 23:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02 23:01 [PATCH 0/9] " Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 1/9] parport: " Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 2/9] mpu401: " Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 3/9] cs4236: " Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 4/9] opl3sa2: " Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 5/9] ns558: " Bjorn Helgaas
2006-03-03 12:55   ` Vojtech Pavlik
2006-03-03 15:58     ` Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 6/9] i8042: " Bjorn Helgaas
2006-03-14  5:31   ` Dmitry Torokhov
2006-03-02 23:09 ` [PATCH 7/9] IRDA: " Bjorn Helgaas
2006-03-02 23:09 ` [PATCH 8/9] cs4232: " Bjorn Helgaas
2006-03-02 23:09 ` Bjorn Helgaas [this message]
2006-03-14  6:19 ` [PATCH 0/9] PNP: " Adam Belay

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=200603021609.57333.bjorn.helgaas@hp.com \
    --to=bjorn.helgaas@hp.com \
    --cc=akpm@osdl.org \
    --cc=ambx1@neo.rr.com \
    --cc=castet.matthieu@free.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@suse.cz \
    --cc=shaohua.li@intel.com \
    /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®