[ALSA] unregister platform devices
Call platform_device_unregister() for all platform devices that we've
registered.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index d1b70ee..d4d2b2a 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -72,6 +72,8 @@
module_param_array(pcm_channels, int, NULL, 0444);
MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
+static struct platform_device *devices[SNDRV_CARDS];
+
struct snd_gusmax {
int irq;
struct snd_card *card;
@@ -364,6 +366,15 @@
},
};
+static void __init_or_module snd_gusmax_unregister_all(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(devices); ++i)
+ platform_device_unregister(devices[i]);
+ platform_driver_unregister(&snd_gusmax_driver);
+}
+
static int __init alsa_card_gusmax_init(void)
{
int i, cards, err;
@@ -381,6 +392,7 @@
err = PTR_ERR(device);
goto errout;
}
+ devices[i] = device;
cards++;
}
if (!cards) {
@@ -393,13 +405,13 @@
return 0;
errout:
- platform_driver_unregister(&snd_gusmax_driver);
+ snd_gusmax_unregister_all();
return err;
}
static void __exit alsa_card_gusmax_exit(void)
{
- platform_driver_unregister(&snd_gusmax_driver);
+ snd_gusmax_unregister_all();
}
module_init(alsa_card_gusmax_init)