aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/gus
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2007-02-22 06:50:54 -0500
committerJaroslav Kysela <perex@suse.cz>2007-05-11 10:55:40 -0400
commit5e24c1c1c496c4603395d6e9cc320f85008fc891 (patch)
tree3bc2d3797f632d99c7f31a49346d4e77b56520aa /sound/isa/gus
parent442f4f36bed8bcadcbda299c615c12fae95eda99 (diff)
[ALSA] Port the rest of ALSA ISA drivers to isa_driver
Port the rest of ALSA ISA drivers to use isa_driver framework instead of platform_driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/isa/gus')
-rw-r--r--sound/isa/gus/gusmax.c67
-rw-r--r--sound/isa/gus/interwave.c101
2 files changed, 53 insertions, 115 deletions
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index d1ad90ca035d..a0d2f8fc2738 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -72,8 +72,6 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver.");
72module_param_array(pcm_channels, int, NULL, 0444); 72module_param_array(pcm_channels, int, NULL, 0444);
73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); 73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
74 74
75static struct platform_device *devices[SNDRV_CARDS];
76
77struct snd_gusmax { 75struct snd_gusmax {
78 int irq; 76 int irq;
79 struct snd_card *card; 77 struct snd_card *card;
@@ -205,9 +203,13 @@ static void snd_gusmax_free(struct snd_card *card)
205 free_irq(maxcard->irq, (void *)maxcard); 203 free_irq(maxcard->irq, (void *)maxcard);
206} 204}
207 205
208static int __devinit snd_gusmax_probe(struct platform_device *pdev) 206static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev)
207{
208 return enable[dev];
209}
210
211static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev)
209{ 212{
210 int dev = pdev->id;
211 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 213 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
212 static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; 214 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
213 int xirq, xdma1, xdma2, err; 215 int xirq, xdma1, xdma2, err;
@@ -333,7 +335,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
333 if (xdma2 >= 0) 335 if (xdma2 >= 0)
334 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 336 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
335 337
336 snd_card_set_dev(card, &pdev->dev); 338 snd_card_set_dev(card, pdev);
337 339
338 if ((err = snd_card_register(card)) < 0) 340 if ((err = snd_card_register(card)) < 0)
339 goto _err; 341 goto _err;
@@ -341,7 +343,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
341 maxcard->gus = gus; 343 maxcard->gus = gus;
342 maxcard->cs4231 = cs4231; 344 maxcard->cs4231 = cs4231;
343 345
344 platform_set_drvdata(pdev, card); 346 dev_set_drvdata(pdev, card);
345 return 0; 347 return 0;
346 348
347 _err: 349 _err:
@@ -349,16 +351,17 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
349 return err; 351 return err;
350} 352}
351 353
352static int __devexit snd_gusmax_remove(struct platform_device *devptr) 354static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev)
353{ 355{
354 snd_card_free(platform_get_drvdata(devptr)); 356 snd_card_free(dev_get_drvdata(devptr));
355 platform_set_drvdata(devptr, NULL); 357 dev_set_drvdata(devptr, NULL);
356 return 0; 358 return 0;
357} 359}
358 360
359#define GUSMAX_DRIVER "snd_gusmax" 361#define GUSMAX_DRIVER "snd_gusmax"
360 362
361static struct platform_driver snd_gusmax_driver = { 363static struct isa_driver snd_gusmax_driver = {
364 .match = snd_gusmax_match,
362 .probe = snd_gusmax_probe, 365 .probe = snd_gusmax_probe,
363 .remove = __devexit_p(snd_gusmax_remove), 366 .remove = __devexit_p(snd_gusmax_remove),
364 /* FIXME: suspend/resume */ 367 /* FIXME: suspend/resume */
@@ -367,52 +370,14 @@ static struct platform_driver snd_gusmax_driver = {
367 }, 370 },
368}; 371};
369 372
370static void __init_or_module snd_gusmax_unregister_all(void)
371{
372 int i;
373
374 for (i = 0; i < ARRAY_SIZE(devices); ++i)
375 platform_device_unregister(devices[i]);
376 platform_driver_unregister(&snd_gusmax_driver);
377}
378
379static int __init alsa_card_gusmax_init(void) 373static int __init alsa_card_gusmax_init(void)
380{ 374{
381 int i, cards, err; 375 return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
382
383 err = platform_driver_register(&snd_gusmax_driver);
384 if (err < 0)
385 return err;
386
387 cards = 0;
388 for (i = 0; i < SNDRV_CARDS; i++) {
389 struct platform_device *device;
390 if (! enable[i])
391 continue;
392 device = platform_device_register_simple(GUSMAX_DRIVER,
393 i, NULL, 0);
394 if (IS_ERR(device))
395 continue;
396 if (!platform_get_drvdata(device)) {
397 platform_device_unregister(device);
398 continue;
399 }
400 devices[i] = device;
401 cards++;
402 }
403 if (!cards) {
404#ifdef MODULE
405 printk(KERN_ERR "GUS MAX soundcard not found or device busy\n");
406#endif
407 snd_gusmax_unregister_all();
408 return -ENODEV;
409 }
410 return 0;
411} 376}
412 377
413static void __exit alsa_card_gusmax_exit(void) 378static void __exit alsa_card_gusmax_exit(void)
414{ 379{
415 snd_gusmax_unregister_all(); 380 isa_unregister_driver(&snd_gusmax_driver);
416} 381}
417 382
418module_init(alsa_card_gusmax_init) 383module_init(alsa_card_gusmax_init)
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 4ec2d79431fc..3e4657255536 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -25,7 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pnp.h> 31#include <linux/pnp.h>
@@ -115,9 +115,6 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver.");
115module_param_array(effect, int, NULL, 0444); 115module_param_array(effect, int, NULL, 0444);
116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); 116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
117 117
118static struct platform_device *platform_devices[SNDRV_CARDS];
119static int pnp_registered;
120
121struct snd_interwave { 118struct snd_interwave {
122 int irq; 119 int irq;
123 struct snd_card *card; 120 struct snd_card *card;
@@ -138,6 +135,7 @@ struct snd_interwave {
138 135
139 136
140#ifdef CONFIG_PNP 137#ifdef CONFIG_PNP
138static int pnp_registered;
141 139
142static struct pnp_card_device_id snd_interwave_pnpids[] = { 140static struct pnp_card_device_id snd_interwave_pnpids[] = {
143#ifndef SNDRV_STB 141#ifndef SNDRV_STB
@@ -793,7 +791,7 @@ static int __devinit snd_interwave_probe(struct snd_card *card, int dev)
793 return 0; 791 return 0;
794} 792}
795 793
796static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) 794static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr)
797{ 795{
798 struct snd_card *card; 796 struct snd_card *card;
799 int err; 797 int err;
@@ -802,18 +800,30 @@ static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device
802 if (! card) 800 if (! card)
803 return -ENOMEM; 801 return -ENOMEM;
804 802
805 snd_card_set_dev(card, &devptr->dev); 803 snd_card_set_dev(card, devptr);
806 if ((err = snd_interwave_probe(card, dev)) < 0) { 804 if ((err = snd_interwave_probe(card, dev)) < 0) {
807 snd_card_free(card); 805 snd_card_free(card);
808 return err; 806 return err;
809 } 807 }
810 platform_set_drvdata(devptr, card); 808 dev_set_drvdata(devptr, card);
811 return 0; 809 return 0;
812} 810}
813 811
814static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) 812static int __devinit snd_interwave_isa_match(struct device *pdev,
813 unsigned int dev)
814{
815 if (!enable[dev])
816 return 0;
817#ifdef CONFIG_PNP
818 if (isapnp[dev])
819 return 0;
820#endif
821 return 1;
822}
823
824static int __devinit snd_interwave_isa_probe(struct device *pdev,
825 unsigned int dev)
815{ 826{
816 int dev = pdev->id;
817 int err; 827 int err;
818 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 828 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
819 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; 829 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
@@ -838,13 +848,13 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev)
838 } 848 }
839 849
840 if (port[dev] != SNDRV_AUTO_PORT) 850 if (port[dev] != SNDRV_AUTO_PORT)
841 return snd_interwave_nonpnp_probe1(dev, pdev); 851 return snd_interwave_isa_probe1(dev, pdev);
842 else { 852 else {
843 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; 853 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
844 int i; 854 int i;
845 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 855 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
846 port[dev] = possible_ports[i]; 856 port[dev] = possible_ports[i];
847 err = snd_interwave_nonpnp_probe1(dev, pdev); 857 err = snd_interwave_isa_probe1(dev, pdev);
848 if (! err) 858 if (! err)
849 return 0; 859 return 0;
850 } 860 }
@@ -852,16 +862,17 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev)
852 } 862 }
853} 863}
854 864
855static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) 865static int __devexit snd_interwave_isa_remove(struct device *devptr, unsigned int dev)
856{ 866{
857 snd_card_free(platform_get_drvdata(devptr)); 867 snd_card_free(dev_get_drvdata(devptr));
858 platform_set_drvdata(devptr, NULL); 868 dev_set_drvdata(devptr, NULL);
859 return 0; 869 return 0;
860} 870}
861 871
862static struct platform_driver snd_interwave_driver = { 872static struct isa_driver snd_interwave_driver = {
863 .probe = snd_interwave_nonpnp_probe, 873 .match = snd_interwave_isa_match,
864 .remove = __devexit_p(snd_interwave_nonpnp_remove), 874 .probe = snd_interwave_isa_probe,
875 .remove = __devexit_p(snd_interwave_isa_remove),
865 /* FIXME: suspend,resume */ 876 /* FIXME: suspend,resume */
866 .driver = { 877 .driver = {
867 .name = INTERWAVE_DRIVER 878 .name = INTERWAVE_DRIVER
@@ -869,8 +880,6 @@ static struct platform_driver snd_interwave_driver = {
869}; 880};
870 881
871#ifdef CONFIG_PNP 882#ifdef CONFIG_PNP
872static unsigned int __devinitdata interwave_pnp_devices;
873
874static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, 883static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
875 const struct pnp_card_device_id *pid) 884 const struct pnp_card_device_id *pid)
876{ 885{
@@ -900,7 +909,6 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
900 } 909 }
901 pnp_set_card_drvdata(pcard, card); 910 pnp_set_card_drvdata(pcard, card);
902 dev++; 911 dev++;
903 interwave_pnp_devices++;
904 return 0; 912 return 0;
905} 913}
906 914
@@ -921,64 +929,29 @@ static struct pnp_card_driver interwave_pnpc_driver = {
921 929
922#endif /* CONFIG_PNP */ 930#endif /* CONFIG_PNP */
923 931
924static void __init_or_module snd_interwave_unregister_all(void)
925{
926 int i;
927
928 if (pnp_registered)
929 pnp_unregister_card_driver(&interwave_pnpc_driver);
930 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
931 platform_device_unregister(platform_devices[i]);
932 platform_driver_unregister(&snd_interwave_driver);
933}
934
935static int __init alsa_card_interwave_init(void) 932static int __init alsa_card_interwave_init(void)
936{ 933{
937 int i, err, cards = 0; 934 int err;
938 935
939 if ((err = platform_driver_register(&snd_interwave_driver)) < 0) 936 err = isa_register_driver(&snd_interwave_driver, SNDRV_CARDS);
937 if (err < 0)
940 return err; 938 return err;
941
942 for (i = 0; i < SNDRV_CARDS; i++) {
943 struct platform_device *device;
944 if (! enable[i])
945 continue;
946#ifdef CONFIG_PNP 939#ifdef CONFIG_PNP
947 if (isapnp[i])
948 continue;
949#endif
950 device = platform_device_register_simple(INTERWAVE_DRIVER,
951 i, NULL, 0);
952 if (IS_ERR(device))
953 continue;
954 if (!platform_get_drvdata(device)) {
955 platform_device_unregister(device);
956 continue;
957 }
958 platform_devices[i] = device;
959 cards++;
960 }
961
962 /* ISA PnP cards */ 940 /* ISA PnP cards */
963 err = pnp_register_card_driver(&interwave_pnpc_driver); 941 err = pnp_register_card_driver(&interwave_pnpc_driver);
964 if (!err) { 942 if (!err)
965 pnp_registered = 1; 943 pnp_registered = 1;
966 cards += interwave_pnp_devices;;
967 }
968
969 if (!cards) {
970#ifdef MODULE
971 printk(KERN_ERR "InterWave soundcard not found or device busy\n");
972#endif 944#endif
973 snd_interwave_unregister_all();
974 return -ENODEV;
975 }
976 return 0; 945 return 0;
977} 946}
978 947
979static void __exit alsa_card_interwave_exit(void) 948static void __exit alsa_card_interwave_exit(void)
980{ 949{
981 snd_interwave_unregister_all(); 950#ifdef CONFIG_PNP
951 if (pnp_registered)
952 pnp_unregister_card_driver(&interwave_pnpc_driver);
953#endif
954 isa_unregister_driver(&snd_interwave_driver);
982} 955}
983 956
984module_init(alsa_card_interwave_init) 957module_init(alsa_card_interwave_init)