diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2005-12-07 03:13:42 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:30:39 -0500 |
commit | f7a9275d949cb0bf1f259a1546e52a0bf518151c (patch) | |
tree | 4d96d9b6196d43684903857ba676dc51bbde4026 /sound/isa/gus/interwave.c | |
parent | 416c1079d30f1a52399b96f6772e993274b774ae (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/gus/interwave.c')
-rw-r--r-- | sound/isa/gus/interwave.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 67a5f7402453..9838d992b101 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c | |||
@@ -115,6 +115,9 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver."); | |||
115 | module_param_array(effect, int, NULL, 0444); | 115 | module_param_array(effect, int, NULL, 0444); |
116 | MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); | 116 | MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); |
117 | 117 | ||
118 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
119 | static int pnp_registered; | ||
120 | |||
118 | struct snd_interwave { | 121 | struct snd_interwave { |
119 | int irq; | 122 | int irq; |
120 | struct snd_card *card; | 123 | struct snd_card *card; |
@@ -914,6 +917,17 @@ static struct pnp_card_driver interwave_pnpc_driver = { | |||
914 | 917 | ||
915 | #endif /* CONFIG_PNP */ | 918 | #endif /* CONFIG_PNP */ |
916 | 919 | ||
920 | static void __init_or_module snd_interwave_unregister_all(void) | ||
921 | { | ||
922 | int i; | ||
923 | |||
924 | if (pnp_registered) | ||
925 | pnp_unregister_card_driver(&interwave_pnpc_driver); | ||
926 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
927 | platform_device_unregister(platform_devices[i]); | ||
928 | platform_driver_unregister(&snd_interwave_driver); | ||
929 | } | ||
930 | |||
917 | static int __init alsa_card_interwave_init(void) | 931 | static int __init alsa_card_interwave_init(void) |
918 | { | 932 | { |
919 | int i, err, cards = 0; | 933 | int i, err, cards = 0; |
@@ -931,32 +945,36 @@ static int __init alsa_card_interwave_init(void) | |||
931 | i, NULL, 0); | 945 | i, NULL, 0); |
932 | if (IS_ERR(device)) { | 946 | if (IS_ERR(device)) { |
933 | err = PTR_ERR(device); | 947 | err = PTR_ERR(device); |
934 | platform_driver_unregister(&snd_interwave_driver); | 948 | goto errout; |
935 | return err; | ||
936 | } | 949 | } |
950 | platform_devices[i] = device; | ||
937 | cards++; | 951 | cards++; |
938 | } | 952 | } |
939 | 953 | ||
940 | /* ISA PnP cards */ | 954 | /* ISA PnP cards */ |
941 | i = pnp_register_card_driver(&interwave_pnpc_driver); | 955 | i = pnp_register_card_driver(&interwave_pnpc_driver); |
942 | if (i > 0) | 956 | if (i >= 0) { |
957 | pnp_registered = 1; | ||
943 | cards += i; | 958 | cards += i; |
959 | } | ||
944 | 960 | ||
945 | if (!cards) { | 961 | if (!cards) { |
946 | pnp_unregister_card_driver(&interwave_pnpc_driver); | ||
947 | platform_driver_unregister(&snd_interwave_driver); | ||
948 | #ifdef MODULE | 962 | #ifdef MODULE |
949 | printk(KERN_ERR "InterWave soundcard not found or device busy\n"); | 963 | printk(KERN_ERR "InterWave soundcard not found or device busy\n"); |
950 | #endif | 964 | #endif |
951 | return -ENODEV; | 965 | err = -ENODEV; |
966 | goto errout; | ||
952 | } | 967 | } |
953 | return 0; | 968 | return 0; |
969 | |||
970 | errout: | ||
971 | snd_interwave_unregister_all(); | ||
972 | return err; | ||
954 | } | 973 | } |
955 | 974 | ||
956 | static void __exit alsa_card_interwave_exit(void) | 975 | static void __exit alsa_card_interwave_exit(void) |
957 | { | 976 | { |
958 | pnp_unregister_card_driver(&interwave_pnpc_driver); | 977 | snd_interwave_unregister_all(); |
959 | platform_driver_unregister(&snd_interwave_driver); | ||
960 | } | 978 | } |
961 | 979 | ||
962 | module_init(alsa_card_interwave_init) | 980 | module_init(alsa_card_interwave_init) |