diff options
-rw-r--r-- | Documentation/pnp.txt | 3 | ||||
-rw-r--r-- | drivers/pnp/card.c | 16 | ||||
-rw-r--r-- | drivers/pnp/driver.c | 19 |
3 files changed, 11 insertions, 27 deletions
diff --git a/Documentation/pnp.txt b/Documentation/pnp.txt index af0f6eabfa1c..9529c9c9fd59 100644 --- a/Documentation/pnp.txt +++ b/Documentation/pnp.txt | |||
@@ -115,6 +115,9 @@ pnp_unregister_protocol | |||
115 | pnp_register_driver | 115 | pnp_register_driver |
116 | - adds a PnP driver to the Plug and Play Layer | 116 | - adds a PnP driver to the Plug and Play Layer |
117 | - this includes driver model integration | 117 | - this includes driver model integration |
118 | - returns zero for success or a negative error number for failure; count | ||
119 | calls to the .add() method if you need to know how many devices bind to | ||
120 | the driver | ||
118 | 121 | ||
119 | pnp_unregister_driver | 122 | pnp_unregister_driver |
120 | - removes a PnP driver from the Plug and Play Layer | 123 | - removes a PnP driver from the Plug and Play Layer |
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index b68eef251614..bb19c64073c6 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c | |||
@@ -47,7 +47,7 @@ static void card_remove(struct pnp_dev * dev) | |||
47 | { | 47 | { |
48 | dev->card_link = NULL; | 48 | dev->card_link = NULL; |
49 | } | 49 | } |
50 | 50 | ||
51 | static void card_remove_first(struct pnp_dev * dev) | 51 | static void card_remove_first(struct pnp_dev * dev) |
52 | { | 52 | { |
53 | struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver); | 53 | struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver); |
@@ -361,7 +361,7 @@ static int card_resume(struct pnp_dev *dev) | |||
361 | 361 | ||
362 | int pnp_register_card_driver(struct pnp_card_driver * drv) | 362 | int pnp_register_card_driver(struct pnp_card_driver * drv) |
363 | { | 363 | { |
364 | int count; | 364 | int error; |
365 | struct list_head *pos, *temp; | 365 | struct list_head *pos, *temp; |
366 | 366 | ||
367 | drv->link.name = drv->name; | 367 | drv->link.name = drv->name; |
@@ -372,21 +372,19 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) | |||
372 | drv->link.suspend = drv->suspend ? card_suspend : NULL; | 372 | drv->link.suspend = drv->suspend ? card_suspend : NULL; |
373 | drv->link.resume = drv->resume ? card_resume : NULL; | 373 | drv->link.resume = drv->resume ? card_resume : NULL; |
374 | 374 | ||
375 | count = pnp_register_driver(&drv->link); | 375 | error = pnp_register_driver(&drv->link); |
376 | if (count < 0) | 376 | if (error < 0) |
377 | return count; | 377 | return error; |
378 | 378 | ||
379 | spin_lock(&pnp_lock); | 379 | spin_lock(&pnp_lock); |
380 | list_add_tail(&drv->global_list, &pnp_card_drivers); | 380 | list_add_tail(&drv->global_list, &pnp_card_drivers); |
381 | spin_unlock(&pnp_lock); | 381 | spin_unlock(&pnp_lock); |
382 | 382 | ||
383 | count = 0; | ||
384 | |||
385 | list_for_each_safe(pos,temp,&pnp_cards){ | 383 | list_for_each_safe(pos,temp,&pnp_cards){ |
386 | struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); | 384 | struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); |
387 | count += card_probe(card,drv); | 385 | card_probe(card,drv); |
388 | } | 386 | } |
389 | return count; | 387 | return 0; |
390 | } | 388 | } |
391 | 389 | ||
392 | /** | 390 | /** |
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 7cafacdd12b0..e54c15383193 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -201,31 +201,14 @@ struct bus_type pnp_bus_type = { | |||
201 | .resume = pnp_bus_resume, | 201 | .resume = pnp_bus_resume, |
202 | }; | 202 | }; |
203 | 203 | ||
204 | |||
205 | static int count_devices(struct device * dev, void * c) | ||
206 | { | ||
207 | int * count = c; | ||
208 | (*count)++; | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | int pnp_register_driver(struct pnp_driver *drv) | 204 | int pnp_register_driver(struct pnp_driver *drv) |
213 | { | 205 | { |
214 | int count; | ||
215 | |||
216 | pnp_dbg("the driver '%s' has been registered", drv->name); | 206 | pnp_dbg("the driver '%s' has been registered", drv->name); |
217 | 207 | ||
218 | drv->driver.name = drv->name; | 208 | drv->driver.name = drv->name; |
219 | drv->driver.bus = &pnp_bus_type; | 209 | drv->driver.bus = &pnp_bus_type; |
220 | 210 | ||
221 | count = driver_register(&drv->driver); | 211 | return driver_register(&drv->driver); |
222 | |||
223 | /* get the number of initial matches */ | ||
224 | if (count >= 0){ | ||
225 | count = 0; | ||
226 | driver_for_each_device(&drv->driver, NULL, &count, count_devices); | ||
227 | } | ||
228 | return count; | ||
229 | } | 212 | } |
230 | 213 | ||
231 | void pnp_unregister_driver(struct pnp_driver *drv) | 214 | void pnp_unregister_driver(struct pnp_driver *drv) |