aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/wavefront/wavefront.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/wavefront/wavefront.c')
-rw-r--r--sound/isa/wavefront/wavefront.c107
1 files changed, 38 insertions, 69 deletions
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index e2fdd5fd39d0..6f143275e3b3 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -24,7 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/pnp.h> 28#include <linux/pnp.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <sound/core.h> 30#include <sound/core.h>
@@ -83,8 +83,6 @@ MODULE_PARM_DESC(fm_port, "FM port #.");
83module_param_array(use_cs4232_midi, bool, NULL, 0444); 83module_param_array(use_cs4232_midi, bool, NULL, 0444);
84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); 84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
85 85
86static struct platform_device *platform_devices[SNDRV_CARDS];
87
88#ifdef CONFIG_PNP 86#ifdef CONFIG_PNP
89static int pnp_registered; 87static int pnp_registered;
90 88
@@ -588,46 +586,59 @@ snd_wavefront_probe (struct snd_card *card, int dev)
588 return snd_card_register(card); 586 return snd_card_register(card);
589} 587}
590 588
591static int __devinit snd_wavefront_nonpnp_probe(struct platform_device *pdev) 589static int __devinit snd_wavefront_isa_match(struct device *pdev,
590 unsigned int dev)
592{ 591{
593 int dev = pdev->id; 592 if (!enable[dev])
594 struct snd_card *card; 593 return 0;
595 int err; 594#ifdef CONFIG_PNP
596 595 if (isapnp[dev])
596 return 0;
597#endif
597 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { 598 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
598 snd_printk("specify CS4232 port\n"); 599 snd_printk("specify CS4232 port\n");
599 return -EINVAL; 600 return 0;
600 } 601 }
601 if (ics2115_port[dev] == SNDRV_AUTO_PORT) { 602 if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
602 snd_printk("specify ICS2115 port\n"); 603 snd_printk("specify ICS2115 port\n");
603 return -ENODEV; 604 return 0;
604 } 605 }
606 return 1;
607}
608
609static int __devinit snd_wavefront_isa_probe(struct device *pdev,
610 unsigned int dev)
611{
612 struct snd_card *card;
613 int err;
605 614
606 card = snd_wavefront_card_new(dev); 615 card = snd_wavefront_card_new(dev);
607 if (! card) 616 if (! card)
608 return -ENOMEM; 617 return -ENOMEM;
609 snd_card_set_dev(card, &pdev->dev); 618 snd_card_set_dev(card, pdev);
610 if ((err = snd_wavefront_probe(card, dev)) < 0) { 619 if ((err = snd_wavefront_probe(card, dev)) < 0) {
611 snd_card_free(card); 620 snd_card_free(card);
612 return err; 621 return err;
613 } 622 }
614 623
615 platform_set_drvdata(pdev, card); 624 dev_set_drvdata(pdev, card);
616 return 0; 625 return 0;
617} 626}
618 627
619static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) 628static int __devexit snd_wavefront_isa_remove(struct device *devptr,
629 unsigned int dev)
620{ 630{
621 snd_card_free(platform_get_drvdata(devptr)); 631 snd_card_free(dev_get_drvdata(devptr));
622 platform_set_drvdata(devptr, NULL); 632 dev_set_drvdata(devptr, NULL);
623 return 0; 633 return 0;
624} 634}
625 635
626#define WAVEFRONT_DRIVER "snd_wavefront" 636#define WAVEFRONT_DRIVER "snd_wavefront"
627 637
628static struct platform_driver snd_wavefront_driver = { 638static struct isa_driver snd_wavefront_driver = {
629 .probe = snd_wavefront_nonpnp_probe, 639 .match = snd_wavefront_isa_match,
630 .remove = __devexit_p(snd_wavefront_nonpnp_remove), 640 .probe = snd_wavefront_isa_probe,
641 .remove = __devexit_p(snd_wavefront_isa_remove),
631 /* FIXME: suspend, resume */ 642 /* FIXME: suspend, resume */
632 .driver = { 643 .driver = {
633 .name = WAVEFRONT_DRIVER 644 .name = WAVEFRONT_DRIVER
@@ -636,8 +647,6 @@ static struct platform_driver snd_wavefront_driver = {
636 647
637 648
638#ifdef CONFIG_PNP 649#ifdef CONFIG_PNP
639static unsigned int __devinitdata wavefront_pnp_devices;
640
641static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, 650static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
642 const struct pnp_card_device_id *pid) 651 const struct pnp_card_device_id *pid)
643{ 652{
@@ -670,7 +679,6 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
670 679
671 pnp_set_card_drvdata(pcard, card); 680 pnp_set_card_drvdata(pcard, card);
672 dev++; 681 dev++;
673 wavefront_pnp_devices++;
674 return 0; 682 return 0;
675} 683}
676 684
@@ -691,67 +699,28 @@ static struct pnp_card_driver wavefront_pnpc_driver = {
691 699
692#endif /* CONFIG_PNP */ 700#endif /* CONFIG_PNP */
693 701
694static void __init_or_module snd_wavefront_unregister_all(void)
695{
696 int i;
697
698#ifdef CONFIG_PNP
699 if (pnp_registered)
700 pnp_unregister_card_driver(&wavefront_pnpc_driver);
701#endif
702 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
703 platform_device_unregister(platform_devices[i]);
704 platform_driver_unregister(&snd_wavefront_driver);
705}
706
707static int __init alsa_card_wavefront_init(void) 702static int __init alsa_card_wavefront_init(void)
708{ 703{
709 int i, err, cards = 0; 704 int err;
710 705
711 if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) 706 err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS);
707 if (err < 0)
712 return err; 708 return err;
713
714 for (i = 0; i < SNDRV_CARDS; i++) {
715 struct platform_device *device;
716 if (! enable[i])
717 continue;
718#ifdef CONFIG_PNP
719 if (isapnp[i])
720 continue;
721#endif
722 device = platform_device_register_simple(WAVEFRONT_DRIVER,
723 i, NULL, 0);
724 if (IS_ERR(device))
725 continue;
726 if (!platform_get_drvdata(device)) {
727 platform_device_unregister(device);
728 continue;
729 }
730 platform_devices[i] = device;
731 cards++;
732 }
733
734#ifdef CONFIG_PNP 709#ifdef CONFIG_PNP
735 err = pnp_register_card_driver(&wavefront_pnpc_driver); 710 err = pnp_register_card_driver(&wavefront_pnpc_driver);
736 if (!err) { 711 if (!err)
737 pnp_registered = 1; 712 pnp_registered = 1;
738 cards += wavefront_pnp_devices;
739 }
740#endif
741
742 if (!cards) {
743#ifdef MODULE
744 printk (KERN_ERR "No WaveFront cards found or devices busy\n");
745#endif 713#endif
746 snd_wavefront_unregister_all();
747 return -ENODEV;
748 }
749 return 0; 714 return 0;
750} 715}
751 716
752static void __exit alsa_card_wavefront_exit(void) 717static void __exit alsa_card_wavefront_exit(void)
753{ 718{
754 snd_wavefront_unregister_all(); 719#ifdef CONFIG_PNP
720 if (pnp_registered)
721 pnp_unregister_card_driver(&wavefront_pnpc_driver);
722#endif
723 isa_unregister_driver(&snd_wavefront_driver);
755} 724}
756 725
757module_init(alsa_card_wavefront_init) 726module_init(alsa_card_wavefront_init)