diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-02-22 06:50:54 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-05-11 10:55:40 -0400 |
commit | 5e24c1c1c496c4603395d6e9cc320f85008fc891 (patch) | |
tree | 3bc2d3797f632d99c7f31a49346d4e77b56520aa /sound/isa/sb/sb16.c | |
parent | 442f4f36bed8bcadcbda299c615c12fae95eda99 (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/sb/sb16.c')
-rw-r--r-- | sound/isa/sb/sb16.c | 107 |
1 files changed, 35 insertions, 72 deletions
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index d64e67f2bafa..8b734a239008 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/pnp.h> | 26 | #include <linux/pnp.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/moduleparam.h> | 29 | #include <linux/moduleparam.h> |
30 | #include <sound/core.h> | 30 | #include <sound/core.h> |
31 | #include <sound/sb.h> | 31 | #include <sound/sb.h> |
@@ -128,7 +128,6 @@ module_param_array(seq_ports, int, NULL, 0444); | |||
128 | MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); | 128 | MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | static struct platform_device *platform_devices[SNDRV_CARDS]; | ||
132 | #ifdef CONFIG_PNP | 131 | #ifdef CONFIG_PNP |
133 | static int pnp_registered; | 132 | static int pnp_registered; |
134 | #endif | 133 | #endif |
@@ -519,7 +518,7 @@ static int snd_sb16_resume(struct snd_card *card) | |||
519 | } | 518 | } |
520 | #endif | 519 | #endif |
521 | 520 | ||
522 | static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr) | 521 | static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev) |
523 | { | 522 | { |
524 | struct snd_card_sb16 *acard; | 523 | struct snd_card_sb16 *acard; |
525 | struct snd_card *card; | 524 | struct snd_card *card; |
@@ -539,19 +538,23 @@ static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *dev | |||
539 | awe_port[dev] = port[dev] + 0x400; | 538 | awe_port[dev] = port[dev] + 0x400; |
540 | #endif | 539 | #endif |
541 | 540 | ||
542 | snd_card_set_dev(card, &devptr->dev); | 541 | snd_card_set_dev(card, pdev); |
543 | if ((err = snd_sb16_probe(card, dev)) < 0) { | 542 | if ((err = snd_sb16_probe(card, dev)) < 0) { |
544 | snd_card_free(card); | 543 | snd_card_free(card); |
545 | return err; | 544 | return err; |
546 | } | 545 | } |
547 | platform_set_drvdata(devptr, card); | 546 | dev_set_drvdata(pdev, card); |
548 | return 0; | 547 | return 0; |
549 | } | 548 | } |
550 | 549 | ||
551 | 550 | ||
552 | static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev) | 551 | static int __devinit snd_sb16_isa_match(struct device *pdev, unsigned int dev) |
552 | { | ||
553 | return enable[dev] && !is_isapnp_selected(dev); | ||
554 | } | ||
555 | |||
556 | static int __devinit snd_sb16_isa_probe(struct device *pdev, unsigned int dev) | ||
553 | { | 557 | { |
554 | int dev = pdev->id; | ||
555 | int err; | 558 | int err; |
556 | static int possible_irqs[] = {5, 9, 10, 7, -1}; | 559 | static int possible_irqs[] = {5, 9, 10, 7, -1}; |
557 | static int possible_dmas8[] = {1, 3, 0, -1}; | 560 | static int possible_dmas8[] = {1, 3, 0, -1}; |
@@ -577,13 +580,13 @@ static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev) | |||
577 | } | 580 | } |
578 | 581 | ||
579 | if (port[dev] != SNDRV_AUTO_PORT) | 582 | if (port[dev] != SNDRV_AUTO_PORT) |
580 | return snd_sb16_nonpnp_probe1(dev, pdev); | 583 | return snd_sb16_isa_probe1(dev, pdev); |
581 | else { | 584 | else { |
582 | static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; | 585 | static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; |
583 | int i; | 586 | int i; |
584 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { | 587 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { |
585 | port[dev] = possible_ports[i]; | 588 | port[dev] = possible_ports[i]; |
586 | err = snd_sb16_nonpnp_probe1(dev, pdev); | 589 | err = snd_sb16_isa_probe1(dev, pdev); |
587 | if (! err) | 590 | if (! err) |
588 | return 0; | 591 | return 0; |
589 | } | 592 | } |
@@ -591,22 +594,23 @@ static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev) | |||
591 | } | 594 | } |
592 | } | 595 | } |
593 | 596 | ||
594 | static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr) | 597 | static int __devexit snd_sb16_isa_remove(struct device *pdev, unsigned int dev) |
595 | { | 598 | { |
596 | snd_card_free(platform_get_drvdata(devptr)); | 599 | snd_card_free(dev_get_drvdata(pdev)); |
597 | platform_set_drvdata(devptr, NULL); | 600 | dev_set_drvdata(pdev, NULL); |
598 | return 0; | 601 | return 0; |
599 | } | 602 | } |
600 | 603 | ||
601 | #ifdef CONFIG_PM | 604 | #ifdef CONFIG_PM |
602 | static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state) | 605 | static int snd_sb16_isa_suspend(struct device *dev, unsigned int n, |
606 | pm_message_t state) | ||
603 | { | 607 | { |
604 | return snd_sb16_suspend(platform_get_drvdata(dev), state); | 608 | return snd_sb16_suspend(dev_get_drvdata(dev), state); |
605 | } | 609 | } |
606 | 610 | ||
607 | static int snd_sb16_nonpnp_resume(struct platform_device *dev) | 611 | static int snd_sb16_isa_resume(struct device *dev, unsigned int n) |
608 | { | 612 | { |
609 | return snd_sb16_resume(platform_get_drvdata(dev)); | 613 | return snd_sb16_resume(dev_get_drvdata(dev)); |
610 | } | 614 | } |
611 | #endif | 615 | #endif |
612 | 616 | ||
@@ -616,12 +620,13 @@ static int snd_sb16_nonpnp_resume(struct platform_device *dev) | |||
616 | #define SND_SB16_DRIVER "snd_sb16" | 620 | #define SND_SB16_DRIVER "snd_sb16" |
617 | #endif | 621 | #endif |
618 | 622 | ||
619 | static struct platform_driver snd_sb16_nonpnp_driver = { | 623 | static struct isa_driver snd_sb16_isa_driver = { |
620 | .probe = snd_sb16_nonpnp_probe, | 624 | .match = snd_sb16_isa_match, |
621 | .remove = __devexit_p(snd_sb16_nonpnp_remove), | 625 | .probe = snd_sb16_isa_probe, |
626 | .remove = __devexit_p(snd_sb16_isa_remove), | ||
622 | #ifdef CONFIG_PM | 627 | #ifdef CONFIG_PM |
623 | .suspend = snd_sb16_nonpnp_suspend, | 628 | .suspend = snd_sb16_isa_suspend, |
624 | .resume = snd_sb16_nonpnp_resume, | 629 | .resume = snd_sb16_isa_resume, |
625 | #endif | 630 | #endif |
626 | .driver = { | 631 | .driver = { |
627 | .name = SND_SB16_DRIVER | 632 | .name = SND_SB16_DRIVER |
@@ -630,8 +635,6 @@ static struct platform_driver snd_sb16_nonpnp_driver = { | |||
630 | 635 | ||
631 | 636 | ||
632 | #ifdef CONFIG_PNP | 637 | #ifdef CONFIG_PNP |
633 | static unsigned int __devinitdata sb16_pnp_devices; | ||
634 | |||
635 | static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, | 638 | static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, |
636 | const struct pnp_card_device_id *pid) | 639 | const struct pnp_card_device_id *pid) |
637 | { | 640 | { |
@@ -653,7 +656,6 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, | |||
653 | } | 656 | } |
654 | pnp_set_card_drvdata(pcard, card); | 657 | pnp_set_card_drvdata(pcard, card); |
655 | dev++; | 658 | dev++; |
656 | sb16_pnp_devices++; | ||
657 | return 0; | 659 | return 0; |
658 | } | 660 | } |
659 | 661 | ||
@@ -695,68 +697,29 @@ static struct pnp_card_driver sb16_pnpc_driver = { | |||
695 | 697 | ||
696 | #endif /* CONFIG_PNP */ | 698 | #endif /* CONFIG_PNP */ |
697 | 699 | ||
698 | static void __init_or_module snd_sb16_unregister_all(void) | ||
699 | { | ||
700 | int i; | ||
701 | |||
702 | #ifdef CONFIG_PNP | ||
703 | if (pnp_registered) | ||
704 | pnp_unregister_card_driver(&sb16_pnpc_driver); | ||
705 | #endif | ||
706 | for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) | ||
707 | platform_device_unregister(platform_devices[i]); | ||
708 | platform_driver_unregister(&snd_sb16_nonpnp_driver); | ||
709 | } | ||
710 | |||
711 | static int __init alsa_card_sb16_init(void) | 700 | static int __init alsa_card_sb16_init(void) |
712 | { | 701 | { |
713 | int i, err, cards = 0; | 702 | int err; |
714 | 703 | ||
715 | if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0) | 704 | err = isa_register_driver(&snd_sb16_isa_driver, SNDRV_CARDS); |
705 | if (err < 0) | ||
716 | return err; | 706 | return err; |
717 | |||
718 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
719 | struct platform_device *device; | ||
720 | if (! enable[i] || is_isapnp_selected(i)) | ||
721 | continue; | ||
722 | device = platform_device_register_simple(SND_SB16_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 | #ifdef CONFIG_PNP | 707 | #ifdef CONFIG_PNP |
734 | /* PnP cards at last */ | 708 | /* PnP cards at last */ |
735 | err = pnp_register_card_driver(&sb16_pnpc_driver); | 709 | err = pnp_register_card_driver(&sb16_pnpc_driver); |
736 | if (!err) { | 710 | if (!err) |
737 | pnp_registered = 1; | 711 | pnp_registered = 1; |
738 | cards += sb16_pnp_devices; | ||
739 | } | ||
740 | #endif | ||
741 | |||
742 | if (!cards) { | ||
743 | #ifdef MODULE | ||
744 | snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); | ||
745 | #ifdef SNDRV_SBAWE_EMU8000 | ||
746 | snd_printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n"); | ||
747 | #else | ||
748 | snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); | ||
749 | #endif | 712 | #endif |
750 | #endif | ||
751 | snd_sb16_unregister_all(); | ||
752 | return -ENODEV; | ||
753 | } | ||
754 | return 0; | 713 | return 0; |
755 | } | 714 | } |
756 | 715 | ||
757 | static void __exit alsa_card_sb16_exit(void) | 716 | static void __exit alsa_card_sb16_exit(void) |
758 | { | 717 | { |
759 | snd_sb16_unregister_all(); | 718 | #ifdef CONFIG_PNP |
719 | if (pnp_registered) | ||
720 | pnp_unregister_card_driver(&sb16_pnpc_driver); | ||
721 | #endif | ||
722 | isa_unregister_driver(&snd_sb16_isa_driver); | ||
760 | } | 723 | } |
761 | 724 | ||
762 | module_init(alsa_card_sb16_init) | 725 | module_init(alsa_card_sb16_init) |