[ALSA] unregister platform device again if probe was unsuccessful
authorRene Herman <rene.herman@keyaccess.nl>
Tue, 11 Apr 2006 12:09:37 +0000 (14:09 +0200)
committerJaroslav Kysela <perex@suse.cz>
Wed, 12 Apr 2006 09:55:32 +0000 (11:55 +0200)
Unregister the platform device again if the probe was unsuccessful.

This restores the behaviour of not loading the driver on probe() failure.

Signed-off-by: Rene Herman <rene.herman@keyaccess.nl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
19 files changed:
sound/isa/ad1848/ad1848.c
sound/isa/adlib.c
sound/isa/cmi8330.c
sound/isa/cs423x/cs4231.c
sound/isa/cs423x/cs4236.c
sound/isa/es1688/es1688.c
sound/isa/es18xx.c
sound/isa/gus/gusclassic.c
sound/isa/gus/gusextreme.c
sound/isa/gus/gusmax.c
sound/isa/gus/interwave.c
sound/isa/opl3sa2.c
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c
sound/isa/sb/sb16.c
sound/isa/sb/sb8.c
sound/isa/sgalaxy.c
sound/isa/sscape.c
sound/isa/wavefront/wavefront.c

index 1f460eb402a37fd2f369e22212b552cd9cca514b..99908e44124da32593b6fa85ea87eafeb4cc1c6b 100644 (file)
@@ -195,6 +195,10 @@ static int __init alsa_card_ad1848_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index a253a14e6a45be6ea18e8b982268c855337eefba..1124344ed948b38005041306e322d8107a7af4d1 100644 (file)
@@ -43,8 +43,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device)
        struct snd_card *card;
        struct snd_opl3 *opl3;
 
-       int error;
-       int i = device->id;
+       int error, i = device->id;
 
        if (port[i] == SNDRV_AUTO_PORT) {
                snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
@@ -95,8 +94,7 @@ static int __devinit snd_adlib_probe(struct platform_device *device)
        return 0;
 
 out1:  snd_card_free(card);
- out0: error = -EINVAL; /* FIXME: should be the original error code */
-       return error;
+out0:  return error;
 }
 
 static int __devexit snd_adlib_remove(struct platform_device *device)
@@ -134,6 +132,11 @@ static int __init alsa_card_adlib_init(void)
                if (IS_ERR(device))
                        continue;
 
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
+
                devices[i] = device;
                cards++;
        }
index 35780b811d161e0f157e4d8cfffe2b7d479e19e2..3c1e9fd56fe00143e3c1a26ca81c5acc9affa4e8 100644 (file)
@@ -701,6 +701,10 @@ static int __init alsa_card_cmi8330_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                cards++;
        }
index 073dac9756797701db1c1c8997024d8bb7b5c3e3..397310f358b7c4ed1f0bfdefaebcb01bfc432442 100644 (file)
@@ -211,6 +211,10 @@ static int __init alsa_card_cs4231_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index b07a62b76175a78ec6fc5a6487f025ae0d3986e2..f7fa779347ffea800b407a5a555b1cf37855137e 100644 (file)
@@ -782,6 +782,10 @@ static int __init alsa_card_cs423x_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                snd_cs423x_devices++;
        }
index d83d7104958fdc88f4d594db1acbfcb855739229..e90689ee162fac5174a3d4413cec954d6675fa40 100644 (file)
@@ -215,6 +215,10 @@ static int __init alsa_card_es1688_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index 0da249bcf02b51908b5567bdd7402340c1be0654..a36ec1daa5cb9e24dcb5e3d887d5d56936c13f2b 100644 (file)
@@ -2393,6 +2393,10 @@ static int __init alsa_card_es18xx_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                cards++;
        }
index ed34427c49db220658e6239c323ab184a54a54c5..37057a37dc30a870b611473113cd6b39425fa845 100644 (file)
@@ -255,6 +255,10 @@ static int __init alsa_card_gusclassic_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index aa312dee99c898607b9e145885a2ab1919c11027..05852fcc613bd32b54217af97f4ab850b8828916 100644 (file)
@@ -365,6 +365,10 @@ static int __init alsa_card_gusextreme_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index a733fabf653aec8a00c145b66ac720209fc113f0..fcf2c8fe6f94ba2b56dead0238e7b2816667a94f 100644 (file)
@@ -392,6 +392,10 @@ static int __init alsa_card_gusmax_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index 4be472ea99d2b84d824e50506468154fb82d572c..4298d339e786fff55ccd1c090476b0bcf17d9441 100644 (file)
@@ -949,6 +949,10 @@ static int __init alsa_card_interwave_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                cards++;
        }
index 02ae73ea0badb5e72d6063bb82d82604a6eb522b..6d889052c32c96932ed1484213f3f7382110786c 100644 (file)
@@ -964,6 +964,10 @@ static int __init alsa_card_opl3sa2_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                snd_opl3sa2_devices++;
        }
index 09384d03dc31f47e9b9a46e91254ba8ca6f70f2b..83d64bc07ff0f113fcf871d0d7e45f7b1ffffb48 100644 (file)
@@ -1436,8 +1436,11 @@ static int __init alsa_card_miro_init(void)
        if ((error = platform_driver_register(&snd_miro_driver)) < 0)
                return error;
        device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
-       if (! IS_ERR(device))
-               return 0;
+       if (! IS_ERR(device)) {
+               if (platform_get_drvdata(device))
+                       return 0;
+               platform_device_unregister(device);
+       }
 #ifdef MODULE
        printk(KERN_ERR "no miro soundcard found\n");
 #endif
index 65b28cbc0ebd75b5211e5cb3cb292e058e8e9239..8ee0d70536f9cc93998e37a26178004ed8768a89 100644 (file)
@@ -2099,8 +2099,11 @@ static int __init alsa_card_opti9xx_init(void)
                        return error;
                device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
                if (!IS_ERR(device)) {
-                       snd_opti9xx_platform_device = device;
-                       return 0;
+                       if (platform_get_drvdata(device)) {
+                               snd_opti9xx_platform_device = device;
+                               return 0;
+                       }
+                       platform_device_unregister(device);
                }
                platform_driver_unregister(&snd_opti9xx_driver);
        }
index 24fa190f33ac155ef8719c75ca7bf7ac0ee38cfb..6333f900eaee63ec027d557d359dbea01e7fe8dc 100644 (file)
@@ -722,6 +722,10 @@ static int __init alsa_card_sb16_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                cards++;
        }
index f75eeb05c1fae12d9557844b1a139341ae726df0..141400c014261aacffe3a42134ea34570c07a8fa 100644 (file)
@@ -266,6 +266,10 @@ static int __init alsa_card_sb8_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index f01a80a97ab8f6a77f044c6abc09fb723a86d06c..09c8e8c6b5e3cf8a548fdbec09660ca88eb70dfb 100644 (file)
@@ -368,6 +368,10 @@ static int __init alsa_card_sgalaxy_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                devices[i] = device;
                cards++;
        }
index 532f6e0eff0b72c4f58896101009a4a78dd6366c..d2a856f0fde201d20e47da42d3960dea8d6537cd 100644 (file)
@@ -1438,6 +1438,10 @@ static int __init sscape_manual_probe(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
        }
        return 0;
index ed9d0173e80fe81e897af1dd3b83af9084c87b86..7ae86f82c3fa8b5852015c137950cedf93cf9322 100644 (file)
@@ -724,6 +724,10 @@ static int __init alsa_card_wavefront_init(void)
                                                         i, NULL, 0);
                if (IS_ERR(device))
                        continue;
+               if (!platform_get_drvdata(device)) {
+                       platform_device_unregister(device);
+                       continue;
+               }
                platform_devices[i] = device;
                cards++;
        }