Pull bugzilla-7897 into release branch
[sfrench/cifs-2.6.git] / sound / isa / ad1848 / ad1848.c
index e091bbeffd2a80a47dcca6ded1989f486623be46..74e501dea8b1f935141f38a0b77cea08d7a8f125 100644 (file)
@@ -65,7 +65,7 @@ MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 3
 static struct platform_device *devices[SNDRV_CARDS];
 
 
-static int __init snd_ad1848_probe(struct platform_device *pdev)
+static int __devinit snd_ad1848_probe(struct platform_device *pdev)
 {
        int dev = pdev->id;
        struct snd_card *card;
@@ -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)