* [PATCH] fixup! of: partition: do not try to translate offset as OF address
@ 2025-06-10 12:19 Ahmad Fatoum
2025-06-10 15:01 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-06-10 12:19 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fixup! of: partition: do not try to translate offset as OF address
2025-06-10 12:19 [PATCH] fixup! of: partition: do not try to translate offset as OF address Ahmad Fatoum
@ 2025-06-10 15:01 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-06-10 15:01 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Tue, 10 Jun 2025 14:19:10 +0200, Ahmad Fatoum wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] fixup! of: partition: do not try to translate offset as OF address
https://git.pengutronix.de/cgit/barebox/commit/?id=109c81f143b4 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-10 17:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-10 12:19 [PATCH] fixup! of: partition: do not try to translate offset as OF address Ahmad Fatoum
2025-06-10 15:01 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox