summaryrefslogtreecommitdiff
path: root/sound/isa/gus/interwave.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-12-07 09:13:42 +0100
committerJaroslav Kysela <perex@suse.cz>2006-01-03 12:30:39 +0100
commitf7a9275d949cb0bf1f259a1546e52a0bf518151c (patch)
tree4d96d9b6196d43684903857ba676dc51bbde4026 /sound/isa/gus/interwave.c
parent416c1079d30f1a52399b96f6772e993274b774ae (diff)
[ALSA] unregister platform devices
Call platform_device_unregister() for all platform devices that we've registered. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/isa/gus/interwave.c')
-rw-r--r--sound/isa/gus/interwave.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 67a5f7402453..9838d992b101 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -115,6 +115,9 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver.");
module_param_array(effect, int, NULL, 0444);
MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
+static struct platform_device *platform_devices[SNDRV_CARDS];
+static int pnp_registered;
+
struct snd_interwave {
int irq;
struct snd_card *card;
@@ -914,6 +917,17 @@ static struct pnp_card_driver interwave_pnpc_driver = {
#endif /* CONFIG_PNP */
+static void __init_or_module snd_interwave_unregister_all(void)
+{
+ int i;
+
+ if (pnp_registered)
+ pnp_unregister_card_driver(&interwave_pnpc_driver);
+ for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
+ platform_device_unregister(platform_devices[i]);
+ platform_driver_unregister(&snd_interwave_driver);
+}
+
static int __init alsa_card_interwave_init(void)
{
int i, err, cards = 0;
@@ -931,32 +945,36 @@ static int __init alsa_card_interwave_init(void)
i, NULL, 0);
if (IS_ERR(device)) {
err = PTR_ERR(device);
- platform_driver_unregister(&snd_interwave_driver);
- return err;
+ goto errout;
}
+ platform_devices[i] = device;
cards++;
}
/* ISA PnP cards */
i = pnp_register_card_driver(&interwave_pnpc_driver);
- if (i > 0)
+ if (i >= 0) {
+ pnp_registered = 1;
cards += i;
+ }
if (!cards) {
- pnp_unregister_card_driver(&interwave_pnpc_driver);
- platform_driver_unregister(&snd_interwave_driver);
#ifdef MODULE
printk(KERN_ERR "InterWave soundcard not found or device busy\n");
#endif
- return -ENODEV;
+ err = -ENODEV;
+ goto errout;
}
return 0;
+
+ errout:
+ snd_interwave_unregister_all();
+ return err;
}
static void __exit alsa_card_interwave_exit(void)
{
- pnp_unregister_card_driver(&interwave_pnpc_driver);
- platform_driver_unregister(&snd_interwave_driver);
+ snd_interwave_unregister_all();
}
module_init(alsa_card_interwave_init)