aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/wavefront/wavefront.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/wavefront/wavefront.c')
-rw-r--r--sound/isa/wavefront/wavefront.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index 77a3012e5510..a6dcb2f970ca 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -83,6 +83,9 @@ MODULE_PARM_DESC(fm_port, "FM port #.");
83module_param_array(use_cs4232_midi, bool, NULL, 0444); 83module_param_array(use_cs4232_midi, bool, NULL, 0444);
84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); 84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
85 85
86static struct platform_device *platform_devices[SNDRV_CARDS];
87static int pnp_registered;
88
86 89
87#ifdef CONFIG_PNP 90#ifdef CONFIG_PNP
88 91
@@ -688,6 +691,17 @@ static struct pnp_card_driver wavefront_pnpc_driver = {
688 691
689#endif /* CONFIG_PNP */ 692#endif /* CONFIG_PNP */
690 693
694static void __init_or_module snd_wavefront_unregister_all(void)
695{
696 int i;
697
698 if (pnp_registered)
699 pnp_unregister_card_driver(&wavefront_pnpc_driver);
700 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
701 platform_device_unregister(platform_devices[i]);
702 platform_driver_unregister(&snd_wavefront_driver);
703}
704
691static int __init alsa_card_wavefront_init(void) 705static int __init alsa_card_wavefront_init(void)
692{ 706{
693 int i, err, cards = 0; 707 int i, err, cards = 0;
@@ -704,31 +718,36 @@ static int __init alsa_card_wavefront_init(void)
704 device = platform_device_register_simple(WAVEFRONT_DRIVER, 718 device = platform_device_register_simple(WAVEFRONT_DRIVER,
705 i, NULL, 0); 719 i, NULL, 0);
706 if (IS_ERR(device)) { 720 if (IS_ERR(device)) {
707 platform_driver_unregister(&snd_wavefront_driver); 721 err = PTR_ERR(device);
708 return PTR_ERR(device); 722 goto errout;
709 } 723 }
724 platform_devices[i] = device;
710 cards++; 725 cards++;
711 } 726 }
712 727
713 i = pnp_register_card_driver(&wavefront_pnpc_driver); 728 i = pnp_register_card_driver(&wavefront_pnpc_driver);
714 if (i > 0) 729 if (i >= 0) {
730 pnp_registered = 1;
715 cards += i; 731 cards += i;
732 }
716 733
717 if (!cards) { 734 if (!cards) {
718 pnp_unregister_card_driver(&wavefront_pnpc_driver);
719 platform_driver_unregister(&snd_wavefront_driver);
720#ifdef MODULE 735#ifdef MODULE
721 printk (KERN_ERR "No WaveFront cards found or devices busy\n"); 736 printk (KERN_ERR "No WaveFront cards found or devices busy\n");
722#endif 737#endif
723 return -ENODEV; 738 err = -ENODEV;
739 goto errout;
724 } 740 }
725 return 0; 741 return 0;
742
743 errout:
744 snd_wavefront_unregister_all();
745 return err;
726} 746}
727 747
728static void __exit alsa_card_wavefront_exit(void) 748static void __exit alsa_card_wavefront_exit(void)
729{ 749{
730 pnp_unregister_card_driver(&wavefront_pnpc_driver); 750 snd_wavefront_unregister_all();
731 platform_driver_unregister(&snd_wavefront_driver);
732} 751}
733 752
734module_init(alsa_card_wavefront_init) 753module_init(alsa_card_wavefront_init)