aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/cmi8330.c
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/isa/cmi8330.c
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/isa/cmi8330.c')
-rw-r--r--sound/isa/cmi8330.c34
1 files changed, 26 insertions, 8 deletions
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)