aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/cs423x/cs4236.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/cs423x/cs4236.c
parent[ALSA] Nest sound devices (diff)
downloadlinux-dev-f7a9275d949cb0bf1f259a1546e52a0bf518151c.tar.xz
linux-dev-f7a9275d949cb0bf1f259a1546e52a0bf518151c.zip
[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/cs423x/cs4236.c')
-rw-r--r--sound/isa/cs423x/cs4236.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 9e399b6e6ed9..e1683337e6cd 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -124,6 +124,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
module_param_array(dma2, int, NULL, 0444);
MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
+static struct platform_device *platform_devices[SNDRV_CARDS];
+static int pnpc_registered;
+#ifdef CS4232
+static int pnp_registered;
+#endif
+
struct snd_card_cs4236 {
struct snd_cs4231 *chip;
struct resource *res_sb_port;
@@ -737,6 +743,21 @@ static struct pnp_card_driver cs423x_pnpc_driver = {
};
#endif /* CONFIG_PNP */
+static void __init_or_module snd_cs423x_unregister_all(void)
+{
+ int i;
+
+ if (pnpc_registered)
+ pnp_unregister_card_driver(&cs423x_pnpc_driver);
+#ifdef CS4232
+ if (pnp_registered)
+ pnp_unregister_driver(&cs4232_pnp_driver);
+#endif
+ for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
+ platform_device_unregister(platform_devices[i]);
+ platform_driver_unregister(&cs423x_nonpnp_driver);
+}
+
static int __init alsa_card_cs423x_init(void)
{
int i, err, cards = 0;
@@ -752,40 +773,40 @@ static int __init alsa_card_cs423x_init(void)
i, NULL, 0);
if (IS_ERR(device)) {
err = PTR_ERR(device);
- platform_driver_unregister(&cs423x_nonpnp_driver);
- return err;
+ goto errout;
}
+ platform_devices[i] = device;
cards++;
}
#ifdef CS4232
i = pnp_register_driver(&cs4232_pnp_driver);
- if (i > 0)
+ if (i >= 0) {
+ pnp_registered = 1;
cards += i;
+ }
#endif
i = pnp_register_card_driver(&cs423x_pnpc_driver);
- if (i > 0)
+ if (i >= 0) {
+ pnpc_registered = 1;
cards += i;
+ }
if (!cards) {
-#ifdef CS4232
- pnp_unregister_driver(&cs4232_pnp_driver);
-#endif
- pnp_unregister_card_driver(&cs423x_pnpc_driver);
- platform_driver_unregister(&cs423x_nonpnp_driver);
#ifdef MODULE
printk(KERN_ERR IDENT " soundcard not found or device busy\n");
#endif
- return -ENODEV;
+ err = -ENODEV;
+ goto errout;
}
return 0;
+
+ errout:
+ snd_cs423x_unregister_all();
+ return err;
}
static void __exit alsa_card_cs423x_exit(void)
{
-#ifdef CS4232
- pnp_unregister_driver(&cs4232_pnp_driver);
-#endif
- pnp_unregister_card_driver(&cs423x_pnpc_driver);
- platform_driver_unregister(&cs423x_nonpnp_driver);
+ snd_cs423x_unregister_all();
}
module_init(alsa_card_cs423x_init)