diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2006-03-27 04:17:16 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-27 11:44:54 -0500 |
commit | be54414d597b168d8c4eb2dafb8933ea15a7c148 (patch) | |
tree | bec9355085d457f1af8f4a0770f4c3a3b1c5a496 | |
parent | 312fef308cb15e793d8902f1dbd318d01268d36e (diff) |
[PATCH] PNP: adjust pnp_register_card_driver() signature: sb_card
Remove the assumption that pnp_register_card_driver() returns the
number of devices claimed. And fix some __init/__devinit issues.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Jaroslav Kysela <perex@suse.cz>
Acked-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | sound/oss/sb_card.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/sound/oss/sb_card.c b/sound/oss/sb_card.c index 680b82e15298..d38e88abc8fa 100644 --- a/sound/oss/sb_card.c +++ b/sound/oss/sb_card.c | |||
@@ -52,6 +52,7 @@ static int __initdata sm_games = 0; /* Logitech soundman games? */ | |||
52 | static struct sb_card_config *legacy = NULL; | 52 | static struct sb_card_config *legacy = NULL; |
53 | 53 | ||
54 | #ifdef CONFIG_PNP | 54 | #ifdef CONFIG_PNP |
55 | static int pnp_registered; | ||
55 | static int __initdata pnp = 1; | 56 | static int __initdata pnp = 1; |
56 | /* | 57 | /* |
57 | static int __initdata uart401 = 0; | 58 | static int __initdata uart401 = 0; |
@@ -133,7 +134,7 @@ static void sb_unload(struct sb_card_config *scc) | |||
133 | } | 134 | } |
134 | 135 | ||
135 | /* Register legacy card with OSS subsystem */ | 136 | /* Register legacy card with OSS subsystem */ |
136 | static int sb_init_legacy(void) | 137 | static int __init sb_init_legacy(void) |
137 | { | 138 | { |
138 | struct sb_module_options sbmo = {0}; | 139 | struct sb_module_options sbmo = {0}; |
139 | 140 | ||
@@ -234,6 +235,8 @@ static void sb_dev2cfg(struct pnp_dev *dev, struct sb_card_config *scc) | |||
234 | } | 235 | } |
235 | } | 236 | } |
236 | 237 | ||
238 | static unsigned int sb_pnp_devices; | ||
239 | |||
237 | /* Probe callback function for the PnP API */ | 240 | /* Probe callback function for the PnP API */ |
238 | static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id) | 241 | static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id) |
239 | { | 242 | { |
@@ -264,6 +267,7 @@ static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device | |||
264 | scc->conf.dma, scc->conf.dma2); | 267 | scc->conf.dma, scc->conf.dma2); |
265 | 268 | ||
266 | pnp_set_card_drvdata(card, scc); | 269 | pnp_set_card_drvdata(card, scc); |
270 | sb_pnp_devices++; | ||
267 | 271 | ||
268 | return sb_register_oss(scc, &sbmo); | 272 | return sb_register_oss(scc, &sbmo); |
269 | } | 273 | } |
@@ -289,6 +293,14 @@ static struct pnp_card_driver sb_pnp_driver = { | |||
289 | MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table); | 293 | MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table); |
290 | #endif /* CONFIG_PNP */ | 294 | #endif /* CONFIG_PNP */ |
291 | 295 | ||
296 | static void __init_or_module sb_unregister_all(void) | ||
297 | { | ||
298 | #ifdef CONFIG_PNP | ||
299 | if (pnp_registered) | ||
300 | pnp_unregister_card_driver(&sb_pnp_driver); | ||
301 | #endif | ||
302 | } | ||
303 | |||
292 | static int __init sb_init(void) | 304 | static int __init sb_init(void) |
293 | { | 305 | { |
294 | int lres = 0; | 306 | int lres = 0; |
@@ -307,17 +319,18 @@ static int __init sb_init(void) | |||
307 | 319 | ||
308 | #ifdef CONFIG_PNP | 320 | #ifdef CONFIG_PNP |
309 | if(pnp) { | 321 | if(pnp) { |
310 | pres = pnp_register_card_driver(&sb_pnp_driver); | 322 | int err = pnp_register_card_driver(&sb_pnp_driver); |
323 | if (!err) | ||
324 | pnp_registered = 1; | ||
325 | pres = sb_pnp_devices; | ||
311 | } | 326 | } |
312 | #endif | 327 | #endif |
313 | printk(KERN_INFO "sb: Init: Done\n"); | 328 | printk(KERN_INFO "sb: Init: Done\n"); |
314 | 329 | ||
315 | /* If either PnP or Legacy registered a card then return | 330 | /* If either PnP or Legacy registered a card then return |
316 | * success */ | 331 | * success */ |
317 | if (pres <= 0 && lres <= 0) { | 332 | if (pres == 0 && lres <= 0) { |
318 | #ifdef CONFIG_PNP | 333 | sb_unregister_all(); |
319 | pnp_unregister_card_driver(&sb_pnp_driver); | ||
320 | #endif | ||
321 | return -ENODEV; | 334 | return -ENODEV; |
322 | } | 335 | } |
323 | return 0; | 336 | return 0; |
@@ -333,9 +346,7 @@ static void __exit sb_exit(void) | |||
333 | sb_unload(legacy); | 346 | sb_unload(legacy); |
334 | } | 347 | } |
335 | 348 | ||
336 | #ifdef CONFIG_PNP | 349 | sb_unregister_all(); |
337 | pnp_unregister_card_driver(&sb_pnp_driver); | ||
338 | #endif | ||
339 | 350 | ||
340 | if (smw_free) { | 351 | if (smw_free) { |
341 | vfree(smw_free); | 352 | vfree(smw_free); |