Merge branch 'misc' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc...
[pandora-kernel.git] / sound / isa / ad1848 / ad1848.c
index e091bbe..99908e4 100644 (file)
@@ -187,13 +187,17 @@ static int __init alsa_card_ad1848_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_AD1848_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++;
@@ -202,14 +206,10 @@ static int __init alsa_card_ad1848_init(void)
 #ifdef MODULE
                printk(KERN_ERR "AD1848 soundcard not found or device busy\n");
 #endif
-               err = -ENODEV;
-               goto errout;
+               snd_ad1848_unregister_all();
+               return -ENODEV;
        }
        return 0;
-
- errout:
-       snd_ad1848_unregister_all();
-       return err;
 }
 
 static void __exit alsa_card_ad1848_exit(void)