Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[sfrench/cifs-2.6.git] / sound / isa / sgalaxy.c
index 0dbbb35b242caea322cb6ad93461213b0a284cc8..09c8e8c6b5e3cf8a548fdbec09660ca88eb70dfb 100644 (file)
@@ -360,13 +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;
+               if (IS_ERR(device))
+                       continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
                }
                devices[i] = device;
                cards++;
@@ -375,14 +379,10 @@ static int __init alsa_card_sgalaxy_init(void)
 #ifdef MODULE
                snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");
 #endif
-               err = -ENODEV;
-               goto errout;
+               snd_sgalaxy_unregister_all();
+               return -ENODEV;
        }
        return 0;
-
- errout:
-       snd_sgalaxy_unregister_all();
-       return err;
 }
 
 static void __exit alsa_card_sgalaxy_exit(void)