mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/6] of: factor out of_node_is_fixed_partitions check
Date: Mon, 17 Feb 2025 19:08:28 +0100	[thread overview]
Message-ID: <20250217180833.3955657-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250217180833.3955657-1-a.fatoum@pengutronix.de>

We have a number of places where we check if a node is compatible with
"fixed-partitions". In preparation for supporting
"barebox,fixed-partitions" as well, factor out the existing compatible
check into a new of_node_is_fixed_partitions() function.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/base.c      | 6 ++----
 drivers/of/of_path.c   | 7 ++++++-
 drivers/of/partition.c | 4 ++--
 include/of.h           | 6 ++++++
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 125f24056eec..dfe4861c9eb6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -351,7 +351,7 @@ static const char *of_get_partition_device_alias(struct device_node *np)
 		return alias;
 
 	np = of_get_parent(np);
-	if (np && of_device_is_compatible(np, "fixed-partitions"))
+	if (np && of_node_is_fixed_partitions(np))
 		np = of_get_parent(np);
 
 	return of_alias_get(np);
@@ -3271,10 +3271,8 @@ char *of_get_reproducible_name(struct device_node *node)
 	 * "fixed-partitions" compatible. We skip this extra subnode from the
 	 * reproducible name to get the same name for both bindings.
 	 */
-	if (node->parent &&
-	    of_device_is_compatible(node->parent, "fixed-partitions")) {
+	if (node->parent && of_node_is_fixed_partitions(node->parent))
 		node = node->parent;
-	}
 
 	offset = of_read_number(reg, na);
 
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 42efb1ad1dbf..b3feaa07e39d 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -12,6 +12,11 @@
 
 #include <linux/mtd/mtd.h>
 
+bool of_node_is_fixed_partitions(const struct device_node *np)
+{
+	return of_device_is_compatible(np, "fixed-partitions");
+}
+
 struct device *of_find_device_by_node_path(const char *path)
 {
 	struct device *dev;
@@ -55,7 +60,7 @@ static struct cdev *__of_cdev_find(struct device_node *node, const char *part)
 		const char *uuid;
 		struct device_node *devnode = node->parent;
 
-		if (of_device_is_compatible(devnode, "fixed-partitions")) {
+		if (of_node_is_fixed_partitions(devnode)) {
 			devnode = devnode->parent;
 
 			/* when partuuid is specified short-circuit the search for the cdev */
diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index 56933cc958f7..4f966d900f1f 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -93,7 +93,7 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
 
 	subnode = of_get_child_by_name(node, "partitions");
 	if (subnode) {
-		if (!of_device_is_compatible(subnode, "fixed-partitions"))
+		if (!of_node_is_fixed_partitions(subnode))
 			return -EINVAL;
 		node = subnode;
 	}
@@ -125,7 +125,7 @@ int of_partition_ensure_probed(struct device_node *np)
 		return -EINVAL;
 
 	/* Check if modern partitions binding */
-	if (of_device_is_compatible(parent, "fixed-partitions")) {
+	if (of_node_is_fixed_partitions(parent)) {
 		parent = of_get_parent(parent);
 
 		/*
diff --git a/include/of.h b/include/of.h
index a83663c602b1..985f0195b2aa 100644
--- a/include/of.h
+++ b/include/of.h
@@ -204,6 +204,7 @@ extern const char *of_get_machine_compatible(void);
 extern int of_machine_is_compatible(const char *compat);
 extern int of_device_is_compatible(const struct device_node *device,
 		const char *compat);
+extern bool of_node_is_fixed_partitions(const struct device_node *np);
 extern int of_device_is_available(const struct device_node *device);
 extern bool of_device_is_big_endian(const struct device_node *device);
 
@@ -916,6 +917,11 @@ static inline int of_device_is_compatible(const struct device_node *device,
 	return 0;
 }
 
+static inline bool of_node_is_fixed_partitions(const struct device_node *device)
+{
+	return false;
+}
+
 static inline int of_device_is_available(const struct device_node *device)
 {
 	return 0;
-- 
2.39.5




  reply	other threads:[~2025-02-17 18:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 18:08 [PATCH 0/6] of: partition: add Linux CONFIG_OF_PARTITION-compatible adaptive fixup mode Ahmad Fatoum
2025-02-17 18:08 ` Ahmad Fatoum [this message]
2025-02-17 18:08 ` [PATCH 2/6] of: of_path: support barebox,fixed-partitions Ahmad Fatoum
2025-02-17 18:08 ` [PATCH 3/6] ARM: IMX8MP: var-dart-dt8mcustomboard.dts: use new-style partition binding Ahmad Fatoum
2025-02-17 18:08 ` [PATCH 4/6] ARM: dts: prefix all non-MTD fixed-partitions with barebox, Ahmad Fatoum
2025-02-17 18:08 ` [PATCH 5/6] of: partition: refactor of_partition_binding checks into switch Ahmad Fatoum
2025-02-17 18:08 ` [PATCH 6/6] of: partition: add Linux CONFIG_OF_PARTITION-compatible adaptive fixup mode Ahmad Fatoum
2025-02-17 19:25 ` [PATCH 0/6] " Marco Felsch
2025-02-17 19:57   ` Ahmad Fatoum
2025-02-20  8:26 ` 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=20250217180833.3955657-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@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