diff options
author | Kevin Hao <haokexin@gmail.com> | 2014-02-14 00:22:45 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2014-02-14 14:52:50 -0500 |
commit | 4e8ca6ee3a5d0e0f4c0cb32e43dc3d69e79e5a76 (patch) | |
tree | 4efa5336730dc37f6895b5ac4357a8ee6338e1c9 /drivers/of | |
parent | 860a445c25aa2f99aa5881603a1f4ed2cec64025 (diff) |
Revert "OF: base: match each node compatible against all given matches first"
This reverts commit 105353145eafb3ea919f5cdeb652a9d8f270228e.
Stephen Chivers reported this is broken as we will get a match
entry '.type = "serial"' instead of the '.compatible = "ns16550"'
in the following scenario:
serial0: serial@4500 {
compatible = "fsl,ns16550", "ns16550";
}
struct of_device_id of_platform_serial_table[] = {
{ .compatible = "ns8250", .data = (void *)PORT_8250, },
{ .compatible = "ns16450", .data = (void *)PORT_16450, },
{ .compatible = "ns16550a", .data = (void *)PORT_16550A, },
{ .compatible = "ns16550", .data = (void *)PORT_16550, },
{ .compatible = "ns16750", .data = (void *)PORT_16750, },
{ .compatible = "ns16850", .data = (void *)PORT_16850, },
...
{ .type = "serial", .data = (void *)PORT_UNKNOWN, },
{ /* end of list */ },
};
So just revert this patch, we will use another implementation to find
the best compatible match in a follow-on patch.
Reported-by: Stephen N Chivers <schivers@csc.com.au>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index ff85450d5683..ba195fbce4c6 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -734,42 +734,24 @@ static | |||
734 | const struct of_device_id *__of_match_node(const struct of_device_id *matches, | 734 | const struct of_device_id *__of_match_node(const struct of_device_id *matches, |
735 | const struct device_node *node) | 735 | const struct device_node *node) |
736 | { | 736 | { |
737 | const char *cp; | ||
738 | int cplen, l; | ||
739 | |||
740 | if (!matches) | 737 | if (!matches) |
741 | return NULL; | 738 | return NULL; |
742 | 739 | ||
743 | cp = __of_get_property(node, "compatible", &cplen); | 740 | while (matches->name[0] || matches->type[0] || matches->compatible[0]) { |
744 | do { | 741 | int match = 1; |
745 | const struct of_device_id *m = matches; | 742 | if (matches->name[0]) |
746 | 743 | match &= node->name | |
747 | /* Check against matches with current compatible string */ | 744 | && !strcmp(matches->name, node->name); |
748 | while (m->name[0] || m->type[0] || m->compatible[0]) { | 745 | if (matches->type[0]) |
749 | int match = 1; | 746 | match &= node->type |
750 | if (m->name[0]) | 747 | && !strcmp(matches->type, node->type); |
751 | match &= node->name | 748 | if (matches->compatible[0]) |
752 | && !strcmp(m->name, node->name); | 749 | match &= __of_device_is_compatible(node, |
753 | if (m->type[0]) | 750 | matches->compatible); |
754 | match &= node->type | 751 | if (match) |
755 | && !strcmp(m->type, node->type); | 752 | return matches; |
756 | if (m->compatible[0]) | 753 | matches++; |
757 | match &= cp | 754 | } |
758 | && !of_compat_cmp(m->compatible, cp, | ||
759 | strlen(m->compatible)); | ||
760 | if (match) | ||
761 | return m; | ||
762 | m++; | ||
763 | } | ||
764 | |||
765 | /* Get node's next compatible string */ | ||
766 | if (cp) { | ||
767 | l = strlen(cp) + 1; | ||
768 | cp += l; | ||
769 | cplen -= l; | ||
770 | } | ||
771 | } while (cp && (cplen > 0)); | ||
772 | |||
773 | return NULL; | 755 | return NULL; |
774 | } | 756 | } |
775 | 757 | ||
@@ -778,10 +760,7 @@ const struct of_device_id *__of_match_node(const struct of_device_id *matches, | |||
778 | * @matches: array of of device match structures to search in | 760 | * @matches: array of of device match structures to search in |
779 | * @node: the of device structure to match against | 761 | * @node: the of device structure to match against |
780 | * | 762 | * |
781 | * Low level utility function used by device matching. Matching order | 763 | * Low level utility function used by device matching. |
782 | * is to compare each of the node's compatibles with all given matches | ||
783 | * first. This implies node's compatible is sorted from specific to | ||
784 | * generic while matches can be in any order. | ||
785 | */ | 764 | */ |
786 | const struct of_device_id *of_match_node(const struct of_device_id *matches, | 765 | const struct of_device_id *of_match_node(const struct of_device_id *matches, |
787 | const struct device_node *node) | 766 | const struct device_node *node) |