mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 7/8] of: partition: add a helper to determin if a node is a of-partition
Date: Fri, 14 Oct 2022 18:35:33 +0200	[thread overview]
Message-ID: <20221014163534.3812272-8-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20221014163534.3812272-1-m.felsch@pengutronix.de>

This helper checks if the given device_node is a of-partition. The check
is based on the node name which should something like partition@xxx. If
that fails the we try to check if the parent node contains a
"fixed-partitions" compatible.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/of/partition.c | 12 ++++++++++++
 include/of.h           |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index abbda674d6..494fd92660 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -107,6 +107,18 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
 	return 0;
 }
 
+int is_of_partition(struct device_node *np)
+{
+	if (of_node_name_eq(np, "partition"))
+		return 1;
+
+	np = of_get_parent(np);
+	if (of_device_is_compatible(np, "fixed-partitions"))
+		return 1;
+
+	return 0;
+}
+
 int of_partition_ensure_probed(struct device_node *np)
 {
 	np = of_get_parent(np);
diff --git a/include/of.h b/include/of.h
index 052d5fcad8..d6a3e75f86 100644
--- a/include/of.h
+++ b/include/of.h
@@ -309,6 +309,7 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node);
 int of_parse_partitions(struct cdev *cdev, struct device_node *node);
 int of_fixup_partitions(struct device_node *np, struct cdev *cdev);
 int of_partitions_register_fixup(struct cdev *cdev);
+int is_of_partition(struct device_node *np);
 struct device_node *of_get_stdoutpath(unsigned int *);
 int of_device_is_stdout_path(struct device_d *dev, unsigned int *baudrate);
 const char *of_get_model(void);
@@ -359,6 +360,11 @@ static inline int of_partitions_register_fixup(struct cdev *cdev)
 	return -ENOSYS;
 }
 
+static inline int is_of_partition(struct device_node *np)
+{
+	return -ENOSYS;
+}
+
 static inline struct device_node *of_get_stdoutpath(unsigned int *rate)
 {
 	return NULL;
-- 
2.30.2




  parent reply	other threads:[~2022-10-14 16:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 16:35 [PATCH 0/8] Barebox-State on-disk partition support Marco Felsch
2022-10-14 16:35 ` [PATCH 1/8] of: of_node_name_eq: correct alignment Marco Felsch
2022-10-20  6:36   ` Sascha Hauer
2022-10-14 16:35 ` [PATCH 2/8] state: select the STATE_DRV when STATE is selected Marco Felsch
2022-10-19  7:48   ` Sascha Hauer
2022-10-19  8:14     ` Marco Felsch
2022-10-14 16:35 ` [PATCH 3/8] state: rename partition_node to backend_node Marco Felsch
2022-10-14 16:35 ` [PATCH 4/8] state: cosmetic fix reverse christmas tree order Marco Felsch
2022-10-19  7:55   ` Sascha Hauer
2022-10-19  8:18     ` Marco Felsch
2022-10-14 16:35 ` [PATCH 5/8] state: rename backend members Marco Felsch
2022-10-14 16:35 ` [PATCH 6/8] state: factor out the backend property parsing Marco Felsch
2022-10-14 16:35 ` Marco Felsch [this message]
2022-10-14 16:35 ` [PATCH 8/8] state: add support for new backend format Marco Felsch
2022-10-20  6:35   ` Sascha Hauer
2022-10-14 16:44 ` [PATCH 0/8] Barebox-State on-disk partition support Marco Felsch

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=20221014163534.3812272-8-m.felsch@pengutronix.de \
    --to=m.felsch@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