aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-12-07 03:13:42 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:30:39 -0500
commitf7a9275d949cb0bf1f259a1546e52a0bf518151c (patch)
tree4d96d9b6196d43684903857ba676dc51bbde4026 /sound/drivers
parent416c1079d30f1a52399b96f6772e993274b774ae (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/drivers')
-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
5 files changed, 60 insertions, 13 deletions
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)