diff options
Diffstat (limited to 'sound/isa/cmi8330.c')
-rw-r--r-- | sound/isa/cmi8330.c | 111 |
1 files changed, 41 insertions, 70 deletions
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index c09a8009d2fa..456156de0791 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <sound/driver.h> | 46 | #include <sound/driver.h> |
47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
48 | #include <linux/err.h> | 48 | #include <linux/err.h> |
49 | #include <linux/platform_device.h> | 49 | #include <linux/isa.h> |
50 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
51 | #include <linux/pnp.h> | 51 | #include <linux/pnp.h> |
52 | #include <linux/moduleparam.h> | 52 | #include <linux/moduleparam.h> |
@@ -108,7 +108,6 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver."); | |||
108 | module_param_array(wssdma, int, NULL, 0444); | 108 | module_param_array(wssdma, int, NULL, 0444); |
109 | MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); | 109 | MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); |
110 | 110 | ||
111 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
112 | #ifdef CONFIG_PNP | 111 | #ifdef CONFIG_PNP |
113 | static int pnp_registered; | 112 | static int pnp_registered; |
114 | #endif | 113 | #endif |
@@ -547,60 +546,70 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) | |||
547 | return snd_card_register(card); | 546 | return snd_card_register(card); |
548 | } | 547 | } |
549 | 548 | ||
550 | static int __devinit snd_cmi8330_nonpnp_probe(struct platform_device *pdev) | 549 | static int __devinit snd_cmi8330_isa_match(struct device *pdev, |
550 | unsigned int dev) | ||
551 | { | 551 | { |
552 | struct snd_card *card; | 552 | if (!enable[dev] || is_isapnp_selected(dev)) |
553 | int err; | 553 | return 0; |
554 | int dev = pdev->id; | ||
555 | |||
556 | if (wssport[dev] == SNDRV_AUTO_PORT) { | 554 | if (wssport[dev] == SNDRV_AUTO_PORT) { |
557 | snd_printk(KERN_ERR PFX "specify wssport\n"); | 555 | snd_printk(KERN_ERR PFX "specify wssport\n"); |
558 | return -EINVAL; | 556 | return 0; |
559 | } | 557 | } |
560 | if (sbport[dev] == SNDRV_AUTO_PORT) { | 558 | if (sbport[dev] == SNDRV_AUTO_PORT) { |
561 | snd_printk(KERN_ERR PFX "specify sbport\n"); | 559 | snd_printk(KERN_ERR PFX "specify sbport\n"); |
562 | return -EINVAL; | 560 | return 0; |
563 | } | 561 | } |
562 | return 1; | ||
563 | } | ||
564 | |||
565 | static int __devinit snd_cmi8330_isa_probe(struct device *pdev, | ||
566 | unsigned int dev) | ||
567 | { | ||
568 | struct snd_card *card; | ||
569 | int err; | ||
564 | 570 | ||
565 | card = snd_cmi8330_card_new(dev); | 571 | card = snd_cmi8330_card_new(dev); |
566 | if (! card) | 572 | if (! card) |
567 | return -ENOMEM; | 573 | return -ENOMEM; |
568 | snd_card_set_dev(card, &pdev->dev); | 574 | snd_card_set_dev(card, pdev); |
569 | if ((err = snd_cmi8330_probe(card, dev)) < 0) { | 575 | if ((err = snd_cmi8330_probe(card, dev)) < 0) { |
570 | snd_card_free(card); | 576 | snd_card_free(card); |
571 | return err; | 577 | return err; |
572 | } | 578 | } |
573 | platform_set_drvdata(pdev, card); | 579 | dev_set_drvdata(pdev, card); |
574 | return 0; | 580 | return 0; |
575 | } | 581 | } |
576 | 582 | ||
577 | static int __devexit snd_cmi8330_nonpnp_remove(struct platform_device *devptr) | 583 | static int __devexit snd_cmi8330_isa_remove(struct device *devptr, |
584 | unsigned int dev) | ||
578 | { | 585 | { |
579 | snd_card_free(platform_get_drvdata(devptr)); | 586 | snd_card_free(dev_get_drvdata(devptr)); |
580 | platform_set_drvdata(devptr, NULL); | 587 | dev_set_drvdata(devptr, NULL); |
581 | return 0; | 588 | return 0; |
582 | } | 589 | } |
583 | 590 | ||
584 | #ifdef CONFIG_PM | 591 | #ifdef CONFIG_PM |
585 | static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state) | 592 | static int snd_cmi8330_isa_suspend(struct device *dev, unsigned int n, |
593 | pm_message_t state) | ||
586 | { | 594 | { |
587 | return snd_cmi8330_suspend(platform_get_drvdata(dev)); | 595 | return snd_cmi8330_suspend(dev_get_drvdata(dev)); |
588 | } | 596 | } |
589 | 597 | ||
590 | static int snd_cmi8330_nonpnp_resume(struct platform_device *dev) | 598 | static int snd_cmi8330_isa_resume(struct device *dev, unsigned int n) |
591 | { | 599 | { |
592 | return snd_cmi8330_resume(platform_get_drvdata(dev)); | 600 | return snd_cmi8330_resume(dev_get_drvdata(dev)); |
593 | } | 601 | } |
594 | #endif | 602 | #endif |
595 | 603 | ||
596 | #define CMI8330_DRIVER "snd_cmi8330" | 604 | #define CMI8330_DRIVER "snd_cmi8330" |
597 | 605 | ||
598 | static struct platform_driver snd_cmi8330_driver = { | 606 | static struct isa_driver snd_cmi8330_driver = { |
599 | .probe = snd_cmi8330_nonpnp_probe, | 607 | .match = snd_cmi8330_isa_match, |
600 | .remove = __devexit_p(snd_cmi8330_nonpnp_remove), | 608 | .probe = snd_cmi8330_isa_probe, |
609 | .remove = __devexit_p(snd_cmi8330_isa_remove), | ||
601 | #ifdef CONFIG_PM | 610 | #ifdef CONFIG_PM |
602 | .suspend = snd_cmi8330_nonpnp_suspend, | 611 | .suspend = snd_cmi8330_isa_suspend, |
603 | .resume = snd_cmi8330_nonpnp_resume, | 612 | .resume = snd_cmi8330_isa_resume, |
604 | #endif | 613 | #endif |
605 | .driver = { | 614 | .driver = { |
606 | .name = CMI8330_DRIVER | 615 | .name = CMI8330_DRIVER |
@@ -609,8 +618,6 @@ static struct platform_driver snd_cmi8330_driver = { | |||
609 | 618 | ||
610 | 619 | ||
611 | #ifdef CONFIG_PNP | 620 | #ifdef CONFIG_PNP |
612 | static unsigned int __devinitdata cmi8330_pnp_devices; | ||
613 | |||
614 | static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, | 621 | static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, |
615 | const struct pnp_card_device_id *pid) | 622 | const struct pnp_card_device_id *pid) |
616 | { | 623 | { |
@@ -640,7 +647,6 @@ static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, | |||
640 | } | 647 | } |
641 | pnp_set_card_drvdata(pcard, card); | 648 | pnp_set_card_drvdata(pcard, card); |
642 | dev++; | 649 | dev++; |
643 | cmi8330_pnp_devices++; | ||
644 | return 0; | 650 | return 0; |
645 | } | 651 | } |
646 | 652 | ||
@@ -675,63 +681,28 @@ static struct pnp_card_driver cmi8330_pnpc_driver = { | |||
675 | }; | 681 | }; |
676 | #endif /* CONFIG_PNP */ | 682 | #endif /* CONFIG_PNP */ |
677 | 683 | ||
678 | static void __init_or_module snd_cmi8330_unregister_all(void) | ||
679 | { | ||
680 | int i; | ||
681 | |||
682 | #ifdef CONFIG_PNP | ||
683 | if (pnp_registered) | ||
684 | pnp_unregister_card_driver(&cmi8330_pnpc_driver); | ||
685 | #endif | ||
686 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
687 | platform_device_unregister(platform_devices[i]); | ||
688 | platform_driver_unregister(&snd_cmi8330_driver); | ||
689 | } | ||
690 | |||
691 | static int __init alsa_card_cmi8330_init(void) | 684 | static int __init alsa_card_cmi8330_init(void) |
692 | { | 685 | { |
693 | int i, err, cards = 0; | 686 | int err; |
694 | 687 | ||
695 | if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0) | 688 | err = isa_register_driver(&snd_cmi8330_driver, SNDRV_CARDS); |
689 | if (err < 0) | ||
696 | return err; | 690 | return err; |
697 | |||
698 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
699 | struct platform_device *device; | ||
700 | if (! enable[i] || is_isapnp_selected(i)) | ||
701 | continue; | ||
702 | device = platform_device_register_simple(CMI8330_DRIVER, | ||
703 | i, NULL, 0); | ||
704 | if (IS_ERR(device)) | ||
705 | continue; | ||
706 | if (!platform_get_drvdata(device)) { | ||
707 | platform_device_unregister(device); | ||
708 | continue; | ||
709 | } | ||
710 | platform_devices[i] = device; | ||
711 | cards++; | ||
712 | } | ||
713 | |||
714 | #ifdef CONFIG_PNP | 691 | #ifdef CONFIG_PNP |
715 | err = pnp_register_card_driver(&cmi8330_pnpc_driver); | 692 | err = pnp_register_card_driver(&cmi8330_pnpc_driver); |
716 | if (!err) { | 693 | if (!err) |
717 | pnp_registered = 1; | 694 | pnp_registered = 1; |
718 | cards += cmi8330_pnp_devices; | ||
719 | } | ||
720 | #endif | 695 | #endif |
721 | |||
722 | if (!cards) { | ||
723 | #ifdef MODULE | ||
724 | snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); | ||
725 | #endif | ||
726 | snd_cmi8330_unregister_all(); | ||
727 | return -ENODEV; | ||
728 | } | ||
729 | return 0; | 696 | return 0; |
730 | } | 697 | } |
731 | 698 | ||
732 | static void __exit alsa_card_cmi8330_exit(void) | 699 | static void __exit alsa_card_cmi8330_exit(void) |
733 | { | 700 | { |
734 | snd_cmi8330_unregister_all(); | 701 | #ifdef CONFIG_PNP |
702 | if (pnp_registered) | ||
703 | pnp_unregister_card_driver(&cmi8330_pnpc_driver); | ||
704 | #endif | ||
705 | isa_unregister_driver(&snd_cmi8330_driver); | ||
735 | } | 706 | } |
736 | 707 | ||
737 | module_init(alsa_card_cmi8330_init) | 708 | module_init(alsa_card_cmi8330_init) |