Merge branch 'for_paulus' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc
[pandora-kernel.git] / sound / isa / wavefront / wavefront.c
index a6dcb2f..7ae86f8 100644 (file)
@@ -84,10 +84,9 @@ module_param_array(use_cs4232_midi, bool, NULL, 0444);
 MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
 
 static struct platform_device *platform_devices[SNDRV_CARDS];
-static int pnp_registered;
-
 
 #ifdef CONFIG_PNP
+static int pnp_registered;
 
 static struct pnp_card_device_id snd_wavefront_pnpids[] = {
        /* Tropez */
@@ -590,7 +589,7 @@ snd_wavefront_probe (struct snd_card *card, int dev)
        return snd_card_register(card);
 }      
 
-static int __init snd_wavefront_nonpnp_probe(struct platform_device *pdev)
+static int __devinit snd_wavefront_nonpnp_probe(struct platform_device *pdev)
 {
        int dev = pdev->id;
        struct snd_card *card;
@@ -638,6 +637,7 @@ static struct platform_driver snd_wavefront_driver = {
 
 
 #ifdef CONFIG_PNP
+static unsigned int __devinitdata wavefront_pnp_devices;
 
 static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
                                               const struct pnp_card_device_id *pid)
@@ -671,6 +671,7 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
 
        pnp_set_card_drvdata(pcard, card);
        dev++;
+       wavefront_pnp_devices++;
        return 0;
 }
 
@@ -695,8 +696,10 @@ static void __init_or_module snd_wavefront_unregister_all(void)
 {
        int i;
 
+#ifdef CONFIG_PNP
        if (pnp_registered)
                pnp_unregister_card_driver(&wavefront_pnpc_driver);
+#endif
        for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
                platform_device_unregister(platform_devices[i]);
        platform_driver_unregister(&snd_wavefront_driver);
@@ -709,40 +712,42 @@ static int __init alsa_card_wavefront_init(void)
        if ((err = platform_driver_register(&snd_wavefront_driver)) < 0)
                return err;
 
-       for (i = 0; i < SNDRV_CARDS && enable[i]; i++) {
+       for (i = 0; i < SNDRV_CARDS; i++) {
                struct platform_device *device;
+               if (! enable[i])
+                       continue;
 #ifdef CONFIG_PNP
                if (isapnp[i])
                        continue;
 #endif
                device = platform_device_register_simple(WAVEFRONT_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;
                }
                platform_devices[i] = device;
                cards++;
        }
 
-       i = pnp_register_card_driver(&wavefront_pnpc_driver);
-       if (i >= 0) {
+#ifdef CONFIG_PNP
+       err = pnp_register_card_driver(&wavefront_pnpc_driver);
+       if (!err) {
                pnp_registered = 1;
-               cards += i;
+               cards += wavefront_pnp_devices;
        }
+#endif
 
        if (!cards) {
 #ifdef MODULE
                printk (KERN_ERR "No WaveFront cards found or devices busy\n");
 #endif
-               err = -ENODEV;
-               goto errout;
+               snd_wavefront_unregister_all();
+               return -ENODEV;
        }
        return 0;
-
- errout:
-       snd_wavefront_unregister_all();
-       return err;
 }
 
 static void __exit alsa_card_wavefront_exit(void)