X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=sound%2Fisa%2Fopl3sa2.c;h=6d889052c32c96932ed1484213f3f7382110786c;hp=56fcd8a946a485822539099505e9bc41043e66fe;hb=7c8ce71b092425f1e938285cab2a679c09444d9b;hpb=f01c18456993bab43067b678f56c87ca954aa43b diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 56fcd8a946a4..6d889052c32c 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -95,6 +95,7 @@ static struct platform_device *platform_devices[SNDRV_CARDS]; static int pnp_registered; static int pnpc_registered; #endif +static unsigned int snd_opl3sa2_devices; /* control ports */ #define OPL3SA2_PM_CTRL 0x01 @@ -760,6 +761,7 @@ static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, } pnp_set_drvdata(pdev, card); dev++; + snd_opl3sa2_devices++; return 0; } @@ -826,6 +828,7 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, } pnp_set_card_drvdata(pcard, card); dev++; + snd_opl3sa2_devices++; return 0; } @@ -944,7 +947,7 @@ static void __init_or_module snd_opl3sa2_unregister_all(void) static int __init alsa_card_opl3sa2_init(void) { - int i, err, cards = 0; + int i, err; if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0) return err; @@ -959,39 +962,33 @@ static int __init alsa_card_opl3sa2_init(void) #endif device = platform_device_register_simple(OPL3SA2_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++; + snd_opl3sa2_devices++; } #ifdef CONFIG_PNP err = pnp_register_driver(&opl3sa2_pnp_driver); - if (err >= 0) { + if (!err) pnp_registered = 1; - cards += err; - } err = pnp_register_card_driver(&opl3sa2_pnpc_driver); - if (err >= 0) { + if (!err) pnpc_registered = 1; - cards += err; - } #endif - if (!cards) { + if (!snd_opl3sa2_devices) { #ifdef MODULE snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); #endif - err = -ENODEV; - goto errout; + snd_opl3sa2_unregister_all(); + return -ENODEV; } return 0; - - errout: - snd_opl3sa2_unregister_all(); - return err; } static void __exit alsa_card_opl3sa2_exit(void)