aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/opl3sa2.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/opl3sa2.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/opl3sa2.c')
-rw-r--r--sound/isa/opl3sa2.c43
1 files changed, 32 insertions, 11 deletions
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)