aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
Diffstat (limited to 'sound')
-rw-r--r--sound/arm/sa11xx-uda1341.c6
-rw-r--r--sound/drivers/dummy.c16
-rw-r--r--sound/drivers/mpu401/mpu401.c21
-rw-r--r--sound/drivers/mtpav.c4
-rw-r--r--sound/drivers/serial-u16550.c16
-rw-r--r--sound/drivers/virmidi.c16
-rw-r--r--sound/isa/ad1848/ad1848.c16
-rw-r--r--sound/isa/cmi8330.c34
-rw-r--r--sound/isa/cs423x/cs4231.c16
-rw-r--r--sound/isa/cs423x/cs4236.c51
-rw-r--r--sound/isa/es1688/es1688.c16
-rw-r--r--sound/isa/es18xx.c34
-rw-r--r--sound/isa/gus/gusclassic.c16
-rw-r--r--sound/isa/gus/gusextreme.c16
-rw-r--r--sound/isa/gus/gusmax.c16
-rw-r--r--sound/isa/gus/interwave.c34
-rw-r--r--sound/isa/opl3sa2.c43
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c9
-rw-r--r--sound/isa/sb/sb16.c42
-rw-r--r--sound/isa/sb/sb8.c16
-rw-r--r--sound/isa/sgalaxy.c16
-rw-r--r--sound/isa/sscape.c33
-rw-r--r--sound/isa/wavefront/wavefront.c35
-rw-r--r--sound/ppc/powermac.c4
24 files changed, 415 insertions, 111 deletions
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index 3c342c1a7c80..13057d92f08a 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -21,7 +21,7 @@
21 * merged HAL layer (patches from Brian) 21 * merged HAL layer (patches from Brian)
22 */ 22 */
23 23
24/* $Id: sa11xx-uda1341.c,v 1.26 2005/11/17 17:19:50 tiwai Exp $ */ 24/* $Id: sa11xx-uda1341.c,v 1.27 2005/12/07 09:13:42 cladisch Exp $ */
25 25
26/*************************************************************************************************** 26/***************************************************************************************************
27* 27*
@@ -155,6 +155,8 @@ static struct snd_pcm_hw_constraint_list hw_constraints_rates = {
155 .mask = 0, 155 .mask = 0,
156}; 156};
157 157
158static struct platform_device *device;
159
158/* }}} */ 160/* }}} */
159 161
160/* {{{ Clock and sample rate stuff */ 162/* {{{ Clock and sample rate stuff */
@@ -976,7 +978,6 @@ static struct platform_driver sa11xx_uda1341_driver = {
976static int __init sa11xx_uda1341_init(void) 978static int __init sa11xx_uda1341_init(void)
977{ 979{
978 int err; 980 int err;
979 struct platform_device *device;
980 981
981 if (!machine_is_h3xxx()) 982 if (!machine_is_h3xxx())
982 return -ENODEV; 983 return -ENODEV;
@@ -992,6 +993,7 @@ static int __init sa11xx_uda1341_init(void)
992 993
993static void __exit sa11xx_uda1341_exit(void) 994static void __exit sa11xx_uda1341_exit(void)
994{ 995{
996 platform_device_unregister(device);
995 platform_driver_unregister(&sa11xx_uda1341_driver); 997 platform_driver_unregister(&sa11xx_uda1341_driver);
996} 998}
997 999
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 186117571745..96d207051628 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -144,6 +144,8 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver.");
144//module_param_array(midi_devs, int, NULL, 0444); 144//module_param_array(midi_devs, int, NULL, 0444);
145//MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver."); 145//MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
146 146
147static struct platform_device *devices[SNDRV_CARDS];
148
147#define MIXER_ADDR_MASTER 0 149#define MIXER_ADDR_MASTER 0
148#define MIXER_ADDR_LINE 1 150#define MIXER_ADDR_LINE 1
149#define MIXER_ADDR_MIC 2 151#define MIXER_ADDR_MIC 2
@@ -634,6 +636,15 @@ static struct platform_driver snd_dummy_driver = {
634 }, 636 },
635}; 637};
636 638
639static void __init_or_module snd_dummy_unregister_all(void)
640{
641 int i;
642
643 for (i = 0; i < ARRAY_SIZE(devices); ++i)
644 platform_device_unregister(devices[i]);
645 platform_driver_unregister(&snd_dummy_driver);
646}
647
637static int __init alsa_card_dummy_init(void) 648static int __init alsa_card_dummy_init(void)
638{ 649{
639 int i, cards, err; 650 int i, cards, err;
@@ -650,6 +661,7 @@ static int __init alsa_card_dummy_init(void)
650 err = PTR_ERR(device); 661 err = PTR_ERR(device);
651 goto errout; 662 goto errout;
652 } 663 }
664 devices[i] = device;
653 cards++; 665 cards++;
654 } 666 }
655 if (!cards) { 667 if (!cards) {
@@ -662,13 +674,13 @@ static int __init alsa_card_dummy_init(void)
662 return 0; 674 return 0;
663 675
664 errout: 676 errout:
665 platform_driver_unregister(&snd_dummy_driver); 677 snd_dummy_unregister_all();
666 return err; 678 return err;
667} 679}
668 680
669static void __exit alsa_card_dummy_exit(void) 681static void __exit alsa_card_dummy_exit(void)
670{ 682{
671 platform_driver_unregister(&snd_dummy_driver); 683 snd_dummy_unregister_all();
672} 684}
673 685
674module_init(alsa_card_dummy_init) 686module_init(alsa_card_dummy_init)
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index ec817a86d3dd..915589a402ab 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -58,6 +58,7 @@ MODULE_PARM_DESC(port, "Port # for MPU-401 device.");
58module_param_array(irq, int, NULL, 0444); 58module_param_array(irq, int, NULL, 0444);
59MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); 59MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
60 60
61static struct platform_device *platform_devices[SNDRV_CARDS];
61static int pnp_registered = 0; 62static int pnp_registered = 0;
62 63
63static int snd_mpu401_create(int dev, struct snd_card **rcard) 64static int snd_mpu401_create(int dev, struct snd_card **rcard)
@@ -220,6 +221,17 @@ static struct pnp_driver snd_mpu401_pnp_driver = {
220static struct pnp_driver snd_mpu401_pnp_driver; 221static struct pnp_driver snd_mpu401_pnp_driver;
221#endif 222#endif
222 223
224static void __init_or_module snd_mpu401_unregister_all(void)
225{
226 int i;
227
228 if (pnp_registered)
229 pnp_unregister_driver(&snd_mpu401_pnp_driver);
230 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
231 platform_device_unregister(platform_devices[i]);
232 platform_driver_unregister(&snd_mpu401_driver);
233}
234
223static int __init alsa_card_mpu401_init(void) 235static int __init alsa_card_mpu401_init(void)
224{ 236{
225 int i, err, devices; 237 int i, err, devices;
@@ -240,6 +252,7 @@ static int __init alsa_card_mpu401_init(void)
240 err = PTR_ERR(device); 252 err = PTR_ERR(device);
241 goto errout; 253 goto errout;
242 } 254 }
255 platform_devices[i] = device;
243 devices++; 256 devices++;
244 } 257 }
245 if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) { 258 if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) {
@@ -257,17 +270,13 @@ static int __init alsa_card_mpu401_init(void)
257 return 0; 270 return 0;
258 271
259 errout: 272 errout:
260 if (pnp_registered) 273 snd_mpu401_unregister_all();
261 pnp_unregister_driver(&snd_mpu401_pnp_driver);
262 platform_driver_unregister(&snd_mpu401_driver);
263 return err; 274 return err;
264} 275}
265 276
266static void __exit alsa_card_mpu401_exit(void) 277static void __exit alsa_card_mpu401_exit(void)
267{ 278{
268 if (pnp_registered) 279 snd_mpu401_unregister_all();
269 pnp_unregister_driver(&snd_mpu401_pnp_driver);
270 platform_driver_unregister(&snd_mpu401_driver);
271} 280}
272 281
273module_init(alsa_card_mpu401_init) 282module_init(alsa_card_mpu401_init)
diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
index d9c4e224fa5f..b7a0b42813e1 100644
--- a/sound/drivers/mtpav.c
+++ b/sound/drivers/mtpav.c
@@ -95,6 +95,8 @@ MODULE_PARM_DESC(irq, "Parallel IRQ # for MotuMTPAV MIDI.");
95module_param(hwports, int, 0444); 95module_param(hwports, int, 0444);
96MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI."); 96MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI.");
97 97
98static struct platform_device *device;
99
98/* 100/*
99 * defines 101 * defines
100 */ 102 */
@@ -763,7 +765,6 @@ static struct platform_driver snd_mtpav_driver = {
763static int __init alsa_card_mtpav_init(void) 765static int __init alsa_card_mtpav_init(void)
764{ 766{
765 int err; 767 int err;
766 struct platform_device *device;
767 768
768 if ((err = platform_driver_register(&snd_mtpav_driver)) < 0) 769 if ((err = platform_driver_register(&snd_mtpav_driver)) < 0)
769 return err; 770 return err;
@@ -778,6 +779,7 @@ static int __init alsa_card_mtpav_init(void)
778 779
779static void __exit alsa_card_mtpav_exit(void) 780static void __exit alsa_card_mtpav_exit(void)
780{ 781{
782 platform_device_unregister(device);
781 platform_driver_unregister(&snd_mtpav_driver); 783 platform_driver_unregister(&snd_mtpav_driver);
782} 784}
783 785
diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c
index 3381a43c592e..29676d800cae 100644
--- a/sound/drivers/serial-u16550.c
+++ b/sound/drivers/serial-u16550.c
@@ -168,6 +168,8 @@ typedef struct _snd_uart16550 {
168 168
169} snd_uart16550_t; 169} snd_uart16550_t;
170 170
171static struct platform_device *devices[SNDRV_CARDS];
172
171static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) 173static inline void snd_uart16550_add_timer(snd_uart16550_t *uart)
172{ 174{
173 if (! uart->timer_running) { 175 if (! uart->timer_running) {
@@ -970,6 +972,15 @@ static struct platform_driver snd_serial_driver = {
970 }, 972 },
971}; 973};
972 974
975static void __init_or_module snd_serial_unregister_all(void)
976{
977 int i;
978
979 for (i = 0; i < ARRAY_SIZE(devices); ++i)
980 platform_device_unregister(devices[i]);
981 platform_driver_unregister(&snd_serial_driver);
982}
983
973static int __init alsa_card_serial_init(void) 984static int __init alsa_card_serial_init(void)
974{ 985{
975 int i, cards, err; 986 int i, cards, err;
@@ -986,6 +997,7 @@ static int __init alsa_card_serial_init(void)
986 err = PTR_ERR(device); 997 err = PTR_ERR(device);
987 goto errout; 998 goto errout;
988 } 999 }
1000 devices[i] = device;
989 cards++; 1001 cards++;
990 } 1002 }
991 if (! cards) { 1003 if (! cards) {
@@ -998,13 +1010,13 @@ static int __init alsa_card_serial_init(void)
998 return 0; 1010 return 0;
999 1011
1000 errout: 1012 errout:
1001 platform_driver_unregister(&snd_serial_driver); 1013 snd_serial_unregister_all();
1002 return err; 1014 return err;
1003} 1015}
1004 1016
1005static void __exit alsa_card_serial_exit(void) 1017static void __exit alsa_card_serial_exit(void)
1006{ 1018{
1007 platform_driver_unregister(&snd_serial_driver); 1019 snd_serial_unregister_all();
1008} 1020}
1009 1021
1010module_init(alsa_card_serial_init) 1022module_init(alsa_card_serial_init)
diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c
index 9f36a6472478..4258723de2ab 100644
--- a/sound/drivers/virmidi.c
+++ b/sound/drivers/virmidi.c
@@ -82,6 +82,8 @@ struct snd_card_virmidi {
82 struct snd_rawmidi *midi[MAX_MIDI_DEVICES]; 82 struct snd_rawmidi *midi[MAX_MIDI_DEVICES];
83}; 83};
84 84
85static struct platform_device *devices[SNDRV_CARDS];
86
85 87
86static int __init snd_virmidi_probe(struct platform_device *devptr) 88static int __init snd_virmidi_probe(struct platform_device *devptr)
87{ 89{
@@ -144,6 +146,15 @@ static struct platform_driver snd_virmidi_driver = {
144 }, 146 },
145}; 147};
146 148
149static void __init_or_module snd_virmidi_unregister_all(void)
150{
151 int i;
152
153 for (i = 0; i < ARRAY_SIZE(devices); ++i)
154 platform_device_unregister(devices[i]);
155 platform_driver_unregister(&snd_virmidi_driver);
156}
157
147static int __init alsa_card_virmidi_init(void) 158static int __init alsa_card_virmidi_init(void)
148{ 159{
149 int i, cards, err; 160 int i, cards, err;
@@ -160,6 +171,7 @@ static int __init alsa_card_virmidi_init(void)
160 err = PTR_ERR(device); 171 err = PTR_ERR(device);
161 goto errout; 172 goto errout;
162 } 173 }
174 devices[i] = device;
163 cards++; 175 cards++;
164 } 176 }
165 if (!cards) { 177 if (!cards) {
@@ -172,13 +184,13 @@ static int __init alsa_card_virmidi_init(void)
172 return 0; 184 return 0;
173 185
174 errout: 186 errout:
175 platform_driver_unregister(&snd_virmidi_driver); 187 snd_virmidi_unregister_all();
176 return err; 188 return err;
177} 189}
178 190
179static void __exit alsa_card_virmidi_exit(void) 191static void __exit alsa_card_virmidi_exit(void)
180{ 192{
181 platform_driver_unregister(&snd_virmidi_driver); 193 snd_virmidi_unregister_all();
182} 194}
183 195
184module_init(alsa_card_virmidi_init) 196module_init(alsa_card_virmidi_init)
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.");
62module_param_array(thinkpad, bool, NULL, 0444); 62module_param_array(thinkpad, bool, NULL, 0444);
63MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); 63MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series.");
64 64
65static struct platform_device *devices[SNDRV_CARDS];
66
65 67
66static int __init snd_ad1848_probe(struct platform_device *pdev) 68static 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
172static 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
170static int __init alsa_card_ad1848_init(void) 181static 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
203static void __exit alsa_card_ad1848_exit(void) 215static 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
208module_init(alsa_card_ad1848_init) 220module_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.");
108module_param_array(wssdma, int, NULL, 0444); 108module_param_array(wssdma, int, NULL, 0444);
109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); 109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
110 110
111static struct platform_device *platform_devices[SNDRV_CARDS];
112static 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
671static 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
668static int __init alsa_card_cmi8330_init(void) 682static 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
704static void __exit alsa_card_cmi8330_exit(void) 723static 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
710module_init(alsa_card_cmi8330_init) 728module_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.");
66module_param_array(dma2, int, NULL, 0444); 66module_param_array(dma2, int, NULL, 0444);
67MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); 67MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver.");
68 68
69static struct platform_device *devices[SNDRV_CARDS];
70
69 71
70static int __init snd_cs4231_probe(struct platform_device *pdev) 72static 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
188static 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
186static int __init alsa_card_cs4231_init(void) 197static 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
219static void __exit alsa_card_cs4231_exit(void) 231static 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
224module_init(alsa_card_cs4231_init) 236module_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.");
124module_param_array(dma2, int, NULL, 0444); 124module_param_array(dma2, int, NULL, 0444);
125MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 125MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
126 126
127static struct platform_device *platform_devices[SNDRV_CARDS];
128static int pnpc_registered;
129#ifdef CS4232
130static int pnp_registered;
131#endif
132
127struct snd_card_cs4236 { 133struct 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
746static 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
740static int __init alsa_card_cs423x_init(void) 761static 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
782static void __exit alsa_card_cs423x_exit(void) 807static 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
791module_init(alsa_card_cs423x_init) 812module_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.");
69module_param_array(dma8, int, NULL, 0444); 69module_param_array(dma8, int, NULL, 0444);
70MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); 70MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver.");
71 71
72static struct platform_device *devices[SNDRV_CARDS];
73
72#define PFX "es1688: " 74#define PFX "es1688: "
73 75
74static int __init snd_es1688_probe(struct platform_device *pdev) 76static 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
192static 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
190static int __init alsa_card_es1688_init(void) 201static 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
223static void __exit alsa_card_es1688_exit(void) 235static 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
228module_init(alsa_card_es1688_init) 240module_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.");
1877module_param_array(dma2, int, NULL, 0444); 1877module_param_array(dma2, int, NULL, 0444);
1878MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); 1878MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
1879 1879
1880static struct platform_device *platform_devices[SNDRV_CARDS];
1881static int pnp_registered;
1882
1880#ifdef CONFIG_PNP 1883#ifdef CONFIG_PNP
1881 1884
1882static struct pnp_card_device_id snd_audiodrive_pnpids[] = { 1885static 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
2208static 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
2205static int __init alsa_card_es18xx_init(void) 2219static 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
2241static void __exit alsa_card_es18xx_exit(void) 2260static 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
2247module_init(alsa_card_es18xx_init) 2265module_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.");
71module_param_array(pcm_channels, int, NULL, 0444); 71module_param_array(pcm_channels, int, NULL, 0444);
72MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); 72MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver.");
73 73
74static 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
232static 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
230static int __init alsa_card_gusclassic_init(void) 241static 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
263static void __exit alsa_card_gusclassic_exit(void) 275static 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
268module_init(alsa_card_gusclassic_init) 280module_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.");
87module_param_array(pcm_channels, int, NULL, 0444); 87module_param_array(pcm_channels, int, NULL, 0444);
88MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); 88MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver.");
89 89
90struct 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
342static 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
340static int __init alsa_card_gusextreme_init(void) 351static 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
373static void __exit alsa_card_gusextreme_exit(void) 385static 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
378module_init(alsa_card_gusextreme_init) 390module_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.");
72module_param_array(pcm_channels, int, NULL, 0444); 72module_param_array(pcm_channels, int, NULL, 0444);
73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); 73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
74 74
75static struct platform_device *devices[SNDRV_CARDS];
76
75struct snd_gusmax { 77struct 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
369static 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
367static int __init alsa_card_gusmax_init(void) 378static 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
400static void __exit alsa_card_gusmax_exit(void) 412static 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
405module_init(alsa_card_gusmax_init) 417module_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.");
115module_param_array(effect, int, NULL, 0444); 115module_param_array(effect, int, NULL, 0444);
116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); 116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
117 117
118static struct platform_device *platform_devices[SNDRV_CARDS];
119static int pnp_registered;
120
118struct snd_interwave { 121struct 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
920static 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
917static int __init alsa_card_interwave_init(void) 931static 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
956static void __exit alsa_card_interwave_exit(void) 975static 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
962module_init(alsa_card_interwave_init) 980module_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.");
90module_param_array(opl3sa3_ymode, int, NULL, 0444); 90module_param_array(opl3sa3_ymode, int, NULL, 0444);
91MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); 91MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
92 92
93static struct platform_device *platform_devices[SNDRV_CARDS];
94static int pnp_registered;
95static 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
928static 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
924static int __init alsa_card_opl3sa2_init(void) 941static 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
966static void __exit alsa_card_opl3sa2_exit(void) 989static 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
973module_init(alsa_card_opl3sa2_init) 994module_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
261static int snd_opti9xx_pnp_is_probed; 261static int snd_opti9xx_pnp_is_probed;
262static 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
2109static void __exit alsa_card_opti9xx_exit(void) 2112static 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);
128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); 128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
129#endif 129#endif
130 130
131static struct platform_device *platform_devices[SNDRV_CARDS];
132#ifdef CONFIG_PNP
133static int pnp_registered;
134#endif
135
131struct snd_card_sb16 { 136struct 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
695static 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
690static int __init alsa_card_sb16_init(void) 708static 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
735static void __exit alsa_card_sb16_exit(void) 756static 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
743module_init(alsa_card_sb16_init) 761module_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.");
56module_param_array(dma8, int, NULL, 0444); 56module_param_array(dma8, int, NULL, 0444);
57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); 57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
58 58
59static struct platform_device *devices[SNDRV_CARDS];
60
59struct snd_sb8 { 61struct 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
243static 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
241static int __init alsa_card_sb8_init(void) 252static 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
274static void __exit alsa_card_sb8_exit(void) 286static 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
279module_init(alsa_card_sb8_init) 291module_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.");
64module_param_array(dma1, int, NULL, 0444); 64module_param_array(dma1, int, NULL, 0444);
65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); 65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
66 66
67static 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
345static 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
343static int __init alsa_card_sgalaxy_init(void) 354static 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
376static void __exit alsa_card_sgalaxy_exit(void) 388static 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
381module_init(alsa_card_sgalaxy_init) 393module_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
68module_param_array(dma, int, NULL, 0444); 68module_param_array(dma, int, NULL, 0444);
69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); 69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
70
71static struct platform_device *platform_devices[SNDRV_CARDS];
72static int pnp_registered;
70 73
71#ifdef CONFIG_PNP 74#ifdef CONFIG_PNP
72static struct pnp_card_device_id sscape_pnpids[] = { 75static 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
1390static 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
1387static int __init sscape_manual_probe(void) 1401static 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
1431static void sscape_exit(void) 1450static 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 #.");
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)
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index efa06fe5f01b..f4902a219e50 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -46,6 +46,8 @@ MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip.");
46module_param(enable_beep, bool, 0444); 46module_param(enable_beep, bool, 0444);
47MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); 47MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
48 48
49static struct platform_device *device;
50
49 51
50/* 52/*
51 */ 53 */
@@ -182,7 +184,6 @@ static struct platform_driver snd_pmac_driver = {
182static int __init alsa_card_pmac_init(void) 184static int __init alsa_card_pmac_init(void)
183{ 185{
184 int err; 186 int err;
185 struct platform_device *device;
186 187
187 if ((err = platform_driver_register(&snd_pmac_driver)) < 0) 188 if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
188 return err; 189 return err;
@@ -197,6 +198,7 @@ static int __init alsa_card_pmac_init(void)
197 198
198static void __exit alsa_card_pmac_exit(void) 199static void __exit alsa_card_pmac_exit(void)
199{ 200{
201 platform_device_unregister(device);
200 platform_driver_unregister(&snd_pmac_driver); 202 platform_driver_unregister(&snd_pmac_driver);
201} 203}
202 204