]> err.no Git - linux-2.6/commitdiff
[PATCH] pnp: PNP: adjust pnp_register_driver signature
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Mon, 27 Mar 2006 09:17:08 +0000 (01:17 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 27 Mar 2006 16:44:53 +0000 (08:44 -0800)
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>
Cc: Adam Belay <ambx1@neo.rr.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Documentation/pnp.txt
drivers/pnp/card.c
drivers/pnp/driver.c

index af0f6eabfa1c47ee0740664826caacdc15cca94c..9529c9c9fd59fe69d8d960b05a9522e7ba0bbaac 100644 (file)
@@ -115,6 +115,9 @@ pnp_unregister_protocol
 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
index b68eef251614c68a55ecadd069f7e76e45ff20cf..bb19c64073c6ddd8e8544de2c773e846e1235349 100644 (file)
@@ -47,7 +47,7 @@ static void card_remove(struct pnp_dev * dev)
 {
        dev->card_link = NULL;
 }
+
 static void card_remove_first(struct pnp_dev * dev)
 {
        struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver);
@@ -361,7 +361,7 @@ static int card_resume(struct pnp_dev *dev)
 
 int pnp_register_card_driver(struct pnp_card_driver * drv)
 {
-       int count;
+       int error;
        struct list_head *pos, *temp;
 
        drv->link.name = drv->name;
@@ -372,21 +372,19 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
        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 7cafacdd12b0a4dae9fea941b3b8efc0076fea85..e54c153831937f8985a28ded2ccd71a4f55458e5 100644 (file)
@@ -201,31 +201,14 @@ struct bus_type pnp_bus_type = {
        .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)