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 master] of: partition: do not try to translate offset as OF address
Date: Thu, 10 Apr 2025 11:55:57 +0200	[thread overview]
Message-ID: <20250410095557.2248025-1-a.fatoum@pengutronix.de> (raw)

of_platform_populate will eventually call of_platform_device_create,
which will print out errors, because of_translate_address chokes on the
partitions node.

The correct fix would be not to use a platform bus here, but until we
add something like the fauxbus, just opencode the platform device
creation without the address translation parts.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/partition.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index a0890bfcdef0..4be2a2c33716 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -112,11 +112,33 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
 	}
 
 	for_each_child_of_node(node, n) {
-		of_parse_partition(cdev, n);
+		struct cdev *partcdev;
+		struct device *dev;
+		int ret;
+
+		partcdev = of_parse_partition(cdev, n);
+		if (!partcdev || !subnode)
+			continue;
+
+		if (!of_property_present(n, "compatible") ||
+		    !of_device_is_available(n))
+			continue;
+
+		/* TODO: migrate to a faux bus? */
+		dev = xzalloc(sizeof(*dev));
+		dev->id = DEVICE_ID_SINGLE;
+		dev->of_node = n;
+		dev->parent = partcdev->dev;
+		n->dev = dev;
+		dev_set_name(dev, "%s", partcdev->name);
+
+		ret = platform_device_register(dev);
+		if (WARN_ON(ret)) {
+			n->dev = NULL;
+			free_device(dev);
+		}
 	}
 
-	if (subnode)
-		of_platform_populate(subnode, NULL, cdev->dev);
 	return 0;
 }
 
-- 
2.39.5




                 reply	other threads:[~2025-04-10 11:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250410095557.2248025-1-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