diff options
Diffstat (limited to 'sound/isa/sb/sb16.c')
-rw-r--r-- | sound/isa/sb/sb16.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 05816c5d829a..c0be7a5a3425 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c | |||
@@ -128,6 +128,11 @@ module_param_array(seq_ports, int, NULL, 0444); | |||
128 | MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); | 128 | MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
132 | #ifdef CONFIG_PNP | ||
133 | static int pnp_registered; | ||
134 | #endif | ||
135 | |||
131 | struct snd_card_sb16 { | 136 | struct snd_card_sb16 { |
132 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */ | 137 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */ |
133 | struct snd_sb *chip; | 138 | struct snd_sb *chip; |
@@ -687,6 +692,19 @@ static struct pnp_card_driver sb16_pnpc_driver = { | |||
687 | 692 | ||
688 | #endif /* CONFIG_PNP */ | 693 | #endif /* CONFIG_PNP */ |
689 | 694 | ||
695 | static void __init_or_module snd_sb16_unregister_all(void) | ||
696 | { | ||
697 | int i; | ||
698 | |||
699 | #ifdef CONFIG_PNP | ||
700 | if (pnp_registered) | ||
701 | pnp_unregister_card_driver(&sb16_pnpc_driver); | ||
702 | #endif | ||
703 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
704 | platform_device_unregister(platform_devices[i]); | ||
705 | platform_driver_unregister(&snd_sb16_nonpnp_driver); | ||
706 | } | ||
707 | |||
690 | static int __init alsa_card_sb16_init(void) | 708 | static int __init alsa_card_sb16_init(void) |
691 | { | 709 | { |
692 | int i, err, cards = 0; | 710 | int i, err, cards = 0; |
@@ -702,23 +720,21 @@ static int __init alsa_card_sb16_init(void) | |||
702 | i, NULL, 0); | 720 | i, NULL, 0); |
703 | if (IS_ERR(device)) { | 721 | if (IS_ERR(device)) { |
704 | err = PTR_ERR(device); | 722 | err = PTR_ERR(device); |
705 | platform_driver_unregister(&snd_sb16_nonpnp_driver); | 723 | goto errout; |
706 | return err; | ||
707 | } | 724 | } |
725 | platform_devices[i] = device; | ||
708 | cards++; | 726 | cards++; |
709 | } | 727 | } |
710 | #ifdef CONFIG_PNP | 728 | #ifdef CONFIG_PNP |
711 | /* PnP cards at last */ | 729 | /* PnP cards at last */ |
712 | i = pnp_register_card_driver(&sb16_pnpc_driver); | 730 | i = pnp_register_card_driver(&sb16_pnpc_driver); |
713 | if (i > 0) | 731 | if (i >= 0) { |
732 | pnp_registered = 1; | ||
714 | cards += i; | 733 | cards += i; |
734 | } | ||
715 | #endif | 735 | #endif |
716 | 736 | ||
717 | if (!cards) { | 737 | if (!cards) { |
718 | #ifdef CONFIG_PNP | ||
719 | pnp_unregister_card_driver(&sb16_pnpc_driver); | ||
720 | #endif | ||
721 | platform_driver_unregister(&snd_sb16_nonpnp_driver); | ||
722 | #ifdef MODULE | 738 | #ifdef MODULE |
723 | snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); | 739 | snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); |
724 | #ifdef SNDRV_SBAWE_EMU8000 | 740 | #ifdef SNDRV_SBAWE_EMU8000 |
@@ -727,17 +743,19 @@ static int __init alsa_card_sb16_init(void) | |||
727 | snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); | 743 | snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); |
728 | #endif | 744 | #endif |
729 | #endif | 745 | #endif |
730 | return -ENODEV; | 746 | err = -ENODEV; |
747 | goto errout; | ||
731 | } | 748 | } |
732 | return 0; | 749 | return 0; |
750 | |||
751 | errout: | ||
752 | snd_sb16_unregister_all(); | ||
753 | return err; | ||
733 | } | 754 | } |
734 | 755 | ||
735 | static void __exit alsa_card_sb16_exit(void) | 756 | static void __exit alsa_card_sb16_exit(void) |
736 | { | 757 | { |
737 | #ifdef CONFIG_PNP | 758 | snd_sb16_unregister_all(); |
738 | pnp_unregister_card_driver(&sb16_pnpc_driver); | ||
739 | #endif | ||
740 | platform_driver_unregister(&snd_sb16_nonpnp_driver); | ||
741 | } | 759 | } |
742 | 760 | ||
743 | module_init(alsa_card_sb16_init) | 761 | module_init(alsa_card_sb16_init) |