mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/4] of: partitions: export of_fixup_partitions
Date: Wed, 25 Nov 2020 06:20:09 +0100	[thread overview]
Message-ID: <20201125052011.20660-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20201125052011.20660-1-s.hauer@pengutronix.de>

of_partitions_register_fixup() tries to automatically determine the
node to fixup. Sometimes this doesn't work, so add of_fixup_partitions()
that can called at fixup time with a device node determined by subsystem
or driver code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/partition.c | 37 +++++++++++++++++++++----------------
 include/of.h           |  6 ++++++
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index 7367073c67..65c24c5426 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -123,20 +123,16 @@ static void delete_subnodes(struct device_node *np)
 	}
 }
 
-static int of_partition_fixup(struct device_node *root, void *ctx)
+int of_fixup_partitions(struct device_node *np, struct cdev *cdev)
 {
-	struct cdev *cdev = ctx, *partcdev;
-	struct device_node *np, *part, *partnode;
-	char *name;
+	struct cdev *partcdev;
+	struct device_node *part, *partnode;
 	int ret;
 	int n_cells, n_parts = 0;
 
 	if (of_partition_binding == MTD_OF_BINDING_DONTTOUCH)
 		return 0;
 
-	if (!cdev->device_node)
-		return -EINVAL;
-
 	list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
 		if (partcdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			continue;
@@ -151,15 +147,6 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
 	else
 		n_cells = 1;
 
-	name = of_get_reproducible_name(cdev->device_node);
-	np = of_find_node_by_reproducible_name(root, name);
-	free(name);
-	if (!np) {
-		dev_err(cdev->dev, "Cannot find nodepath %s, cannot fixup\n",
-				cdev->device_node->full_name);
-		return -EINVAL;
-	}
-
 	partnode = of_get_child_by_name(np, "partitions");
 	if (partnode) {
 		if (of_partition_binding == MTD_OF_BINDING_LEGACY) {
@@ -242,6 +229,24 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
 	return 0;
 }
 
+static int of_partition_fixup(struct device_node *root, void *ctx)
+{
+	struct cdev *cdev = ctx;
+	struct device_node *np;
+	char *name;
+
+	name = of_get_reproducible_name(cdev->device_node);
+	np = of_find_node_by_reproducible_name(root, name);
+	free(name);
+	if (!np) {
+		dev_err(cdev->dev, "Cannot find nodepath %s, cannot fixup\n",
+				cdev->device_node->full_name);
+		return -EINVAL;
+	}
+
+	return of_fixup_partitions(np, cdev);
+}
+
 int of_partitions_register_fixup(struct cdev *cdev)
 {
 	return of_register_fixup(of_partition_fixup, cdev);
diff --git a/include/of.h b/include/of.h
index 08a02e1105..aebd8384ad 100644
--- a/include/of.h
+++ b/include/of.h
@@ -275,6 +275,7 @@ extern struct device_d *of_device_enable_and_register_by_alias(
 
 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 of_device_is_stdout_path(struct device_d *dev);
 const char *of_get_model(void);
@@ -303,6 +304,11 @@ static inline int of_parse_partitions(struct cdev *cdev,
 	return -EINVAL;
 }
 
+static inline int of_fixup_partitions(struct device_node *np, struct cdev *cdev)
+{
+	return -ENOSYS;
+}
+
 static inline int of_partitions_register_fixup(struct cdev *cdev)
 {
 	return -ENOSYS;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-11-25  5:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25  5:20 [PATCH 0/4] mtd: nand: Add special fixup kernel partitions for Denali Sascha Hauer
2020-11-25  5:20 ` [PATCH 1/4] mtd: Remove set but not used of_path Sascha Hauer
2020-11-25  5:20 ` Sascha Hauer [this message]
2020-11-25  5:20 ` [PATCH 3/4] mtd: Add hook to fix up kernel partitions Sascha Hauer
2020-11-25  5:20 ` [PATCH 4/4] mtd: nand: denali: cope with kernel device trees without chip subnodes 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=20201125052011.20660-3-s.hauer@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