Skip to content

Commit bc51b0c

Browse files
committed
Revert "of: match by compatible property first"
This reverts commit 107a84e. Meelis Roos reports a regression since 3.5-rc5 that stops Sun Fire V100 and Sun Netra X1 sparc64 machines from booting, hanging after enabling serial console. He bisected it to commit 107a84e. Rob Herring explains: "The problem is match combinations of compatible plus name and/or type fail to match correctly. I have a fix for this, but given how late it is for 3.5 I think it is best to revert this for now. There could be other cases that rely on the current although wrong behavior. I will post an updated version for 3.6." Bisected-and-reported-by: Meelis Roos <[email protected]> Requested-by: Rob Herring <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Grant Likely <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2437fcc commit bc51b0c

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

drivers/of/base.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -511,22 +511,6 @@ struct device_node *of_find_node_with_property(struct device_node *from,
511511
}
512512
EXPORT_SYMBOL(of_find_node_with_property);
513513

514-
static const struct of_device_id *of_match_compat(const struct of_device_id *matches,
515-
const char *compat)
516-
{
517-
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
518-
const char *cp = matches->compatible;
519-
int len = strlen(cp);
520-
521-
if (len > 0 && of_compat_cmp(compat, cp, len) == 0)
522-
return matches;
523-
524-
matches++;
525-
}
526-
527-
return NULL;
528-
}
529-
530514
/**
531515
* of_match_node - Tell if an device_node has a matching of_match structure
532516
* @matches: array of of device match structures to search in
@@ -537,18 +521,9 @@ static const struct of_device_id *of_match_compat(const struct of_device_id *mat
537521
const struct of_device_id *of_match_node(const struct of_device_id *matches,
538522
const struct device_node *node)
539523
{
540-
struct property *prop;
541-
const char *cp;
542-
543524
if (!matches)
544525
return NULL;
545526

546-
of_property_for_each_string(node, "compatible", prop, cp) {
547-
const struct of_device_id *match = of_match_compat(matches, cp);
548-
if (match)
549-
return match;
550-
}
551-
552527
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
553528
int match = 1;
554529
if (matches->name[0])
@@ -557,7 +532,10 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
557532
if (matches->type[0])
558533
match &= node->type
559534
&& !strcmp(matches->type, node->type);
560-
if (match && !matches->compatible[0])
535+
if (matches->compatible[0])
536+
match &= of_device_is_compatible(node,
537+
matches->compatible);
538+
if (match)
561539
return matches;
562540
matches++;
563541
}

0 commit comments

Comments
 (0)