aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/cs423x/cs4236.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/cs423x/cs4236.c')
-rw-r--r--sound/isa/cs423x/cs4236.c51
1 files changed, 36 insertions, 15 deletions
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)