Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'dt-fixes-for-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull devicetree fixes from Rob Herring:
"Fix booting on PPC boards. Changes to of_match_node matching caused
the serial port on some PPC boards to stop working. Reverted the
change and reimplement to split matching between new style compatible
only matching and fallback to old matching algorithm"

* tag 'dt-fixes-for-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
of: search the best compatible match first in __of_match_node()
Revert "OF: base: match each node compatible against all given matches first"

+55 -35
+55 -35
drivers/of/base.c
··· 730 730 } 731 731 EXPORT_SYMBOL(of_find_node_with_property); 732 732 733 + static const struct of_device_id * 734 + of_match_compatible(const struct of_device_id *matches, 735 + const struct device_node *node) 736 + { 737 + const char *cp; 738 + int cplen, l; 739 + const struct of_device_id *m; 740 + 741 + cp = __of_get_property(node, "compatible", &cplen); 742 + while (cp && (cplen > 0)) { 743 + m = matches; 744 + while (m->name[0] || m->type[0] || m->compatible[0]) { 745 + /* Only match for the entries without type and name */ 746 + if (m->name[0] || m->type[0] || 747 + of_compat_cmp(m->compatible, cp, 748 + strlen(m->compatible))) 749 + m++; 750 + else 751 + return m; 752 + } 753 + 754 + /* Get node's next compatible string */ 755 + l = strlen(cp) + 1; 756 + cp += l; 757 + cplen -= l; 758 + } 759 + 760 + return NULL; 761 + } 762 + 733 763 static 734 764 const struct of_device_id *__of_match_node(const struct of_device_id *matches, 735 765 const struct device_node *node) 736 766 { 737 - const char *cp; 738 - int cplen, l; 767 + const struct of_device_id *m; 739 768 740 769 if (!matches) 741 770 return NULL; 742 771 743 - cp = __of_get_property(node, "compatible", &cplen); 744 - do { 745 - const struct of_device_id *m = matches; 772 + m = of_match_compatible(matches, node); 773 + if (m) 774 + return m; 746 775 747 - /* Check against matches with current compatible string */ 748 - while (m->name[0] || m->type[0] || m->compatible[0]) { 749 - int match = 1; 750 - if (m->name[0]) 751 - match &= node->name 752 - && !strcmp(m->name, node->name); 753 - if (m->type[0]) 754 - match &= node->type 755 - && !strcmp(m->type, node->type); 756 - if (m->compatible[0]) 757 - match &= cp 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 - 776 + while (matches->name[0] || matches->type[0] || matches->compatible[0]) { 777 + int match = 1; 778 + if (matches->name[0]) 779 + match &= node->name 780 + && !strcmp(matches->name, node->name); 781 + if (matches->type[0]) 782 + match &= node->type 783 + && !strcmp(matches->type, node->type); 784 + if (matches->compatible[0]) 785 + match &= __of_device_is_compatible(node, 786 + matches->compatible); 787 + if (match) 788 + return matches; 789 + matches++; 790 + } 773 791 return NULL; 774 792 } 775 793 ··· 796 778 * @matches: array of of device match structures to search in 797 779 * @node: the of device structure to match against 798 780 * 799 - * Low level utility function used by device matching. Matching order 800 - * is to compare each of the node's compatibles with all given matches 801 - * first. This implies node's compatible is sorted from specific to 802 - * generic while matches can be in any order. 781 + * Low level utility function used by device matching. We have two ways 782 + * of matching: 783 + * - Try to find the best compatible match by comparing each compatible 784 + * string of device node with all the given matches respectively. 785 + * - If the above method failed, then try to match the compatible by using 786 + * __of_device_is_compatible() besides the match in type and name. 803 787 */ 804 788 const struct of_device_id *of_match_node(const struct of_device_id *matches, 805 789 const struct device_node *node)