diff options
Diffstat (limited to 'sound/drivers/mpu401/mpu401.c')
-rw-r--r-- | sound/drivers/mpu401/mpu401.c | 21 |
1 files changed, 15 insertions, 6 deletions
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."); | |||
58 | module_param_array(irq, int, NULL, 0444); | 58 | module_param_array(irq, int, NULL, 0444); |
59 | MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); | 59 | MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); |
60 | 60 | ||
61 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
61 | static int pnp_registered = 0; | 62 | static int pnp_registered = 0; |
62 | 63 | ||
63 | static int snd_mpu401_create(int dev, struct snd_card **rcard) | 64 | static int snd_mpu401_create(int dev, struct snd_card **rcard) |
@@ -220,6 +221,17 @@ static struct pnp_driver snd_mpu401_pnp_driver = { | |||
220 | static struct pnp_driver snd_mpu401_pnp_driver; | 221 | static struct pnp_driver snd_mpu401_pnp_driver; |
221 | #endif | 222 | #endif |
222 | 223 | ||
224 | static 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 | |||
223 | static int __init alsa_card_mpu401_init(void) | 235 | static 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 | ||
266 | static void __exit alsa_card_mpu401_exit(void) | 277 | static 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 | ||
273 | module_init(alsa_card_mpu401_init) | 282 | module_init(alsa_card_mpu401_init) |