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.c125
1 files changed, 54 insertions, 71 deletions
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 07ffd5c22e81..7d9d4d562e90 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.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/slab.h> 26#include <linux/slab.h>
27#include <linux/pnp.h> 27#include <linux/pnp.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -126,14 +126,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
126module_param_array(dma2, int, NULL, 0444); 126module_param_array(dma2, int, NULL, 0444);
127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
128 128
129static struct platform_device *platform_devices[SNDRV_CARDS];
130#ifdef CONFIG_PNP 129#ifdef CONFIG_PNP
131static int pnpc_registered; 130static int pnpc_registered;
132#ifdef CS4232 131#ifdef CS4232
133static int pnp_registered; 132static int pnp_registered;
134#endif 133#endif
135#endif /* CONFIG_PNP */ 134#endif /* CONFIG_PNP */
136static unsigned int snd_cs423x_devices;
137 135
138struct snd_card_cs4236 { 136struct snd_card_cs4236 {
139 struct snd_cs4231 *chip; 137 struct snd_cs4231 *chip;
@@ -542,38 +540,55 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
542 return snd_card_register(card); 540 return snd_card_register(card);
543} 541}
544 542
545static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) 543static int __devinit snd_cs423x_isa_match(struct device *pdev,
544 unsigned int dev)
546{ 545{
547 int dev = pdev->id; 546 if (!enable[dev] || is_isapnp_selected(dev))
548 struct snd_card *card; 547 return 0;
549 int err;
550 548
551 if (port[dev] == SNDRV_AUTO_PORT) { 549 if (port[dev] == SNDRV_AUTO_PORT) {
552 snd_printk(KERN_ERR "specify port\n"); 550 snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id);
553 return -EINVAL; 551 return 0;
554 } 552 }
555 if (cport[dev] == SNDRV_AUTO_PORT) { 553 if (cport[dev] == SNDRV_AUTO_PORT) {
556 snd_printk(KERN_ERR "specify cport\n"); 554 snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id);
557 return -EINVAL; 555 return 0;
556 }
557 if (irq[dev] == SNDRV_AUTO_IRQ) {
558 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
559 return 0;
558 } 560 }
561 if (dma1[dev] == SNDRV_AUTO_DMA) {
562 snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id);
563 return 0;
564 }
565 return 1;
566}
567
568static int __devinit snd_cs423x_isa_probe(struct device *pdev,
569 unsigned int dev)
570{
571 struct snd_card *card;
572 int err;
559 573
560 card = snd_cs423x_card_new(dev); 574 card = snd_cs423x_card_new(dev);
561 if (! card) 575 if (! card)
562 return -ENOMEM; 576 return -ENOMEM;
563 snd_card_set_dev(card, &pdev->dev); 577 snd_card_set_dev(card, pdev);
564 if ((err = snd_cs423x_probe(card, dev)) < 0) { 578 if ((err = snd_cs423x_probe(card, dev)) < 0) {
565 snd_card_free(card); 579 snd_card_free(card);
566 return err; 580 return err;
567 } 581 }
568 582
569 platform_set_drvdata(pdev, card); 583 dev_set_drvdata(pdev, card);
570 return 0; 584 return 0;
571} 585}
572 586
573static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) 587static int __devexit snd_cs423x_isa_remove(struct device *pdev,
588 unsigned int dev)
574{ 589{
575 snd_card_free(platform_get_drvdata(devptr)); 590 snd_card_free(dev_get_drvdata(pdev));
576 platform_set_drvdata(devptr, NULL); 591 dev_set_drvdata(pdev, NULL);
577 return 0; 592 return 0;
578} 593}
579 594
@@ -594,23 +609,25 @@ static int snd_cs423x_resume(struct snd_card *card)
594 return 0; 609 return 0;
595} 610}
596 611
597static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 612static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n,
613 pm_message_t state)
598{ 614{
599 return snd_cs423x_suspend(platform_get_drvdata(dev)); 615 return snd_cs423x_suspend(dev_get_drvdata(dev));
600} 616}
601 617
602static int snd_cs423x_nonpnp_resume(struct platform_device *dev) 618static int snd_cs423x_isa_resume(struct device *dev, unsigned int n)
603{ 619{
604 return snd_cs423x_resume(platform_get_drvdata(dev)); 620 return snd_cs423x_resume(dev_get_drvdata(dev));
605} 621}
606#endif 622#endif
607 623
608static struct platform_driver cs423x_nonpnp_driver = { 624static struct isa_driver cs423x_isa_driver = {
609 .probe = snd_cs423x_nonpnp_probe, 625 .match = snd_cs423x_isa_match,
610 .remove = __devexit_p(snd_cs423x_nonpnp_remove), 626 .probe = snd_cs423x_isa_probe,
627 .remove = __devexit_p(snd_cs423x_isa_remove),
611#ifdef CONFIG_PM 628#ifdef CONFIG_PM
612 .suspend = snd_cs423x_nonpnp_suspend, 629 .suspend = snd_cs423x_isa_suspend,
613 .resume = snd_cs423x_nonpnp_resume, 630 .resume = snd_cs423x_isa_resume,
614#endif 631#endif
615 .driver = { 632 .driver = {
616 .name = CS423X_DRIVER 633 .name = CS423X_DRIVER
@@ -651,7 +668,6 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
651 } 668 }
652 pnp_set_drvdata(pdev, card); 669 pnp_set_drvdata(pdev, card);
653 dev++; 670 dev++;
654 snd_cs423x_devices++;
655 return 0; 671 return 0;
656} 672}
657 673
@@ -715,7 +731,6 @@ static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
715 } 731 }
716 pnp_set_card_drvdata(pcard, card); 732 pnp_set_card_drvdata(pcard, card);
717 dev++; 733 dev++;
718 snd_cs423x_devices++;
719 return 0; 734 return 0;
720} 735}
721 736
@@ -750,45 +765,13 @@ static struct pnp_card_driver cs423x_pnpc_driver = {
750}; 765};
751#endif /* CONFIG_PNP */ 766#endif /* CONFIG_PNP */
752 767
753static void __init_or_module snd_cs423x_unregister_all(void)
754{
755 int i;
756
757#ifdef CONFIG_PNP
758 if (pnpc_registered)
759 pnp_unregister_card_driver(&cs423x_pnpc_driver);
760#ifdef CS4232
761 if (pnp_registered)
762 pnp_unregister_driver(&cs4232_pnp_driver);
763#endif
764#endif /* CONFIG_PNP */
765 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
766 platform_device_unregister(platform_devices[i]);
767 platform_driver_unregister(&cs423x_nonpnp_driver);
768}
769
770static int __init alsa_card_cs423x_init(void) 768static int __init alsa_card_cs423x_init(void)
771{ 769{
772 int i, err; 770 int err;
773 771
774 if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0) 772 err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS);
773 if (err < 0)
775 return err; 774 return err;
776
777 for (i = 0; i < SNDRV_CARDS; i++) {
778 struct platform_device *device;
779 if (! enable[i] || is_isapnp_selected(i))
780 continue;
781 device = platform_device_register_simple(CS423X_DRIVER,
782 i, NULL, 0);
783 if (IS_ERR(device))
784 continue;
785 if (!platform_get_drvdata(device)) {
786 platform_device_unregister(device);
787 continue;
788 }
789 platform_devices[i] = device;
790 snd_cs423x_devices++;
791 }
792#ifdef CONFIG_PNP 775#ifdef CONFIG_PNP
793#ifdef CS4232 776#ifdef CS4232
794 err = pnp_register_driver(&cs4232_pnp_driver); 777 err = pnp_register_driver(&cs4232_pnp_driver);
@@ -799,20 +782,20 @@ static int __init alsa_card_cs423x_init(void)
799 if (!err) 782 if (!err)
800 pnpc_registered = 1; 783 pnpc_registered = 1;
801#endif /* CONFIG_PNP */ 784#endif /* CONFIG_PNP */
802
803 if (!snd_cs423x_devices) {
804#ifdef MODULE
805 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
806#endif
807 snd_cs423x_unregister_all();
808 return -ENODEV;
809 }
810 return 0; 785 return 0;
811} 786}
812 787
813static void __exit alsa_card_cs423x_exit(void) 788static void __exit alsa_card_cs423x_exit(void)
814{ 789{
815 snd_cs423x_unregister_all(); 790#ifdef CONFIG_PNP
791 if (pnpc_registered)
792 pnp_unregister_card_driver(&cs423x_pnpc_driver);
793#ifdef CS4232
794 if (pnp_registered)
795 pnp_unregister_driver(&cs4232_pnp_driver);
796#endif
797#endif /* CONFIG_PNP */
798 isa_unregister_driver(&cs423x_isa_driver);
816} 799}
817 800
818module_init(alsa_card_cs423x_init) 801module_init(alsa_card_cs423x_init)