summaryrefslogtreecommitdiff
path: root/sound/isa/sscape.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-12-07 11:13:42 +0300
committerJaroslav Kysela <perex@suse.cz>2006-01-03 14:30:39 +0300
commitf7a9275d949cb0bf1f259a1546e52a0bf518151c (patch)
tree4d96d9b6196d43684903857ba676dc51bbde4026 /sound/isa/sscape.c
parent416c1079d30f1a52399b96f6772e993274b774ae (diff)
downloadlinux-f7a9275d949cb0bf1f259a1546e52a0bf518151c.tar.xz
[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/sscape.c')
-rw-r--r--sound/isa/sscape.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 6271efe689df..5fb981c0a281 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -67,6 +67,9 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");
module_param_array(dma, int, NULL, 0444);
MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
+
+static struct platform_device *platform_devices[SNDRV_CARDS];
+static int pnp_registered;
#ifdef CONFIG_PNP
static struct pnp_card_device_id sscape_pnpids[] = {
@@ -1384,6 +1387,17 @@ static struct pnp_card_driver sscape_pnpc_driver = {
#endif /* CONFIG_PNP */
+static void __init_or_module sscape_unregister_all(void)
+{
+ int i;
+
+ if (pnp_registered)
+ pnp_unregister_card_driver(&sscape_pnpc_driver);
+ for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
+ platform_device_unregister(platform_devices[i]);
+ platform_driver_unregister(&snd_sscape_driver);
+}
+
static int __init sscape_manual_probe(void)
{
struct platform_device *device;
@@ -1411,8 +1425,8 @@ static int __init sscape_manual_probe(void)
dma[i] == SNDRV_AUTO_DMA) {
printk(KERN_INFO
"sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
- platform_driver_unregister(&snd_sscape_driver);
- return -ENXIO;
+ ret = -ENXIO;
+ goto errout;
}
/*
@@ -1421,17 +1435,21 @@ static int __init sscape_manual_probe(void)
device = platform_device_register_simple(SSCAPE_DRIVER,
i, NULL, 0);
if (IS_ERR(device)) {
- platform_driver_unregister(&snd_sscape_driver);
- return PTR_ERR(device);
+ ret = PTR_ERR(device);
+ goto errout;
}
+ platform_devices[i] = device;
}
return 0;
+
+ errout:
+ sscape_unregister_all();
+ return ret;
}
static void sscape_exit(void)
{
- pnp_unregister_card_driver(&sscape_pnpc_driver);
- platform_driver_unregister(&snd_sscape_driver);
+ sscape_unregister_all();
}
@@ -1448,7 +1466,8 @@ static int __init sscape_init(void)
ret = sscape_manual_probe();
if (ret < 0)
return ret;
- pnp_register_card_driver(&sscape_pnpc_driver);
+ if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0)
+ pnp_registered = 1;
return 0;
}