From: "Rob Herring (Arm)" <robh@kernel.org>
To: Saravana Kannan <saravanak@google.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] of: Add an iterator to walk up parent nodes
Date: Thu, 30 May 2024 20:03:27 -0500 [thread overview]
Message-ID: <20240530-dt-interrupt-map-fix-v1-1-2331d8732f08@kernel.org> (raw)
In-Reply-To: <20240530-dt-interrupt-map-fix-v1-0-2331d8732f08@kernel.org>
Similar to other node iterators, add one for walking up parent
nodes. The iterator starts on the current node, not the immediate
parent as that seems to be the common case and starting with the parent
node can be implemented like this:
for_each_parent_of_node_scoped(parent, of_get_parent(node))
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
include/linux/of.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/of.h b/include/linux/of.h
index a0bedd038a05..c322802dfc2b 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1482,6 +1482,11 @@ static inline int of_property_read_s32(const struct device_node *np,
child != NULL; \
child = of_get_next_available_child(parent, child))
+#define for_each_parent_of_node_scoped(parent, node) \
+ for (struct device_node *parent __free(device_node) = \
+ of_node_get(node) ; \
+ parent; parent = of_get_next_parent(parent))
+
#define for_each_of_cpu_node(cpu) \
for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
cpu = of_get_next_cpu_node(cpu))
--
2.43.0
next prev parent reply other threads:[~2024-05-31 1:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 1:03 [PATCH 0/3] of: Reimplement of_(bus_)?n_(size|addr)_cells() Rob Herring (Arm)
2024-05-31 1:03 ` Rob Herring (Arm) [this message]
2024-05-31 1:03 ` [PATCH 2/3] of: Add missing locking to of_(bus_)?n_(size|addr)_cells() Rob Herring (Arm)
2024-06-04 16:08 ` Rob Herring
2024-05-31 1:03 ` [PATCH 3/3] of/irq: Use of_bus_n_addr_cells() to retrieve "#address-cells" Rob Herring (Arm)
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=20240530-dt-interrupt-map-fix-v1-1-2331d8732f08@kernel.org \
--to=robh@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=saravanak@google.com \
/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
all inboxes | Powered by JetHome®