]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/isa/sgalaxy.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / sound / isa / sgalaxy.c
index 2e1d4677fe12feaebe71c0d5d02eeca5c6b10800..a60e66afbf90707c36f8cc56729cf3824beaa8b1 100644 (file)
@@ -64,6 +64,8 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver.");
 module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
 
+static struct platform_device *devices[SNDRV_CARDS];
+
 #define SGALAXY_AUXC_LEFT 18
 #define SGALAXY_AUXC_RIGHT 19
 
@@ -340,6 +342,15 @@ static struct platform_driver snd_sgalaxy_driver = {
        },
 };
 
+static void __init_or_module snd_sgalaxy_unregister_all(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(devices); ++i)
+               platform_device_unregister(devices[i]);
+       platform_driver_unregister(&snd_sgalaxy_driver);
+}
+
 static int __init alsa_card_sgalaxy_init(void)
 {
        int i, cards, err;
@@ -349,14 +360,17 @@ static int __init alsa_card_sgalaxy_init(void)
                return err;
 
        cards = 0;
-       for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
+       for (i = 0; i < SNDRV_CARDS; i++) {
                struct platform_device *device;
+               if (! enable[i])
+                       continue;
                device = platform_device_register_simple(SND_SGALAXY_DRIVER,
                                                         i, NULL, 0);
                if (IS_ERR(device)) {
                        err = PTR_ERR(device);
                        goto errout;
                }
+               devices[i] = device;
                cards++;
        }
        if (!cards) {
@@ -369,13 +383,13 @@ static int __init alsa_card_sgalaxy_init(void)
        return 0;
 
  errout:
-       platform_driver_unregister(&snd_sgalaxy_driver);
+       snd_sgalaxy_unregister_all();
        return err;
 }
 
 static void __exit alsa_card_sgalaxy_exit(void)
 {
-       platform_driver_unregister(&snd_sgalaxy_driver);
+       snd_sgalaxy_unregister_all();
 }
 
 module_init(alsa_card_sgalaxy_init)