diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2005-12-07 03:13:42 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:30:39 -0500 |
commit | f7a9275d949cb0bf1f259a1546e52a0bf518151c (patch) | |
tree | 4d96d9b6196d43684903857ba676dc51bbde4026 /sound/isa | |
parent | 416c1079d30f1a52399b96f6772e993274b774ae (diff) |
[ALSA] unregister platform devices
Call platform_device_unregister() for all platform devices that we've
registered.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/isa')
-rw-r--r-- | sound/isa/ad1848/ad1848.c | 16 | ||||
-rw-r--r-- | sound/isa/cmi8330.c | 34 | ||||
-rw-r--r-- | sound/isa/cs423x/cs4231.c | 16 | ||||
-rw-r--r-- | sound/isa/cs423x/cs4236.c | 51 | ||||
-rw-r--r-- | sound/isa/es1688/es1688.c | 16 | ||||
-rw-r--r-- | sound/isa/es18xx.c | 34 | ||||
-rw-r--r-- | sound/isa/gus/gusclassic.c | 16 | ||||
-rw-r--r-- | sound/isa/gus/gusextreme.c | 16 | ||||
-rw-r--r-- | sound/isa/gus/gusmax.c | 16 | ||||
-rw-r--r-- | sound/isa/gus/interwave.c | 34 | ||||
-rw-r--r-- | sound/isa/opl3sa2.c | 43 | ||||
-rw-r--r-- | sound/isa/opti9xx/opti92x-ad1848.c | 9 | ||||
-rw-r--r-- | sound/isa/sb/sb16.c | 42 | ||||
-rw-r--r-- | sound/isa/sb/sb8.c | 16 | ||||
-rw-r--r-- | sound/isa/sgalaxy.c | 16 | ||||
-rw-r--r-- | sound/isa/sscape.c | 33 | ||||
-rw-r--r-- | sound/isa/wavefront/wavefront.c | 35 |
17 files changed, 348 insertions, 95 deletions
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 1019e9fdff53..e091bbeffd2a 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c | |||
@@ -62,6 +62,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); | |||
62 | module_param_array(thinkpad, bool, NULL, 0444); | 62 | module_param_array(thinkpad, bool, NULL, 0444); |
63 | MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); | 63 | MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); |
64 | 64 | ||
65 | static struct platform_device *devices[SNDRV_CARDS]; | ||
66 | |||
65 | 67 | ||
66 | static int __init snd_ad1848_probe(struct platform_device *pdev) | 68 | static int __init snd_ad1848_probe(struct platform_device *pdev) |
67 | { | 69 | { |
@@ -167,6 +169,15 @@ static struct platform_driver snd_ad1848_driver = { | |||
167 | }, | 169 | }, |
168 | }; | 170 | }; |
169 | 171 | ||
172 | static void __init_or_module snd_ad1848_unregister_all(void) | ||
173 | { | ||
174 | int i; | ||
175 | |||
176 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
177 | platform_device_unregister(devices[i]); | ||
178 | platform_driver_unregister(&snd_ad1848_driver); | ||
179 | } | ||
180 | |||
170 | static int __init alsa_card_ad1848_init(void) | 181 | static int __init alsa_card_ad1848_init(void) |
171 | { | 182 | { |
172 | int i, cards, err; | 183 | int i, cards, err; |
@@ -184,6 +195,7 @@ static int __init alsa_card_ad1848_init(void) | |||
184 | err = PTR_ERR(device); | 195 | err = PTR_ERR(device); |
185 | goto errout; | 196 | goto errout; |
186 | } | 197 | } |
198 | devices[i] = device; | ||
187 | cards++; | 199 | cards++; |
188 | } | 200 | } |
189 | if (!cards) { | 201 | if (!cards) { |
@@ -196,13 +208,13 @@ static int __init alsa_card_ad1848_init(void) | |||
196 | return 0; | 208 | return 0; |
197 | 209 | ||
198 | errout: | 210 | errout: |
199 | platform_driver_unregister(&snd_ad1848_driver); | 211 | snd_ad1848_unregister_all(); |
200 | return err; | 212 | return err; |
201 | } | 213 | } |
202 | 214 | ||
203 | static void __exit alsa_card_ad1848_exit(void) | 215 | static void __exit alsa_card_ad1848_exit(void) |
204 | { | 216 | { |
205 | platform_driver_unregister(&snd_ad1848_driver); | 217 | snd_ad1848_unregister_all(); |
206 | } | 218 | } |
207 | 219 | ||
208 | module_init(alsa_card_ad1848_init) | 220 | module_init(alsa_card_ad1848_init) |
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index ba0114ebafde..bd8e23818460 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c | |||
@@ -108,6 +108,9 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver."); | |||
108 | module_param_array(wssdma, int, NULL, 0444); | 108 | module_param_array(wssdma, int, NULL, 0444); |
109 | MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); | 109 | MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); |
110 | 110 | ||
111 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
112 | static int pnp_registered; | ||
113 | |||
111 | #define CMI8330_RMUX3D 16 | 114 | #define CMI8330_RMUX3D 16 |
112 | #define CMI8330_MUTEMUX 17 | 115 | #define CMI8330_MUTEMUX 17 |
113 | #define CMI8330_OUTPUTVOL 18 | 116 | #define CMI8330_OUTPUTVOL 18 |
@@ -665,6 +668,17 @@ static struct pnp_card_driver cmi8330_pnpc_driver = { | |||
665 | }; | 668 | }; |
666 | #endif /* CONFIG_PNP */ | 669 | #endif /* CONFIG_PNP */ |
667 | 670 | ||
671 | static void __init_or_module snd_cmi8330_unregister_all(void) | ||
672 | { | ||
673 | int i; | ||
674 | |||
675 | if (pnp_registered) | ||
676 | pnp_unregister_card_driver(&cmi8330_pnpc_driver); | ||
677 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
678 | platform_device_unregister(platform_devices[i]); | ||
679 | platform_driver_unregister(&snd_cmi8330_driver); | ||
680 | } | ||
681 | |||
668 | static int __init alsa_card_cmi8330_init(void) | 682 | static int __init alsa_card_cmi8330_init(void) |
669 | { | 683 | { |
670 | int i, err, cards = 0; | 684 | int i, err, cards = 0; |
@@ -680,31 +694,35 @@ static int __init alsa_card_cmi8330_init(void) | |||
680 | i, NULL, 0); | 694 | i, NULL, 0); |
681 | if (IS_ERR(device)) { | 695 | if (IS_ERR(device)) { |
682 | err = PTR_ERR(device); | 696 | err = PTR_ERR(device); |
683 | platform_driver_unregister(&snd_cmi8330_driver); | 697 | goto errout; |
684 | return err; | ||
685 | } | 698 | } |
699 | platform_devices[i] = device; | ||
686 | cards++; | 700 | cards++; |
687 | } | 701 | } |
688 | 702 | ||
689 | err = pnp_register_card_driver(&cmi8330_pnpc_driver); | 703 | err = pnp_register_card_driver(&cmi8330_pnpc_driver); |
690 | if (err > 0) | 704 | if (err >= 0) { |
705 | pnp_registered = 1; | ||
691 | cards += err; | 706 | cards += err; |
707 | } | ||
692 | 708 | ||
693 | if (!cards) { | 709 | if (!cards) { |
694 | pnp_unregister_card_driver(&cmi8330_pnpc_driver); | ||
695 | platform_driver_unregister(&snd_cmi8330_driver); | ||
696 | #ifdef MODULE | 710 | #ifdef MODULE |
697 | snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); | 711 | snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); |
698 | #endif | 712 | #endif |
699 | return -ENODEV; | 713 | err = -ENODEV; |
714 | goto errout; | ||
700 | } | 715 | } |
701 | return 0; | 716 | return 0; |
717 | |||
718 | errout: | ||
719 | snd_cmi8330_unregister_all(); | ||
720 | return err; | ||
702 | } | 721 | } |
703 | 722 | ||
704 | static void __exit alsa_card_cmi8330_exit(void) | 723 | static void __exit alsa_card_cmi8330_exit(void) |
705 | { | 724 | { |
706 | pnp_unregister_card_driver(&cmi8330_pnpc_driver); | 725 | snd_cmi8330_unregister_all(); |
707 | platform_driver_unregister(&snd_cmi8330_driver); | ||
708 | } | 726 | } |
709 | 727 | ||
710 | module_init(alsa_card_cmi8330_init) | 728 | module_init(alsa_card_cmi8330_init) |
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index b5252a5d7412..ab67b5c2590d 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c | |||
@@ -66,6 +66,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); | |||
66 | module_param_array(dma2, int, NULL, 0444); | 66 | module_param_array(dma2, int, NULL, 0444); |
67 | MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); | 67 | MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); |
68 | 68 | ||
69 | static struct platform_device *devices[SNDRV_CARDS]; | ||
70 | |||
69 | 71 | ||
70 | static int __init snd_cs4231_probe(struct platform_device *pdev) | 72 | static int __init snd_cs4231_probe(struct platform_device *pdev) |
71 | { | 73 | { |
@@ -183,6 +185,15 @@ static struct platform_driver snd_cs4231_driver = { | |||
183 | }, | 185 | }, |
184 | }; | 186 | }; |
185 | 187 | ||
188 | static void __init_or_module snd_cs4231_unregister_all(void) | ||
189 | { | ||
190 | int i; | ||
191 | |||
192 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
193 | platform_device_unregister(devices[i]); | ||
194 | platform_driver_unregister(&snd_cs4231_driver); | ||
195 | } | ||
196 | |||
186 | static int __init alsa_card_cs4231_init(void) | 197 | static int __init alsa_card_cs4231_init(void) |
187 | { | 198 | { |
188 | int i, cards, err; | 199 | int i, cards, err; |
@@ -200,6 +211,7 @@ static int __init alsa_card_cs4231_init(void) | |||
200 | err = PTR_ERR(device); | 211 | err = PTR_ERR(device); |
201 | goto errout; | 212 | goto errout; |
202 | } | 213 | } |
214 | devices[i] = device; | ||
203 | cards++; | 215 | cards++; |
204 | } | 216 | } |
205 | if (!cards) { | 217 | if (!cards) { |
@@ -212,13 +224,13 @@ static int __init alsa_card_cs4231_init(void) | |||
212 | return 0; | 224 | return 0; |
213 | 225 | ||
214 | errout: | 226 | errout: |
215 | platform_driver_unregister(&snd_cs4231_driver); | 227 | snd_cs4231_unregister_all(); |
216 | return err; | 228 | return err; |
217 | } | 229 | } |
218 | 230 | ||
219 | static void __exit alsa_card_cs4231_exit(void) | 231 | static void __exit alsa_card_cs4231_exit(void) |
220 | { | 232 | { |
221 | platform_driver_unregister(&snd_cs4231_driver); | 233 | snd_cs4231_unregister_all(); |
222 | } | 234 | } |
223 | 235 | ||
224 | module_init(alsa_card_cs4231_init) | 236 | module_init(alsa_card_cs4231_init) |
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 9e399b6e6ed9..e1683337e6cd 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c | |||
@@ -124,6 +124,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver."); | |||
124 | module_param_array(dma2, int, NULL, 0444); | 124 | module_param_array(dma2, int, NULL, 0444); |
125 | MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); | 125 | MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); |
126 | 126 | ||
127 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
128 | static int pnpc_registered; | ||
129 | #ifdef CS4232 | ||
130 | static int pnp_registered; | ||
131 | #endif | ||
132 | |||
127 | struct snd_card_cs4236 { | 133 | struct snd_card_cs4236 { |
128 | struct snd_cs4231 *chip; | 134 | struct snd_cs4231 *chip; |
129 | struct resource *res_sb_port; | 135 | struct resource *res_sb_port; |
@@ -737,6 +743,21 @@ static struct pnp_card_driver cs423x_pnpc_driver = { | |||
737 | }; | 743 | }; |
738 | #endif /* CONFIG_PNP */ | 744 | #endif /* CONFIG_PNP */ |
739 | 745 | ||
746 | static void __init_or_module snd_cs423x_unregister_all(void) | ||
747 | { | ||
748 | int i; | ||
749 | |||
750 | if (pnpc_registered) | ||
751 | pnp_unregister_card_driver(&cs423x_pnpc_driver); | ||
752 | #ifdef CS4232 | ||
753 | if (pnp_registered) | ||
754 | pnp_unregister_driver(&cs4232_pnp_driver); | ||
755 | #endif | ||
756 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
757 | platform_device_unregister(platform_devices[i]); | ||
758 | platform_driver_unregister(&cs423x_nonpnp_driver); | ||
759 | } | ||
760 | |||
740 | static int __init alsa_card_cs423x_init(void) | 761 | static int __init alsa_card_cs423x_init(void) |
741 | { | 762 | { |
742 | int i, err, cards = 0; | 763 | int i, err, cards = 0; |
@@ -752,40 +773,40 @@ static int __init alsa_card_cs423x_init(void) | |||
752 | i, NULL, 0); | 773 | i, NULL, 0); |
753 | if (IS_ERR(device)) { | 774 | if (IS_ERR(device)) { |
754 | err = PTR_ERR(device); | 775 | err = PTR_ERR(device); |
755 | platform_driver_unregister(&cs423x_nonpnp_driver); | 776 | goto errout; |
756 | return err; | ||
757 | } | 777 | } |
778 | platform_devices[i] = device; | ||
758 | cards++; | 779 | cards++; |
759 | } | 780 | } |
760 | #ifdef CS4232 | 781 | #ifdef CS4232 |
761 | i = pnp_register_driver(&cs4232_pnp_driver); | 782 | i = pnp_register_driver(&cs4232_pnp_driver); |
762 | if (i > 0) | 783 | if (i >= 0) { |
784 | pnp_registered = 1; | ||
763 | cards += i; | 785 | cards += i; |
786 | } | ||
764 | #endif | 787 | #endif |
765 | i = pnp_register_card_driver(&cs423x_pnpc_driver); | 788 | i = pnp_register_card_driver(&cs423x_pnpc_driver); |
766 | if (i > 0) | 789 | if (i >= 0) { |
790 | pnpc_registered = 1; | ||
767 | cards += i; | 791 | cards += i; |
792 | } | ||
768 | if (!cards) { | 793 | if (!cards) { |
769 | #ifdef CS4232 | ||
770 | pnp_unregister_driver(&cs4232_pnp_driver); | ||
771 | #endif | ||
772 | pnp_unregister_card_driver(&cs423x_pnpc_driver); | ||
773 | platform_driver_unregister(&cs423x_nonpnp_driver); | ||
774 | #ifdef MODULE | 794 | #ifdef MODULE |
775 | printk(KERN_ERR IDENT " soundcard not found or device busy\n"); | 795 | printk(KERN_ERR IDENT " soundcard not found or device busy\n"); |
776 | #endif | 796 | #endif |
777 | return -ENODEV; | 797 | err = -ENODEV; |
798 | goto errout; | ||
778 | } | 799 | } |
779 | return 0; | 800 | return 0; |
801 | |||
802 | errout: | ||
803 | snd_cs423x_unregister_all(); | ||
804 | return err; | ||
780 | } | 805 | } |
781 | 806 | ||
782 | static void __exit alsa_card_cs423x_exit(void) | 807 | static void __exit alsa_card_cs423x_exit(void) |
783 | { | 808 | { |
784 | #ifdef CS4232 | 809 | snd_cs423x_unregister_all(); |
785 | pnp_unregister_driver(&cs4232_pnp_driver); | ||
786 | #endif | ||
787 | pnp_unregister_card_driver(&cs423x_pnpc_driver); | ||
788 | platform_driver_unregister(&cs423x_nonpnp_driver); | ||
789 | } | 810 | } |
790 | 811 | ||
791 | module_init(alsa_card_cs423x_init) | 812 | module_init(alsa_card_cs423x_init) |
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 68bd40a76f01..50d23cf3d7cc 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c | |||
@@ -69,6 +69,8 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); | |||
69 | module_param_array(dma8, int, NULL, 0444); | 69 | module_param_array(dma8, int, NULL, 0444); |
70 | MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); | 70 | MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); |
71 | 71 | ||
72 | static struct platform_device *devices[SNDRV_CARDS]; | ||
73 | |||
72 | #define PFX "es1688: " | 74 | #define PFX "es1688: " |
73 | 75 | ||
74 | static int __init snd_es1688_probe(struct platform_device *pdev) | 76 | static int __init snd_es1688_probe(struct platform_device *pdev) |
@@ -187,6 +189,15 @@ static struct platform_driver snd_es1688_driver = { | |||
187 | }, | 189 | }, |
188 | }; | 190 | }; |
189 | 191 | ||
192 | static void __init_or_module snd_es1688_unregister_all(void) | ||
193 | { | ||
194 | int i; | ||
195 | |||
196 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
197 | platform_device_unregister(devices[i]); | ||
198 | platform_driver_unregister(&snd_es1688_driver); | ||
199 | } | ||
200 | |||
190 | static int __init alsa_card_es1688_init(void) | 201 | static int __init alsa_card_es1688_init(void) |
191 | { | 202 | { |
192 | int i, cards, err; | 203 | int i, cards, err; |
@@ -204,6 +215,7 @@ static int __init alsa_card_es1688_init(void) | |||
204 | err = PTR_ERR(device); | 215 | err = PTR_ERR(device); |
205 | goto errout; | 216 | goto errout; |
206 | } | 217 | } |
218 | devices[i] = device; | ||
207 | cards++; | 219 | cards++; |
208 | } | 220 | } |
209 | if (!cards) { | 221 | if (!cards) { |
@@ -216,13 +228,13 @@ static int __init alsa_card_es1688_init(void) | |||
216 | return 0; | 228 | return 0; |
217 | 229 | ||
218 | errout: | 230 | errout: |
219 | platform_driver_unregister(&snd_es1688_driver); | 231 | snd_es1688_unregister_all(); |
220 | return err; | 232 | return err; |
221 | } | 233 | } |
222 | 234 | ||
223 | static void __exit alsa_card_es1688_exit(void) | 235 | static void __exit alsa_card_es1688_exit(void) |
224 | { | 236 | { |
225 | platform_driver_unregister(&snd_es1688_driver); | 237 | snd_es1688_unregister_all(); |
226 | } | 238 | } |
227 | 239 | ||
228 | module_init(alsa_card_es1688_init) | 240 | module_init(alsa_card_es1688_init) |
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 34d47132f082..bf5de0782eb0 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c | |||
@@ -1877,6 +1877,9 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver."); | |||
1877 | module_param_array(dma2, int, NULL, 0444); | 1877 | module_param_array(dma2, int, NULL, 0444); |
1878 | MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); | 1878 | MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); |
1879 | 1879 | ||
1880 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
1881 | static int pnp_registered; | ||
1882 | |||
1880 | #ifdef CONFIG_PNP | 1883 | #ifdef CONFIG_PNP |
1881 | 1884 | ||
1882 | static struct pnp_card_device_id snd_audiodrive_pnpids[] = { | 1885 | static struct pnp_card_device_id snd_audiodrive_pnpids[] = { |
@@ -2202,6 +2205,17 @@ static struct pnp_card_driver es18xx_pnpc_driver = { | |||
2202 | }; | 2205 | }; |
2203 | #endif /* CONFIG_PNP */ | 2206 | #endif /* CONFIG_PNP */ |
2204 | 2207 | ||
2208 | static void __init_or_module snd_es18xx_unregister_all(void) | ||
2209 | { | ||
2210 | int i; | ||
2211 | |||
2212 | if (pnp_registered) | ||
2213 | pnp_unregister_card_driver(&es18xx_pnpc_driver); | ||
2214 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
2215 | platform_device_unregister(platform_devices[i]); | ||
2216 | platform_driver_unregister(&snd_es18xx_nonpnp_driver); | ||
2217 | } | ||
2218 | |||
2205 | static int __init alsa_card_es18xx_init(void) | 2219 | static int __init alsa_card_es18xx_init(void) |
2206 | { | 2220 | { |
2207 | int i, err, cards = 0; | 2221 | int i, err, cards = 0; |
@@ -2217,31 +2231,35 @@ static int __init alsa_card_es18xx_init(void) | |||
2217 | i, NULL, 0); | 2231 | i, NULL, 0); |
2218 | if (IS_ERR(device)) { | 2232 | if (IS_ERR(device)) { |
2219 | err = PTR_ERR(device); | 2233 | err = PTR_ERR(device); |
2220 | platform_driver_unregister(&snd_es18xx_nonpnp_driver); | 2234 | goto errout; |
2221 | return err; | ||
2222 | } | 2235 | } |
2236 | platform_devices[i] = device; | ||
2223 | cards++; | 2237 | cards++; |
2224 | } | 2238 | } |
2225 | 2239 | ||
2226 | i = pnp_register_card_driver(&es18xx_pnpc_driver); | 2240 | i = pnp_register_card_driver(&es18xx_pnpc_driver); |
2227 | if (i > 0) | 2241 | if (i >= 0) { |
2242 | pnp_registered = 1; | ||
2228 | cards += i; | 2243 | cards += i; |
2244 | } | ||
2229 | 2245 | ||
2230 | if(!cards) { | 2246 | if(!cards) { |
2231 | pnp_unregister_card_driver(&es18xx_pnpc_driver); | ||
2232 | platform_driver_unregister(&snd_es18xx_nonpnp_driver); | ||
2233 | #ifdef MODULE | 2247 | #ifdef MODULE |
2234 | snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); | 2248 | snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); |
2235 | #endif | 2249 | #endif |
2236 | return -ENODEV; | 2250 | err = -ENODEV; |
2251 | goto errout; | ||
2237 | } | 2252 | } |
2238 | return 0; | 2253 | return 0; |
2254 | |||
2255 | errout: | ||
2256 | snd_es18xx_unregister_all(); | ||
2257 | return err; | ||
2239 | } | 2258 | } |
2240 | 2259 | ||
2241 | static void __exit alsa_card_es18xx_exit(void) | 2260 | static void __exit alsa_card_es18xx_exit(void) |
2242 | { | 2261 | { |
2243 | pnp_unregister_card_driver(&es18xx_pnpc_driver); | 2262 | snd_es18xx_unregister_all(); |
2244 | platform_driver_unregister(&snd_es18xx_nonpnp_driver); | ||
2245 | } | 2263 | } |
2246 | 2264 | ||
2247 | module_init(alsa_card_es18xx_init) | 2265 | module_init(alsa_card_es18xx_init) |
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 57beb74f5b9d..d1165b96fa3f 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c | |||
@@ -71,6 +71,8 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); | |||
71 | module_param_array(pcm_channels, int, NULL, 0444); | 71 | module_param_array(pcm_channels, int, NULL, 0444); |
72 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); | 72 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); |
73 | 73 | ||
74 | static struct platform_device *devices[SNDRV_CARDS]; | ||
75 | |||
74 | 76 | ||
75 | #define PFX "gusclassic: " | 77 | #define PFX "gusclassic: " |
76 | 78 | ||
@@ -227,6 +229,15 @@ static struct platform_driver snd_gusclassic_driver = { | |||
227 | }, | 229 | }, |
228 | }; | 230 | }; |
229 | 231 | ||
232 | static void __init_or_module snd_gusclassic_unregister_all(void) | ||
233 | { | ||
234 | int i; | ||
235 | |||
236 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
237 | platform_device_unregister(devices[i]); | ||
238 | platform_driver_unregister(&snd_gusclassic_driver); | ||
239 | } | ||
240 | |||
230 | static int __init alsa_card_gusclassic_init(void) | 241 | static int __init alsa_card_gusclassic_init(void) |
231 | { | 242 | { |
232 | int i, cards, err; | 243 | int i, cards, err; |
@@ -244,6 +255,7 @@ static int __init alsa_card_gusclassic_init(void) | |||
244 | err = PTR_ERR(device); | 255 | err = PTR_ERR(device); |
245 | goto errout; | 256 | goto errout; |
246 | } | 257 | } |
258 | devices[i] = device; | ||
247 | cards++; | 259 | cards++; |
248 | } | 260 | } |
249 | if (!cards) { | 261 | if (!cards) { |
@@ -256,13 +268,13 @@ static int __init alsa_card_gusclassic_init(void) | |||
256 | return 0; | 268 | return 0; |
257 | 269 | ||
258 | errout: | 270 | errout: |
259 | platform_driver_unregister(&snd_gusclassic_driver); | 271 | snd_gusclassic_unregister_all(); |
260 | return err; | 272 | return err; |
261 | } | 273 | } |
262 | 274 | ||
263 | static void __exit alsa_card_gusclassic_exit(void) | 275 | static void __exit alsa_card_gusclassic_exit(void) |
264 | { | 276 | { |
265 | platform_driver_unregister(&snd_gusclassic_driver); | 277 | snd_gusclassic_unregister_all(); |
266 | } | 278 | } |
267 | 279 | ||
268 | module_init(alsa_card_gusclassic_init) | 280 | module_init(alsa_card_gusclassic_init) |
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 6fad9734a853..239f16e6b9ee 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c | |||
@@ -87,6 +87,8 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); | |||
87 | module_param_array(pcm_channels, int, NULL, 0444); | 87 | module_param_array(pcm_channels, int, NULL, 0444); |
88 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); | 88 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); |
89 | 89 | ||
90 | struct platform_device *devices[SNDRV_CARDS]; | ||
91 | |||
90 | 92 | ||
91 | #define PFX "gusextreme: " | 93 | #define PFX "gusextreme: " |
92 | 94 | ||
@@ -337,6 +339,15 @@ static struct platform_driver snd_gusextreme_driver = { | |||
337 | }, | 339 | }, |
338 | }; | 340 | }; |
339 | 341 | ||
342 | static void __init_or_module snd_gusextreme_unregister_all(void) | ||
343 | { | ||
344 | int i; | ||
345 | |||
346 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
347 | platform_device_unregister(devices[i]); | ||
348 | platform_driver_unregister(&snd_gusextreme_driver); | ||
349 | } | ||
350 | |||
340 | static int __init alsa_card_gusextreme_init(void) | 351 | static int __init alsa_card_gusextreme_init(void) |
341 | { | 352 | { |
342 | int i, cards, err; | 353 | int i, cards, err; |
@@ -354,6 +365,7 @@ static int __init alsa_card_gusextreme_init(void) | |||
354 | err = PTR_ERR(device); | 365 | err = PTR_ERR(device); |
355 | goto errout; | 366 | goto errout; |
356 | } | 367 | } |
368 | devices[i] = device; | ||
357 | cards++; | 369 | cards++; |
358 | } | 370 | } |
359 | if (!cards) { | 371 | if (!cards) { |
@@ -366,13 +378,13 @@ static int __init alsa_card_gusextreme_init(void) | |||
366 | return 0; | 378 | return 0; |
367 | 379 | ||
368 | errout: | 380 | errout: |
369 | platform_driver_unregister(&snd_gusextreme_driver); | 381 | snd_gusextreme_unregister_all(); |
370 | return err; | 382 | return err; |
371 | } | 383 | } |
372 | 384 | ||
373 | static void __exit alsa_card_gusextreme_exit(void) | 385 | static void __exit alsa_card_gusextreme_exit(void) |
374 | { | 386 | { |
375 | platform_driver_unregister(&snd_gusextreme_driver); | 387 | snd_gusextreme_unregister_all(); |
376 | } | 388 | } |
377 | 389 | ||
378 | module_init(alsa_card_gusextreme_init) | 390 | module_init(alsa_card_gusextreme_init) |
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index d1b70ee9b039..d4d2b2a517d5 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c | |||
@@ -72,6 +72,8 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver."); | |||
72 | module_param_array(pcm_channels, int, NULL, 0444); | 72 | module_param_array(pcm_channels, int, NULL, 0444); |
73 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); | 73 | MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); |
74 | 74 | ||
75 | static struct platform_device *devices[SNDRV_CARDS]; | ||
76 | |||
75 | struct snd_gusmax { | 77 | struct snd_gusmax { |
76 | int irq; | 78 | int irq; |
77 | struct snd_card *card; | 79 | struct snd_card *card; |
@@ -364,6 +366,15 @@ static struct platform_driver snd_gusmax_driver = { | |||
364 | }, | 366 | }, |
365 | }; | 367 | }; |
366 | 368 | ||
369 | static void __init_or_module snd_gusmax_unregister_all(void) | ||
370 | { | ||
371 | int i; | ||
372 | |||
373 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
374 | platform_device_unregister(devices[i]); | ||
375 | platform_driver_unregister(&snd_gusmax_driver); | ||
376 | } | ||
377 | |||
367 | static int __init alsa_card_gusmax_init(void) | 378 | static int __init alsa_card_gusmax_init(void) |
368 | { | 379 | { |
369 | int i, cards, err; | 380 | int i, cards, err; |
@@ -381,6 +392,7 @@ static int __init alsa_card_gusmax_init(void) | |||
381 | err = PTR_ERR(device); | 392 | err = PTR_ERR(device); |
382 | goto errout; | 393 | goto errout; |
383 | } | 394 | } |
395 | devices[i] = device; | ||
384 | cards++; | 396 | cards++; |
385 | } | 397 | } |
386 | if (!cards) { | 398 | if (!cards) { |
@@ -393,13 +405,13 @@ static int __init alsa_card_gusmax_init(void) | |||
393 | return 0; | 405 | return 0; |
394 | 406 | ||
395 | errout: | 407 | errout: |
396 | platform_driver_unregister(&snd_gusmax_driver); | 408 | snd_gusmax_unregister_all(); |
397 | return err; | 409 | return err; |
398 | } | 410 | } |
399 | 411 | ||
400 | static void __exit alsa_card_gusmax_exit(void) | 412 | static void __exit alsa_card_gusmax_exit(void) |
401 | { | 413 | { |
402 | platform_driver_unregister(&snd_gusmax_driver); | 414 | snd_gusmax_unregister_all(); |
403 | } | 415 | } |
404 | 416 | ||
405 | module_init(alsa_card_gusmax_init) | 417 | module_init(alsa_card_gusmax_init) |
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 67a5f7402453..9838d992b101 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c | |||
@@ -115,6 +115,9 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver."); | |||
115 | module_param_array(effect, int, NULL, 0444); | 115 | module_param_array(effect, int, NULL, 0444); |
116 | MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); | 116 | MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); |
117 | 117 | ||
118 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
119 | static int pnp_registered; | ||
120 | |||
118 | struct snd_interwave { | 121 | struct snd_interwave { |
119 | int irq; | 122 | int irq; |
120 | struct snd_card *card; | 123 | struct snd_card *card; |
@@ -914,6 +917,17 @@ static struct pnp_card_driver interwave_pnpc_driver = { | |||
914 | 917 | ||
915 | #endif /* CONFIG_PNP */ | 918 | #endif /* CONFIG_PNP */ |
916 | 919 | ||
920 | static void __init_or_module snd_interwave_unregister_all(void) | ||
921 | { | ||
922 | int i; | ||
923 | |||
924 | if (pnp_registered) | ||
925 | pnp_unregister_card_driver(&interwave_pnpc_driver); | ||
926 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
927 | platform_device_unregister(platform_devices[i]); | ||
928 | platform_driver_unregister(&snd_interwave_driver); | ||
929 | } | ||
930 | |||
917 | static int __init alsa_card_interwave_init(void) | 931 | static int __init alsa_card_interwave_init(void) |
918 | { | 932 | { |
919 | int i, err, cards = 0; | 933 | int i, err, cards = 0; |
@@ -931,32 +945,36 @@ static int __init alsa_card_interwave_init(void) | |||
931 | i, NULL, 0); | 945 | i, NULL, 0); |
932 | if (IS_ERR(device)) { | 946 | if (IS_ERR(device)) { |
933 | err = PTR_ERR(device); | 947 | err = PTR_ERR(device); |
934 | platform_driver_unregister(&snd_interwave_driver); | 948 | goto errout; |
935 | return err; | ||
936 | } | 949 | } |
950 | platform_devices[i] = device; | ||
937 | cards++; | 951 | cards++; |
938 | } | 952 | } |
939 | 953 | ||
940 | /* ISA PnP cards */ | 954 | /* ISA PnP cards */ |
941 | i = pnp_register_card_driver(&interwave_pnpc_driver); | 955 | i = pnp_register_card_driver(&interwave_pnpc_driver); |
942 | if (i > 0) | 956 | if (i >= 0) { |
957 | pnp_registered = 1; | ||
943 | cards += i; | 958 | cards += i; |
959 | } | ||
944 | 960 | ||
945 | if (!cards) { | 961 | if (!cards) { |
946 | pnp_unregister_card_driver(&interwave_pnpc_driver); | ||
947 | platform_driver_unregister(&snd_interwave_driver); | ||
948 | #ifdef MODULE | 962 | #ifdef MODULE |
949 | printk(KERN_ERR "InterWave soundcard not found or device busy\n"); | 963 | printk(KERN_ERR "InterWave soundcard not found or device busy\n"); |
950 | #endif | 964 | #endif |
951 | return -ENODEV; | 965 | err = -ENODEV; |
966 | goto errout; | ||
952 | } | 967 | } |
953 | return 0; | 968 | return 0; |
969 | |||
970 | errout: | ||
971 | snd_interwave_unregister_all(); | ||
972 | return err; | ||
954 | } | 973 | } |
955 | 974 | ||
956 | static void __exit alsa_card_interwave_exit(void) | 975 | static void __exit alsa_card_interwave_exit(void) |
957 | { | 976 | { |
958 | pnp_unregister_card_driver(&interwave_pnpc_driver); | 977 | snd_interwave_unregister_all(); |
959 | platform_driver_unregister(&snd_interwave_driver); | ||
960 | } | 978 | } |
961 | 979 | ||
962 | module_init(alsa_card_interwave_init) | 980 | module_init(alsa_card_interwave_init) |
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index aafe5565b6e5..ca359e0c674b 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c | |||
@@ -90,6 +90,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver."); | |||
90 | module_param_array(opl3sa3_ymode, int, NULL, 0444); | 90 | module_param_array(opl3sa3_ymode, int, NULL, 0444); |
91 | MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); | 91 | MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); |
92 | 92 | ||
93 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
94 | static int pnp_registered; | ||
95 | static int pnpc_registered; | ||
96 | |||
93 | /* control ports */ | 97 | /* control ports */ |
94 | #define OPL3SA2_PM_CTRL 0x01 | 98 | #define OPL3SA2_PM_CTRL 0x01 |
95 | #define OPL3SA2_SYS_CTRL 0x02 | 99 | #define OPL3SA2_SYS_CTRL 0x02 |
@@ -921,6 +925,19 @@ static struct platform_driver snd_opl3sa2_nonpnp_driver = { | |||
921 | }, | 925 | }, |
922 | }; | 926 | }; |
923 | 927 | ||
928 | static void __init_or_module snd_opl3sa2_unregister_all(void) | ||
929 | { | ||
930 | int i; | ||
931 | |||
932 | if (pnpc_registered) | ||
933 | pnp_unregister_card_driver(&opl3sa2_pnpc_driver); | ||
934 | if (pnp_registered) | ||
935 | pnp_unregister_driver(&opl3sa2_pnp_driver); | ||
936 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
937 | platform_device_unregister(platform_devices[i]); | ||
938 | platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); | ||
939 | } | ||
940 | |||
924 | static int __init alsa_card_opl3sa2_init(void) | 941 | static int __init alsa_card_opl3sa2_init(void) |
925 | { | 942 | { |
926 | int i, err, cards = 0; | 943 | int i, err, cards = 0; |
@@ -938,36 +955,40 @@ static int __init alsa_card_opl3sa2_init(void) | |||
938 | i, NULL, 0); | 955 | i, NULL, 0); |
939 | if (IS_ERR(device)) { | 956 | if (IS_ERR(device)) { |
940 | err = PTR_ERR(device); | 957 | err = PTR_ERR(device); |
941 | platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); | 958 | goto errout; |
942 | return err; | ||
943 | } | 959 | } |
960 | platform_devices[i] = device; | ||
944 | cards++; | 961 | cards++; |
945 | } | 962 | } |
946 | 963 | ||
947 | err = pnp_register_driver(&opl3sa2_pnp_driver); | 964 | err = pnp_register_driver(&opl3sa2_pnp_driver); |
948 | if (err > 0) | 965 | if (err >= 0) { |
966 | pnp_registered = 1; | ||
949 | cards += err; | 967 | cards += err; |
968 | } | ||
950 | err = pnp_register_card_driver(&opl3sa2_pnpc_driver); | 969 | err = pnp_register_card_driver(&opl3sa2_pnpc_driver); |
951 | if (err > 0) | 970 | if (err >= 0) { |
971 | pnpc_registered = 1; | ||
952 | cards += err; | 972 | cards += err; |
973 | } | ||
953 | 974 | ||
954 | if (!cards) { | 975 | if (!cards) { |
955 | #ifdef MODULE | 976 | #ifdef MODULE |
956 | snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); | 977 | snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); |
957 | #endif | 978 | #endif |
958 | pnp_unregister_card_driver(&opl3sa2_pnpc_driver); | 979 | err = -ENODEV; |
959 | pnp_unregister_driver(&opl3sa2_pnp_driver); | 980 | goto errout; |
960 | platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); | ||
961 | return -ENODEV; | ||
962 | } | 981 | } |
963 | return 0; | 982 | return 0; |
983 | |||
984 | errout: | ||
985 | snd_opl3sa2_unregister_all(); | ||
986 | return err; | ||
964 | } | 987 | } |
965 | 988 | ||
966 | static void __exit alsa_card_opl3sa2_exit(void) | 989 | static void __exit alsa_card_opl3sa2_exit(void) |
967 | { | 990 | { |
968 | pnp_unregister_card_driver(&opl3sa2_pnpc_driver); | 991 | snd_opl3sa2_unregister_all(); |
969 | pnp_unregister_driver(&opl3sa2_pnp_driver); | ||
970 | platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); | ||
971 | } | 992 | } |
972 | 993 | ||
973 | module_init(alsa_card_opl3sa2_init) | 994 | module_init(alsa_card_opl3sa2_init) |
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 39211e58cd68..1ea3944ef7ab 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
@@ -259,6 +259,7 @@ struct snd_opti9xx { | |||
259 | }; | 259 | }; |
260 | 260 | ||
261 | static int snd_opti9xx_pnp_is_probed; | 261 | static int snd_opti9xx_pnp_is_probed; |
262 | static struct platform_device *snd_opti9xx_platform_device; | ||
262 | 263 | ||
263 | #ifdef CONFIG_PNP | 264 | #ifdef CONFIG_PNP |
264 | 265 | ||
@@ -2095,8 +2096,10 @@ static int __init alsa_card_opti9xx_init(void) | |||
2095 | if (error < 0) | 2096 | if (error < 0) |
2096 | return error; | 2097 | return error; |
2097 | device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); | 2098 | device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); |
2098 | if (! IS_ERR(device)) | 2099 | if (!IS_ERR(device)) { |
2100 | snd_opti9xx_platform_device = device; | ||
2099 | return 0; | 2101 | return 0; |
2102 | } | ||
2100 | platform_driver_unregister(&snd_opti9xx_driver); | 2103 | platform_driver_unregister(&snd_opti9xx_driver); |
2101 | } | 2104 | } |
2102 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); | 2105 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); |
@@ -2108,8 +2111,10 @@ static int __init alsa_card_opti9xx_init(void) | |||
2108 | 2111 | ||
2109 | static void __exit alsa_card_opti9xx_exit(void) | 2112 | static void __exit alsa_card_opti9xx_exit(void) |
2110 | { | 2113 | { |
2111 | if (! snd_opti9xx_pnp_is_probed) | 2114 | if (!snd_opti9xx_pnp_is_probed) { |
2115 | platform_device_unregister(snd_opti9xx_platform_device); | ||
2112 | platform_driver_unregister(&snd_opti9xx_driver); | 2116 | platform_driver_unregister(&snd_opti9xx_driver); |
2117 | } | ||
2113 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); | 2118 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); |
2114 | } | 2119 | } |
2115 | 2120 | ||
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) |
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 0a3d55d639a9..60ee79cd14a3 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c | |||
@@ -56,6 +56,8 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver."); | |||
56 | module_param_array(dma8, int, NULL, 0444); | 56 | module_param_array(dma8, int, NULL, 0444); |
57 | MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); | 57 | MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); |
58 | 58 | ||
59 | static struct platform_device *devices[SNDRV_CARDS]; | ||
60 | |||
59 | struct snd_sb8 { | 61 | struct snd_sb8 { |
60 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */ | 62 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */ |
61 | struct snd_sb *chip; | 63 | struct snd_sb *chip; |
@@ -238,6 +240,15 @@ static struct platform_driver snd_sb8_driver = { | |||
238 | }, | 240 | }, |
239 | }; | 241 | }; |
240 | 242 | ||
243 | static void __init_or_module snd_sb8_unregister_all(void) | ||
244 | { | ||
245 | int i; | ||
246 | |||
247 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
248 | platform_device_unregister(devices[i]); | ||
249 | platform_driver_unregister(&snd_sb8_driver); | ||
250 | } | ||
251 | |||
241 | static int __init alsa_card_sb8_init(void) | 252 | static int __init alsa_card_sb8_init(void) |
242 | { | 253 | { |
243 | int i, cards, err; | 254 | int i, cards, err; |
@@ -255,6 +266,7 @@ static int __init alsa_card_sb8_init(void) | |||
255 | err = PTR_ERR(device); | 266 | err = PTR_ERR(device); |
256 | goto errout; | 267 | goto errout; |
257 | } | 268 | } |
269 | devices[i] = device; | ||
258 | cards++; | 270 | cards++; |
259 | } | 271 | } |
260 | if (!cards) { | 272 | if (!cards) { |
@@ -267,13 +279,13 @@ static int __init alsa_card_sb8_init(void) | |||
267 | return 0; | 279 | return 0; |
268 | 280 | ||
269 | errout: | 281 | errout: |
270 | platform_driver_unregister(&snd_sb8_driver); | 282 | snd_sb8_unregister_all(); |
271 | return err; | 283 | return err; |
272 | } | 284 | } |
273 | 285 | ||
274 | static void __exit alsa_card_sb8_exit(void) | 286 | static void __exit alsa_card_sb8_exit(void) |
275 | { | 287 | { |
276 | platform_driver_unregister(&snd_sb8_driver); | 288 | snd_sb8_unregister_all(); |
277 | } | 289 | } |
278 | 290 | ||
279 | module_init(alsa_card_sb8_init) | 291 | module_init(alsa_card_sb8_init) |
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 2e1d4677fe12..0dbbb35b242c 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c | |||
@@ -64,6 +64,8 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); | |||
64 | module_param_array(dma1, int, NULL, 0444); | 64 | module_param_array(dma1, int, NULL, 0444); |
65 | MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); | 65 | MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); |
66 | 66 | ||
67 | static struct platform_device *devices[SNDRV_CARDS]; | ||
68 | |||
67 | #define SGALAXY_AUXC_LEFT 18 | 69 | #define SGALAXY_AUXC_LEFT 18 |
68 | #define SGALAXY_AUXC_RIGHT 19 | 70 | #define SGALAXY_AUXC_RIGHT 19 |
69 | 71 | ||
@@ -340,6 +342,15 @@ static struct platform_driver snd_sgalaxy_driver = { | |||
340 | }, | 342 | }, |
341 | }; | 343 | }; |
342 | 344 | ||
345 | static void __init_or_module snd_sgalaxy_unregister_all(void) | ||
346 | { | ||
347 | int i; | ||
348 | |||
349 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
350 | platform_device_unregister(devices[i]); | ||
351 | platform_driver_unregister(&snd_sgalaxy_driver); | ||
352 | } | ||
353 | |||
343 | static int __init alsa_card_sgalaxy_init(void) | 354 | static int __init alsa_card_sgalaxy_init(void) |
344 | { | 355 | { |
345 | int i, cards, err; | 356 | int i, cards, err; |
@@ -357,6 +368,7 @@ static int __init alsa_card_sgalaxy_init(void) | |||
357 | err = PTR_ERR(device); | 368 | err = PTR_ERR(device); |
358 | goto errout; | 369 | goto errout; |
359 | } | 370 | } |
371 | devices[i] = device; | ||
360 | cards++; | 372 | cards++; |
361 | } | 373 | } |
362 | if (!cards) { | 374 | if (!cards) { |
@@ -369,13 +381,13 @@ static int __init alsa_card_sgalaxy_init(void) | |||
369 | return 0; | 381 | return 0; |
370 | 382 | ||
371 | errout: | 383 | errout: |
372 | platform_driver_unregister(&snd_sgalaxy_driver); | 384 | snd_sgalaxy_unregister_all(); |
373 | return err; | 385 | return err; |
374 | } | 386 | } |
375 | 387 | ||
376 | static void __exit alsa_card_sgalaxy_exit(void) | 388 | static void __exit alsa_card_sgalaxy_exit(void) |
377 | { | 389 | { |
378 | platform_driver_unregister(&snd_sgalaxy_driver); | 390 | snd_sgalaxy_unregister_all(); |
379 | } | 391 | } |
380 | 392 | ||
381 | module_init(alsa_card_sgalaxy_init) | 393 | module_init(alsa_card_sgalaxy_init) |
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 6271efe689df..5fb981c0a281 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c | |||
@@ -67,6 +67,9 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver."); | |||
67 | 67 | ||
68 | module_param_array(dma, int, NULL, 0444); | 68 | module_param_array(dma, int, NULL, 0444); |
69 | MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); | 69 | MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); |
70 | |||
71 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
72 | static int pnp_registered; | ||
70 | 73 | ||
71 | #ifdef CONFIG_PNP | 74 | #ifdef CONFIG_PNP |
72 | static struct pnp_card_device_id sscape_pnpids[] = { | 75 | static struct pnp_card_device_id sscape_pnpids[] = { |
@@ -1384,6 +1387,17 @@ static struct pnp_card_driver sscape_pnpc_driver = { | |||
1384 | 1387 | ||
1385 | #endif /* CONFIG_PNP */ | 1388 | #endif /* CONFIG_PNP */ |
1386 | 1389 | ||
1390 | static void __init_or_module sscape_unregister_all(void) | ||
1391 | { | ||
1392 | int i; | ||
1393 | |||
1394 | if (pnp_registered) | ||
1395 | pnp_unregister_card_driver(&sscape_pnpc_driver); | ||
1396 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
1397 | platform_device_unregister(platform_devices[i]); | ||
1398 | platform_driver_unregister(&snd_sscape_driver); | ||
1399 | } | ||
1400 | |||
1387 | static int __init sscape_manual_probe(void) | 1401 | static int __init sscape_manual_probe(void) |
1388 | { | 1402 | { |
1389 | struct platform_device *device; | 1403 | struct platform_device *device; |
@@ -1411,8 +1425,8 @@ static int __init sscape_manual_probe(void) | |||
1411 | dma[i] == SNDRV_AUTO_DMA) { | 1425 | dma[i] == SNDRV_AUTO_DMA) { |
1412 | printk(KERN_INFO | 1426 | printk(KERN_INFO |
1413 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); | 1427 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); |
1414 | platform_driver_unregister(&snd_sscape_driver); | 1428 | ret = -ENXIO; |
1415 | return -ENXIO; | 1429 | goto errout; |
1416 | } | 1430 | } |
1417 | 1431 | ||
1418 | /* | 1432 | /* |
@@ -1421,17 +1435,21 @@ static int __init sscape_manual_probe(void) | |||
1421 | device = platform_device_register_simple(SSCAPE_DRIVER, | 1435 | device = platform_device_register_simple(SSCAPE_DRIVER, |
1422 | i, NULL, 0); | 1436 | i, NULL, 0); |
1423 | if (IS_ERR(device)) { | 1437 | if (IS_ERR(device)) { |
1424 | platform_driver_unregister(&snd_sscape_driver); | 1438 | ret = PTR_ERR(device); |
1425 | return PTR_ERR(device); | 1439 | goto errout; |
1426 | } | 1440 | } |
1441 | platform_devices[i] = device; | ||
1427 | } | 1442 | } |
1428 | return 0; | 1443 | return 0; |
1444 | |||
1445 | errout: | ||
1446 | sscape_unregister_all(); | ||
1447 | return ret; | ||
1429 | } | 1448 | } |
1430 | 1449 | ||
1431 | static void sscape_exit(void) | 1450 | static void sscape_exit(void) |
1432 | { | 1451 | { |
1433 | pnp_unregister_card_driver(&sscape_pnpc_driver); | 1452 | sscape_unregister_all(); |
1434 | platform_driver_unregister(&snd_sscape_driver); | ||
1435 | } | 1453 | } |
1436 | 1454 | ||
1437 | 1455 | ||
@@ -1448,7 +1466,8 @@ static int __init sscape_init(void) | |||
1448 | ret = sscape_manual_probe(); | 1466 | ret = sscape_manual_probe(); |
1449 | if (ret < 0) | 1467 | if (ret < 0) |
1450 | return ret; | 1468 | return ret; |
1451 | pnp_register_card_driver(&sscape_pnpc_driver); | 1469 | if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0) |
1470 | pnp_registered = 1; | ||
1452 | return 0; | 1471 | return 0; |
1453 | } | 1472 | } |
1454 | 1473 | ||
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 #."); | |||
83 | module_param_array(use_cs4232_midi, bool, NULL, 0444); | 83 | module_param_array(use_cs4232_midi, bool, NULL, 0444); |
84 | MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); | 84 | MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); |
85 | 85 | ||
86 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
87 | static 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 | ||
694 | static 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 | |||
691 | static int __init alsa_card_wavefront_init(void) | 705 | static 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 | ||
728 | static void __exit alsa_card_wavefront_exit(void) | 748 | static 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 | ||
734 | module_init(alsa_card_wavefront_init) | 753 | module_init(alsa_card_wavefront_init) |