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] fixup! of: partition: do not try to translate offset as OF address
Date: Tue, 10 Jun 2025 14:19:10 +0200	[thread overview]
Message-ID: <20250610121910.1911393-1-a.fatoum@pengutronix.de> (raw)

base: resource: fix build with OF support disabled

With OF disabled, we end up with of_add_child_device defined twice.
Move the definition into of/platform.c to fix this. This is the better
place anyway, because it allocates a platform device.

For some reason, we compile of/platform.c even for CONFIG_OFDEVICE disabled,
but CONFIG_OFTREE enabled, so we need to tweak the #ifdef accordingly.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/base/resource.c | 25 -------------------------
 drivers/of/platform.c   | 26 ++++++++++++++++++++++++++
 include/driver.h        |  2 +-
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/drivers/base/resource.c b/drivers/base/resource.c
index d214df0def4c..cf163844b86e 100644
--- a/drivers/base/resource.c
+++ b/drivers/base/resource.c
@@ -75,31 +75,6 @@ struct device *add_child_device(struct device *parent,
 }
 EXPORT_SYMBOL(add_child_device);
 
-struct device *of_add_child_device(struct device *parent,
-		const char* devname, int id, struct device_node *np)
-{
-	struct device *dev;
-	int err;
-
-	if (!of_property_present(np, "compatible") || !of_device_is_available(np))
-		return NULL;
-
-	dev = device_alloc(devname, id);
-	dev->parent = parent;
-	dev->of_node = np;
-
-	np->dev = dev;
-	err = platform_device_register(dev);
-	if (err) {
-		np->dev = NULL;
-		free_device(dev);
-		return ERR_PTR(err);
-	}
-
-	return dev;
-}
-EXPORT_SYMBOL(of_add_child_device);
-
 struct device *add_generic_device_res(const char* devname, int id,
 		struct resource *res, int nb, void *pdata)
 {
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 7e086e9488e6..3600b5f9c10b 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -7,6 +7,7 @@
  * based on Linux devicetree support
  */
 #include <common.h>
+#include <driver.h>
 #include <deep-probe.h>
 #include <malloc.h>
 #include <of.h>
@@ -314,6 +315,31 @@ struct device *of_device_enable_and_register_by_alias(const char *alias)
 }
 EXPORT_SYMBOL(of_device_enable_and_register_by_alias);
 
+struct device *of_add_child_device(struct device *parent,
+		const char* devname, int id, struct device_node *np)
+{
+	struct device *dev;
+	int err;
+
+	if (!of_property_present(np, "compatible") || !of_device_is_available(np))
+		return NULL;
+
+	dev = device_alloc(devname, id);
+	dev->parent = parent;
+	dev->of_node = np;
+
+	np->dev = dev;
+	err = platform_device_register(dev);
+	if (err) {
+		np->dev = NULL;
+		free_device(dev);
+		return ERR_PTR(err);
+	}
+
+	return dev;
+}
+EXPORT_SYMBOL(of_add_child_device);
+
 #ifdef CONFIG_ARM_AMBA
 static struct device *of_amba_device_create(struct device_node *np)
 {
diff --git a/include/driver.h b/include/driver.h
index 31f63a0678d8..dd50a7aa3cce 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -227,7 +227,7 @@ struct device *add_child_device(struct device *parent,
 				resource_size_t start, resource_size_t size, unsigned int flags,
 				void *pdata);
 
-#ifdef CONFIG_OFDEVICE
+#ifdef CONFIG_OFTREE
 struct device *of_add_child_device(struct device *parent,
 		const char* devname, int id, struct device_node *np);
 #else
-- 
2.39.5




             reply	other threads:[~2025-06-10 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10 12:19 Ahmad Fatoum [this message]
2025-06-10 15:01 ` 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=20250610121910.1911393-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