diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2011-02-22 22:16:13 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-02-28 15:22:43 -0500 |
commit | e5263a517688b83861d406223a0f111a6e4116ff (patch) | |
tree | ad487f73ba74785a3725137e89b54278a3bfade4 /drivers/tty | |
parent | 55f19d56742a7b544e80b47339c17bfcfd0ff3b4 (diff) |
dt: uartlite: merge platform and of_platform driver bindings
of_platform_driver is getting removed, and a single platform_driver
can now support both devicetree and non-devicetree use cases. This
patch merges the two driver registrations.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/uartlite.c | 103 |
1 files changed, 24 insertions, 79 deletions
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c index d2fce865b731..8af1ed83a4c0 100644 --- a/drivers/tty/serial/uartlite.c +++ b/drivers/tty/serial/uartlite.c | |||
@@ -19,22 +19,11 @@ | |||
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
22 | #if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE)) | ||
23 | #include <linux/of.h> | 22 | #include <linux/of.h> |
24 | #include <linux/of_address.h> | 23 | #include <linux/of_address.h> |
25 | #include <linux/of_device.h> | 24 | #include <linux/of_device.h> |
26 | #include <linux/of_platform.h> | 25 | #include <linux/of_platform.h> |
27 | 26 | ||
28 | /* Match table for of_platform binding */ | ||
29 | static struct of_device_id ulite_of_match[] __devinitdata = { | ||
30 | { .compatible = "xlnx,opb-uartlite-1.00.b", }, | ||
31 | { .compatible = "xlnx,xps-uartlite-1.00.a", }, | ||
32 | {} | ||
33 | }; | ||
34 | MODULE_DEVICE_TABLE(of, ulite_of_match); | ||
35 | |||
36 | #endif | ||
37 | |||
38 | #define ULITE_NAME "ttyUL" | 27 | #define ULITE_NAME "ttyUL" |
39 | #define ULITE_MAJOR 204 | 28 | #define ULITE_MAJOR 204 |
40 | #define ULITE_MINOR 187 | 29 | #define ULITE_MINOR 187 |
@@ -571,9 +560,29 @@ static int __devexit ulite_release(struct device *dev) | |||
571 | * Platform bus binding | 560 | * Platform bus binding |
572 | */ | 561 | */ |
573 | 562 | ||
563 | #if defined(CONFIG_OF) | ||
564 | /* Match table for of_platform binding */ | ||
565 | static struct of_device_id ulite_of_match[] __devinitdata = { | ||
566 | { .compatible = "xlnx,opb-uartlite-1.00.b", }, | ||
567 | { .compatible = "xlnx,xps-uartlite-1.00.a", }, | ||
568 | {} | ||
569 | }; | ||
570 | MODULE_DEVICE_TABLE(of, ulite_of_match); | ||
571 | #else /* CONFIG_OF */ | ||
572 | #define ulite_of_match NULL | ||
573 | #endif /* CONFIG_OF */ | ||
574 | |||
574 | static int __devinit ulite_probe(struct platform_device *pdev) | 575 | static int __devinit ulite_probe(struct platform_device *pdev) |
575 | { | 576 | { |
576 | struct resource *res, *res2; | 577 | struct resource *res, *res2; |
578 | int id = pdev->id; | ||
579 | #ifdef CONFIG_OF | ||
580 | const __be32 *prop; | ||
581 | |||
582 | prop = of_get_property(pdev->dev.of_node, "port-number", NULL); | ||
583 | if (prop) | ||
584 | id = be32_to_cpup(prop); | ||
585 | #endif | ||
577 | 586 | ||
578 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 587 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
579 | if (!res) | 588 | if (!res) |
@@ -583,7 +592,7 @@ static int __devinit ulite_probe(struct platform_device *pdev) | |||
583 | if (!res2) | 592 | if (!res2) |
584 | return -ENODEV; | 593 | return -ENODEV; |
585 | 594 | ||
586 | return ulite_assign(&pdev->dev, pdev->id, res->start, res2->start); | 595 | return ulite_assign(&pdev->dev, id, res->start, res2->start); |
587 | } | 596 | } |
588 | 597 | ||
589 | static int __devexit ulite_remove(struct platform_device *pdev) | 598 | static int __devexit ulite_remove(struct platform_device *pdev) |
@@ -595,72 +604,15 @@ static int __devexit ulite_remove(struct platform_device *pdev) | |||
595 | MODULE_ALIAS("platform:uartlite"); | 604 | MODULE_ALIAS("platform:uartlite"); |
596 | 605 | ||
597 | static struct platform_driver ulite_platform_driver = { | 606 | static struct platform_driver ulite_platform_driver = { |
598 | .probe = ulite_probe, | 607 | .probe = ulite_probe, |
599 | .remove = __devexit_p(ulite_remove), | 608 | .remove = __devexit_p(ulite_remove), |
600 | .driver = { | ||
601 | .owner = THIS_MODULE, | ||
602 | .name = "uartlite", | ||
603 | }, | ||
604 | }; | ||
605 | |||
606 | /* --------------------------------------------------------------------- | ||
607 | * OF bus bindings | ||
608 | */ | ||
609 | #if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE)) | ||
610 | static int __devinit | ||
611 | ulite_of_probe(struct platform_device *op, const struct of_device_id *match) | ||
612 | { | ||
613 | struct resource res; | ||
614 | const unsigned int *id; | ||
615 | int irq, rc; | ||
616 | |||
617 | dev_dbg(&op->dev, "%s(%p, %p)\n", __func__, op, match); | ||
618 | |||
619 | rc = of_address_to_resource(op->dev.of_node, 0, &res); | ||
620 | if (rc) { | ||
621 | dev_err(&op->dev, "invalid address\n"); | ||
622 | return rc; | ||
623 | } | ||
624 | |||
625 | irq = irq_of_parse_and_map(op->dev.of_node, 0); | ||
626 | |||
627 | id = of_get_property(op->dev.of_node, "port-number", NULL); | ||
628 | |||
629 | return ulite_assign(&op->dev, id ? *id : -1, res.start, irq); | ||
630 | } | ||
631 | |||
632 | static int __devexit ulite_of_remove(struct platform_device *op) | ||
633 | { | ||
634 | return ulite_release(&op->dev); | ||
635 | } | ||
636 | |||
637 | static struct of_platform_driver ulite_of_driver = { | ||
638 | .probe = ulite_of_probe, | ||
639 | .remove = __devexit_p(ulite_of_remove), | ||
640 | .driver = { | 609 | .driver = { |
641 | .name = "uartlite", | ||
642 | .owner = THIS_MODULE, | 610 | .owner = THIS_MODULE, |
611 | .name = "uartlite", | ||
643 | .of_match_table = ulite_of_match, | 612 | .of_match_table = ulite_of_match, |
644 | }, | 613 | }, |
645 | }; | 614 | }; |
646 | 615 | ||
647 | /* Registration helpers to keep the number of #ifdefs to a minimum */ | ||
648 | static inline int __init ulite_of_register(void) | ||
649 | { | ||
650 | pr_debug("uartlite: calling of_register_platform_driver()\n"); | ||
651 | return of_register_platform_driver(&ulite_of_driver); | ||
652 | } | ||
653 | |||
654 | static inline void __exit ulite_of_unregister(void) | ||
655 | { | ||
656 | of_unregister_platform_driver(&ulite_of_driver); | ||
657 | } | ||
658 | #else /* CONFIG_OF && (CONFIG_PPC32 || CONFIG_MICROBLAZE) */ | ||
659 | /* Appropriate config not enabled; do nothing helpers */ | ||
660 | static inline int __init ulite_of_register(void) { return 0; } | ||
661 | static inline void __exit ulite_of_unregister(void) { } | ||
662 | #endif /* CONFIG_OF && (CONFIG_PPC32 || CONFIG_MICROBLAZE) */ | ||
663 | |||
664 | /* --------------------------------------------------------------------- | 616 | /* --------------------------------------------------------------------- |
665 | * Module setup/teardown | 617 | * Module setup/teardown |
666 | */ | 618 | */ |
@@ -674,10 +626,6 @@ int __init ulite_init(void) | |||
674 | if (ret) | 626 | if (ret) |
675 | goto err_uart; | 627 | goto err_uart; |
676 | 628 | ||
677 | ret = ulite_of_register(); | ||
678 | if (ret) | ||
679 | goto err_of; | ||
680 | |||
681 | pr_debug("uartlite: calling platform_driver_register()\n"); | 629 | pr_debug("uartlite: calling platform_driver_register()\n"); |
682 | ret = platform_driver_register(&ulite_platform_driver); | 630 | ret = platform_driver_register(&ulite_platform_driver); |
683 | if (ret) | 631 | if (ret) |
@@ -686,8 +634,6 @@ int __init ulite_init(void) | |||
686 | return 0; | 634 | return 0; |
687 | 635 | ||
688 | err_plat: | 636 | err_plat: |
689 | ulite_of_unregister(); | ||
690 | err_of: | ||
691 | uart_unregister_driver(&ulite_uart_driver); | 637 | uart_unregister_driver(&ulite_uart_driver); |
692 | err_uart: | 638 | err_uart: |
693 | printk(KERN_ERR "registering uartlite driver failed: err=%i", ret); | 639 | printk(KERN_ERR "registering uartlite driver failed: err=%i", ret); |
@@ -697,7 +643,6 @@ err_uart: | |||
697 | void __exit ulite_exit(void) | 643 | void __exit ulite_exit(void) |
698 | { | 644 | { |
699 | platform_driver_unregister(&ulite_platform_driver); | 645 | platform_driver_unregister(&ulite_platform_driver); |
700 | ulite_of_unregister(); | ||
701 | uart_unregister_driver(&ulite_uart_driver); | 646 | uart_unregister_driver(&ulite_uart_driver); |
702 | } | 647 | } |
703 | 648 | ||