summaryrefslogtreecommitdiff
path: root/sound/isa/wavefront/wavefront.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/wavefront/wavefront.c')
-rw-r--r--sound/isa/wavefront/wavefront.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 77a3012e5510..a6dcb2f970ca 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -83,6 +83,9 @@ MODULE_PARM_DESC(fm_port, "FM port #.");
module_param_array(use_cs4232_midi, bool, NULL, 0444);
MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
+static struct platform_device *platform_devices[SNDRV_CARDS];
+static int pnp_registered;
+
#ifdef CONFIG_PNP
@@ -688,6 +691,17 @@ static struct pnp_card_driver wavefront_pnpc_driver = {
#endif /* CONFIG_PNP */
+static void __init_or_module snd_wavefront_unregister_all(void)
+{
+ int i;
+
+ if (pnp_registered)
+ pnp_unregister_card_driver(&wavefront_pnpc_driver);
+ for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
+ platform_device_unregister(platform_devices[i]);
+ platform_driver_unregister(&snd_wavefront_driver);
+}
+
static int __init alsa_card_wavefront_init(void)
{
int i, err, cards = 0;
@@ -704,31 +718,36 @@ static int __init alsa_card_wavefront_init(void)
device = platform_device_register_simple(WAVEFRONT_DRIVER,
i, NULL, 0);
if (IS_ERR(device)) {
- platform_driver_unregister(&snd_wavefront_driver);
- return PTR_ERR(device);
+ err = PTR_ERR(device);
+ goto errout;
}
+ platform_devices[i] = device;
cards++;
}
i = pnp_register_card_driver(&wavefront_pnpc_driver);
- if (i > 0)
+ if (i >= 0) {
+ pnp_registered = 1;
cards += i;
+ }
if (!cards) {
- pnp_unregister_card_driver(&wavefront_pnpc_driver);
- platform_driver_unregister(&snd_wavefront_driver);
#ifdef MODULE
printk (KERN_ERR "No WaveFront cards found or devices busy\n");
#endif
- return -ENODEV;
+ err = -ENODEV;
+ goto errout;
}
return 0;
+
+ errout:
+ snd_wavefront_unregister_all();
+ return err;
}
static void __exit alsa_card_wavefront_exit(void)
{
- pnp_unregister_card_driver(&wavefront_pnpc_driver);
- platform_driver_unregister(&snd_wavefront_driver);
+ snd_wavefront_unregister_all();
}
module_init(alsa_card_wavefront_init)