[PATCH] fixup! of: partition: do not try to translate offset as OF address
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Jun 10 05:19:10 PDT 2025
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 at 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
More information about the barebox
mailing list