Skip to content

Commit

Permalink
of: fix incorrect return value of of_find_matching_node_and_match()
Browse files Browse the repository at this point in the history
The of_find_matching_node_and_match() function incorrectly sets the matched
entry to 'matches' when the compatible value of a node matches one of the
possible values. This results in incorrectly selecting the the first entry in
the 'matches' list as the matched entry. Fix this by noting down the result of
the call to of_match_node() and setting that as the matched entry.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
  • Loading branch information
Thomas Abraham authored and Rob Herring committed Jan 20, 2013
1 parent 7d1f9ae commit dc71bcf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,16 +612,18 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
const struct of_device_id **match)
{
struct device_node *np;
const struct of_device_id *m;

if (match)
*match = NULL;

read_lock(&devtree_lock);
np = from ? from->allnext : of_allnodes;
for (; np; np = np->allnext) {
if (of_match_node(matches, np) && of_node_get(np)) {
m = of_match_node(matches, np);
if (m && of_node_get(np)) {
if (match)
*match = matches;
*match = m;
break;
}
}
Expand Down

0 comments on commit dc71bcf

Please sign in to comment.