Commit be54414d authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Linus Torvalds

[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: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Jaroslav Kysela <perex@suse.cz>
Acked-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 312fef30
...@@ -52,6 +52,7 @@ static int __initdata sm_games = 0; /* Logitech soundman games? */ ...@@ -52,6 +52,7 @@ static int __initdata sm_games = 0; /* Logitech soundman games? */
static struct sb_card_config *legacy = NULL; static struct sb_card_config *legacy = NULL;
#ifdef CONFIG_PNP #ifdef CONFIG_PNP
static int pnp_registered;
static int __initdata pnp = 1; static int __initdata pnp = 1;
/* /*
static int __initdata uart401 = 0; static int __initdata uart401 = 0;
...@@ -133,7 +134,7 @@ static void sb_unload(struct sb_card_config *scc) ...@@ -133,7 +134,7 @@ static void sb_unload(struct sb_card_config *scc)
} }
/* Register legacy card with OSS subsystem */ /* Register legacy card with OSS subsystem */
static int sb_init_legacy(void) static int __init sb_init_legacy(void)
{ {
struct sb_module_options sbmo = {0}; struct sb_module_options sbmo = {0};
...@@ -234,6 +235,8 @@ static void sb_dev2cfg(struct pnp_dev *dev, struct sb_card_config *scc) ...@@ -234,6 +235,8 @@ static void sb_dev2cfg(struct pnp_dev *dev, struct sb_card_config *scc)
} }
} }
static unsigned int sb_pnp_devices;
/* Probe callback function for the PnP API */ /* Probe callback function for the PnP API */
static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id) static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device_id *card_id)
{ {
...@@ -264,6 +267,7 @@ static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device ...@@ -264,6 +267,7 @@ static int sb_pnp_probe(struct pnp_card_link *card, const struct pnp_card_device
scc->conf.dma, scc->conf.dma2); scc->conf.dma, scc->conf.dma2);
pnp_set_card_drvdata(card, scc); pnp_set_card_drvdata(card, scc);
sb_pnp_devices++;
return sb_register_oss(scc, &sbmo); return sb_register_oss(scc, &sbmo);
} }
...@@ -289,6 +293,14 @@ static struct pnp_card_driver sb_pnp_driver = { ...@@ -289,6 +293,14 @@ static struct pnp_card_driver sb_pnp_driver = {
MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table); MODULE_DEVICE_TABLE(pnp_card, sb_pnp_card_table);
#endif /* CONFIG_PNP */ #endif /* CONFIG_PNP */
static void __init_or_module sb_unregister_all(void)
{
#ifdef CONFIG_PNP
if (pnp_registered)
pnp_unregister_card_driver(&sb_pnp_driver);
#endif
}
static int __init sb_init(void) static int __init sb_init(void)
{ {
int lres = 0; int lres = 0;
...@@ -307,17 +319,18 @@ static int __init sb_init(void) ...@@ -307,17 +319,18 @@ static int __init sb_init(void)
#ifdef CONFIG_PNP #ifdef CONFIG_PNP
if(pnp) { if(pnp) {
pres = pnp_register_card_driver(&sb_pnp_driver); int err = pnp_register_card_driver(&sb_pnp_driver);
if (!err)
pnp_registered = 1;
pres = sb_pnp_devices;
} }
#endif #endif
printk(KERN_INFO "sb: Init: Done\n"); printk(KERN_INFO "sb: Init: Done\n");
/* If either PnP or Legacy registered a card then return /* If either PnP or Legacy registered a card then return
* success */ * success */
if (pres <= 0 && lres <= 0) { if (pres == 0 && lres <= 0) {
#ifdef CONFIG_PNP sb_unregister_all();
pnp_unregister_card_driver(&sb_pnp_driver);
#endif
return -ENODEV; return -ENODEV;
} }
return 0; return 0;
...@@ -333,9 +346,7 @@ static void __exit sb_exit(void) ...@@ -333,9 +346,7 @@ static void __exit sb_exit(void)
sb_unload(legacy); sb_unload(legacy);
} }
#ifdef CONFIG_PNP sb_unregister_all();
pnp_unregister_card_driver(&sb_pnp_driver);
#endif
if (smw_free) { if (smw_free) {
vfree(smw_free); vfree(smw_free);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment