Skip to contentSkip to conversation

of: fix incorrect return value of of_find_matching_node_and_match()

PATCH New Thomas Abraham 2 participants 6 messages Jan 19, 2013 – Jan 21, 2013 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: fix incorrect return value of of_find_matching_node_and_match()

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.

---
 drivers/of/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/of/base.c +4 -2
index 2390ddb..960ae5b 100644
@@ -612,6 +612,7 @@ 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;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
 	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;
 		}
 	}
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 of: fix incorrect return value of of_find_matching_node_and_match()

Quoted 10 lines · Thomas Abraham

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.

---
 drivers/of/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

[Adding devicetree-discuss at lists.ozlabs.org to the cc list]

Quoted 29 lines
drivers/of/base.c +4 -3
index 2390ddb..960ae5b 100644
@@ -612,6 +612,7 @@ 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;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
        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;
                }
        }
--

1.7.5.4

#2 lore raw

PATCH 1/1 of: fix incorrect return value of of_find_matching_node_and_match()

In reply to Thomas Abraham
Quoted 5 lines · Thomas Abraham

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.

Looks fine, but is this breaking something in 3.8 or can it wait for 3.9?

Rob

Quoted 32 lines
---
 drivers/of/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/of/base.c +4 -2
index 2390ddb..960ae5b 100644
@@ -612,6 +612,7 @@ 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;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
 	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;
 		}
 	}
#3 lore raw

PATCH 1/1 of: fix incorrect return value of of_find_matching_node_and_match()

Quoted 8 lines · Rob Herring
Quoted 5 lines · Thomas Abraham

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.

Looks fine, but is this breaking something in 3.8 or can it wait for 3.9?

Yes, it can wait for 3.9. I am using this function while adding device tree support for timers on exynos platform which will probably merged in 3.9.

Thanks,
Thomas.

Quoted 35 lines

Rob

Quoted 32 lines
---
 drivers/of/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/of/base.c +4 -2
index 2390ddb..960ae5b 100644
@@ -612,6 +612,7 @@ 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;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
      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;
              }
      }
#4 lore raw

PATCH 1/1 of: fix incorrect return value of of_find_matching_node_and_match()

Quoted 8 lines · Thomas Abraham
Quoted 7 lines · Rob Herring
Quoted 5 lines · Thomas Abraham

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.

Quoted 5 lines
Quoted 1 line

Looks fine, but is this breaking something in 3.8 or can it wait for 3.9?

Yes, it can wait for 3.9. I am using this function while adding device tree support for timers on exynos platform which will probably merged in 3.9.

Applied for 3.9. It's in my for-next branch on sources.calxeda.com. This is a stable branch.

Rob

Quoted 39 lines

Thanks,
Thomas.

Quoted 35 lines

Rob

Quoted 32 lines
---
 drivers/of/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/of/base.c +4 -2
index 2390ddb..960ae5b 100644
@@ -612,6 +612,7 @@ 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;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
      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;
              }
      }
#5 lore raw

PATCH 1/1 of: fix incorrect return value of of_find_matching_node_and_match()

Quoted 11 lines · Rob Herring
Quoted 10 lines · Thomas Abraham
Quoted 8 lines · Rob Herring
Quoted 5 lines · Thomas Abraham

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.

Looks fine, but is this breaking something in 3.8 or can it wait for 3.9?

Quoted 8 lines
Quoted 3 lines

Yes, it can wait for 3.9. I am using this function while adding device tree support for timers on exynos platform which will probably merged in 3.9.

Applied for 3.9. It's in my for-next branch on sources.calxeda.com. This is a stable branch.

Rob

Thank you Rob.

Regards,
Thomas.