diff options
| -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) |
