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 | |
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')
-rw-r--r-- | sound/isa/sb/sb16.c | 107 | ||||
-rw-r--r-- | sound/isa/sb/sb8.c | 86 |
2 files changed, 66 insertions, 127 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) |
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index be1e83e6dea3..b7de1bc0e8a4 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.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/ioport.h> | 27 | #include <linux/ioport.h> |
28 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
@@ -56,8 +56,6 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver."); | |||
56 | module_param_array(dma8, int, NULL, 0444); | 56 | module_param_array(dma8, int, NULL, 0444); |
57 | MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); | 57 | MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); |
58 | 58 | ||
59 | static struct platform_device *devices[SNDRV_CARDS]; | ||
60 | |||
61 | struct snd_sb8 { | 59 | struct snd_sb8 { |
62 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */ | 60 | struct resource *fm_res; /* used to block FM i/o region for legacy cards */ |
63 | struct snd_sb *chip; | 61 | struct snd_sb *chip; |
@@ -83,9 +81,23 @@ static void snd_sb8_free(struct snd_card *card) | |||
83 | release_and_free_resource(acard->fm_res); | 81 | release_and_free_resource(acard->fm_res); |
84 | } | 82 | } |
85 | 83 | ||
86 | static int __devinit snd_sb8_probe(struct platform_device *pdev) | 84 | static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev) |
85 | { | ||
86 | if (!enable[dev]) | ||
87 | return 0; | ||
88 | if (irq[dev] == SNDRV_AUTO_IRQ) { | ||
89 | snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id); | ||
90 | return 0; | ||
91 | } | ||
92 | if (dma8[dev] == SNDRV_AUTO_DMA) { | ||
93 | snd_printk(KERN_ERR "%s: please specify dma8\n", pdev->bus_id); | ||
94 | return 0; | ||
95 | } | ||
96 | return 1; | ||
97 | } | ||
98 | |||
99 | static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev) | ||
87 | { | 100 | { |
88 | int dev = pdev->id; | ||
89 | struct snd_sb *chip; | 101 | struct snd_sb *chip; |
90 | struct snd_card *card; | 102 | struct snd_card *card; |
91 | struct snd_sb8 *acard; | 103 | struct snd_sb8 *acard; |
@@ -180,12 +192,12 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev) | |||
180 | chip->port, | 192 | chip->port, |
181 | irq[dev], dma8[dev]); | 193 | irq[dev], dma8[dev]); |
182 | 194 | ||
183 | snd_card_set_dev(card, &pdev->dev); | 195 | snd_card_set_dev(card, pdev); |
184 | 196 | ||
185 | if ((err = snd_card_register(card)) < 0) | 197 | if ((err = snd_card_register(card)) < 0) |
186 | goto _err; | 198 | goto _err; |
187 | 199 | ||
188 | platform_set_drvdata(pdev, card); | 200 | dev_set_drvdata(pdev, card); |
189 | return 0; | 201 | return 0; |
190 | 202 | ||
191 | _err: | 203 | _err: |
@@ -193,17 +205,18 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev) | |||
193 | return err; | 205 | return err; |
194 | } | 206 | } |
195 | 207 | ||
196 | static int __devexit snd_sb8_remove(struct platform_device *pdev) | 208 | static int __devexit snd_sb8_remove(struct device *pdev, unsigned int dev) |
197 | { | 209 | { |
198 | snd_card_free(platform_get_drvdata(pdev)); | 210 | snd_card_free(dev_get_drvdata(pdev)); |
199 | platform_set_drvdata(pdev, NULL); | 211 | dev_set_drvdata(pdev, NULL); |
200 | return 0; | 212 | return 0; |
201 | } | 213 | } |
202 | 214 | ||
203 | #ifdef CONFIG_PM | 215 | #ifdef CONFIG_PM |
204 | static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) | 216 | static int snd_sb8_suspend(struct device *dev, unsigned int n, |
217 | pm_message_t state) | ||
205 | { | 218 | { |
206 | struct snd_card *card = platform_get_drvdata(dev); | 219 | struct snd_card *card = dev_get_drvdata(dev); |
207 | struct snd_sb8 *acard = card->private_data; | 220 | struct snd_sb8 *acard = card->private_data; |
208 | struct snd_sb *chip = acard->chip; | 221 | struct snd_sb *chip = acard->chip; |
209 | 222 | ||
@@ -213,9 +226,9 @@ static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) | |||
213 | return 0; | 226 | return 0; |
214 | } | 227 | } |
215 | 228 | ||
216 | static int snd_sb8_resume(struct platform_device *dev) | 229 | static int snd_sb8_resume(struct device *dev, unsigned int n) |
217 | { | 230 | { |
218 | struct snd_card *card = platform_get_drvdata(dev); | 231 | struct snd_card *card = dev_get_drvdata(dev); |
219 | struct snd_sb8 *acard = card->private_data; | 232 | struct snd_sb8 *acard = card->private_data; |
220 | struct snd_sb *chip = acard->chip; | 233 | struct snd_sb *chip = acard->chip; |
221 | 234 | ||
@@ -228,7 +241,8 @@ static int snd_sb8_resume(struct platform_device *dev) | |||
228 | 241 | ||
229 | #define SND_SB8_DRIVER "snd_sb8" | 242 | #define SND_SB8_DRIVER "snd_sb8" |
230 | 243 | ||
231 | static struct platform_driver snd_sb8_driver = { | 244 | static struct isa_driver snd_sb8_driver = { |
245 | .match = snd_sb8_match, | ||
232 | .probe = snd_sb8_probe, | 246 | .probe = snd_sb8_probe, |
233 | .remove = __devexit_p(snd_sb8_remove), | 247 | .remove = __devexit_p(snd_sb8_remove), |
234 | #ifdef CONFIG_PM | 248 | #ifdef CONFIG_PM |
@@ -240,52 +254,14 @@ static struct platform_driver snd_sb8_driver = { | |||
240 | }, | 254 | }, |
241 | }; | 255 | }; |
242 | 256 | ||
243 | static void __init_or_module snd_sb8_unregister_all(void) | ||
244 | { | ||
245 | int i; | ||
246 | |||
247 | for (i = 0; i < ARRAY_SIZE(devices); ++i) | ||
248 | platform_device_unregister(devices[i]); | ||
249 | platform_driver_unregister(&snd_sb8_driver); | ||
250 | } | ||
251 | |||
252 | static int __init alsa_card_sb8_init(void) | 257 | static int __init alsa_card_sb8_init(void) |
253 | { | 258 | { |
254 | int i, cards, err; | 259 | return isa_register_driver(&snd_sb8_driver, SNDRV_CARDS); |
255 | |||
256 | err = platform_driver_register(&snd_sb8_driver); | ||
257 | if (err < 0) | ||
258 | return err; | ||
259 | |||
260 | cards = 0; | ||
261 | for (i = 0; i < SNDRV_CARDS; i++) { | ||
262 | struct platform_device *device; | ||
263 | if (! enable[i]) | ||
264 | continue; | ||
265 | device = platform_device_register_simple(SND_SB8_DRIVER, | ||
266 | i, NULL, 0); | ||
267 | if (IS_ERR(device)) | ||
268 | continue; | ||
269 | if (!platform_get_drvdata(device)) { | ||
270 | platform_device_unregister(device); | ||
271 | continue; | ||
272 | } | ||
273 | devices[i] = device; | ||
274 | cards++; | ||
275 | } | ||
276 | if (!cards) { | ||
277 | #ifdef MODULE | ||
278 | snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n"); | ||
279 | #endif | ||
280 | snd_sb8_unregister_all(); | ||
281 | return -ENODEV; | ||
282 | } | ||
283 | return 0; | ||
284 | } | 260 | } |
285 | 261 | ||
286 | static void __exit alsa_card_sb8_exit(void) | 262 | static void __exit alsa_card_sb8_exit(void) |
287 | { | 263 | { |
288 | snd_sb8_unregister_all(); | 264 | isa_unregister_driver(&snd_sb8_driver); |
289 | } | 265 | } |
290 | 266 | ||
291 | module_init(alsa_card_sb8_init) | 267 | module_init(alsa_card_sb8_init) |