mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 1/5] of: fix of_get_next_child() for prev->parent != node
Date: Wed, 25 Sep 2024 16:01:11 +0200	[thread overview]
Message-ID: <20240925-of-graph-fixes-v1-1-c0a3ac989b0c@pengutronix.de> (raw)
In-Reply-To: <20240925-of-graph-fixes-v1-0-c0a3ac989b0c@pengutronix.de>

of_get_next_child() is supposed to return the next sibling of 'prev' and
the function does exactly that. It expects that 'node' is always the
same parent node. of_graph_get_next_endpoint() breaks this expectation,
it walks further down the tree and then calls of_get_next_child() with
'node' being some subnode of the original node. Fix this by retrieving
'node' always from 'prev' and use 'node' only on initial entry when
'prev' is NULL.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/base.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 62d84786ae..6fd69e7d7d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2054,6 +2054,9 @@ EXPORT_SYMBOL(of_get_next_available_child);
 struct device_node *of_get_next_child(const struct device_node *node,
 	struct device_node *prev)
 {
+	if (prev)
+		node = prev->parent;
+
 	prev = list_prepare_entry(prev, &node->children, parent_list);
 	list_for_each_entry_continue(prev, &node->children, parent_list)
 		return prev;

-- 
2.39.5




  reply	other threads:[~2024-09-25 14:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 14:01 [PATCH 0/5] of-graph fixes Sascha Hauer
2024-09-25 14:01 ` Sascha Hauer [this message]
2024-09-25 14:01 ` [PATCH 2/5] of: fix of_graph_get_next_endpoint() Sascha Hauer
2024-09-25 14:01 ` [PATCH 3/5] of: of_graph: honour ports subnode Sascha Hauer
2024-09-25 14:01 ` [PATCH 4/5] of: of_graph: fix of_graph_get_next_endpoint() Sascha Hauer
2024-09-25 14:01 ` [PATCH 5/5] of: of_graph: add missing functions Sascha Hauer
2024-09-27 10:39 ` [PATCH 0/5] of-graph fixes Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240925-of-graph-fixes-v1-1-c0a3ac989b0c@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox