History

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.

Kevin Hao committed 12 years ago

Commit 4e8ca6e1 parent 860a4451 file · +16 −37Browse files

Unified · Split

drivers/of/base.c+16−37
@@ -734,42 +734,24 @@ static · 733 unmodified lines
734const struct of_device_id *__of_match_node(const struct of_device_id *matches,734const 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->name748 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->type751 if (match)
755 && !strcmp(m->type, node->type);752 return matches;
756 if (m->compatible[0])753 matches++;
757 match &= cp754 }
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, · 2 unmodified lines
778 * @matches: array of of device match structures to search in760 * @matches: array of of device match structures to search in
779 * @node: the of device structure to match against761 * @node: the of device structure to match against
780 *762 *
781 * Low level utility function used by device matching. Matching order763 * 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 */
786const struct of_device_id *of_match_node(const struct of_device_id *matches,765const 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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t