[PATCH 4/4] dm: dummy implementations of live-tree functions
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Wed Dec 31 20:10:54 CET 2025
We have opted to prefer 'if' over '#if' to more easily see problems in
contributed code.
When compiling with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y the compiler does not
execute all optimization paths and references live-tree functions
even if CONFIG_$(PHASE_)OF_LIVE is not defined.
E.g. building qemu-riscv64_smode_defconfig with
CONFIG_CC_OPTIMIZE_FOR_DEBUG=y fails due to missing symbols.
Provide dummy implementation to allow debug builds.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
drivers/core/Makefile | 6 +-
drivers/core/nof_access.c | 246 ++++++++++++++++++++++++++++++++++++++
drivers/core/nof_addr.c | 37 ++++++
3 files changed, 288 insertions(+), 1 deletion(-)
create mode 100644 drivers/core/nof_access.c
create mode 100644 drivers/core/nof_addr.c
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index a549890c22b..caa912f48ab 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -11,7 +11,11 @@ obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o
obj-$(CONFIG_DM) += dump.o
obj-$(CONFIG_$(PHASE_)REGMAP) += regmap.o
obj-$(CONFIG_$(PHASE_)SYSCON) += syscon-uclass.o
-obj-$(CONFIG_$(PHASE_)OF_LIVE) += of_access.o of_addr.o
+ifdef CONFIG_$(PHASE_)OF_LIVE
+obj-y += of_access.o of_addr.o
+else
+obj-y += nof_access.o nof_addr.o
+endif
ifndef CONFIG_DM_DEV_READ_INLINE
obj-$(CONFIG_OF_CONTROL) += read.o
endif
diff --git a/drivers/core/nof_access.c b/drivers/core/nof_access.c
new file mode 100644
index 00000000000..08adba247f7
--- /dev/null
+++ b/drivers/core/nof_access.c
@@ -0,0 +1,246 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * This file contains dummy function implementations that are only needed
+ * when compiling with -Og. In this case the optimizer does not remove
+ * function calls based on CONFIG_$(PHASE_)OF_LIVE.
+ */
+
+#include <dm/of_access.h>
+#include <linux/errno.h>
+
+int of_n_addr_cells(const struct device_node *np)
+{
+ return -ENOSYS;
+}
+
+int of_n_size_cells(const struct device_node *np)
+{
+ return -ENOSYS;
+}
+
+int of_simple_addr_cells(const struct device_node *np)
+{
+ return -ENOSYS;
+}
+
+int of_simple_size_cells(const struct device_node *np)
+{
+ return -ENOSYS;
+}
+
+struct property *of_find_property(const struct device_node *np,
+ const char *name, int *lenp)
+{
+ return NULL;
+}
+
+struct device_node *of_find_all_nodes(struct device_node *prev)
+{
+ return NULL;
+}
+
+const void *of_get_property(const struct device_node *np, const char *name,
+ int *lenp)
+{
+ return NULL;
+}
+
+const struct property *of_get_first_property(const struct device_node *np)
+{
+ return NULL;
+}
+
+const struct property *of_get_next_property(const struct device_node *np,
+ const struct property *property)
+{
+ return NULL;
+}
+
+const void *of_get_property_by_prop(const struct device_node *np,
+ const struct property *property,
+ const char **name,
+ int *lenp)
+{
+ return NULL;
+}
+
+int of_device_is_compatible(const struct device_node *device,
+ const char *compat, const char *type,
+ const char *name)
+{
+ return -ENOSYS;
+}
+
+bool of_device_is_available(const struct device_node *device)
+{
+ return false;
+}
+
+struct device_node *of_get_parent(const struct device_node *node)
+{
+ return NULL;
+}
+
+struct device_node *of_find_node_opts_by_path(struct device_node *root,
+ const char *path,
+ const char **opts)
+{
+ return NULL;
+}
+
+struct device_node *of_find_compatible_node(struct device_node *from,
+ const char *type, const char *compatible)
+{
+ return NULL;
+}
+
+struct device_node *of_find_node_by_prop_value(struct device_node *from,
+ const char *propname,
+ const void *propval, int proplen)
+{
+ return NULL;
+}
+
+struct device_node *of_find_node_by_phandle(struct device_node *root,
+ phandle handle)
+{
+ return NULL;
+}
+
+int of_read_u8(const struct device_node *np, const char *propname, u8 *outp)
+{
+ return -ENOSYS;
+}
+
+int of_read_u16(const struct device_node *np, const char *propname, u16 *outp)
+{
+ return -ENOSYS;
+}
+
+int of_read_u32(const struct device_node *np, const char *propname, u32 *outp)
+{
+ return -ENOSYS;
+}
+
+int of_read_u32_array(const struct device_node *np, const char *propname,
+ u32 *out_values, size_t sz)
+{
+ return -ENOSYS;
+}
+
+int of_read_u32_index(const struct device_node *np, const char *propname,
+ int index, u32 *outp)
+{
+ return -ENOSYS;
+}
+
+int of_read_u64_index(const struct device_node *np, const char *propname,
+ int index, u64 *outp)
+{
+ return -ENOSYS;
+}
+
+int of_read_u64(const struct device_node *np, const char *propname, u64 *outp)
+{
+ return -ENOSYS;
+}
+
+int of_property_match_string(const struct device_node *np, const char *propname,
+ const char *string)
+{
+ return -ENOSYS;
+}
+
+int of_property_read_string_helper(const struct device_node *np,
+ const char *propname, const char **out_strs,
+ size_t sz, int skip)
+{
+ return -ENOSYS;
+}
+
+struct device_node *of_root_parse_phandle(struct device_node *root,
+ const struct device_node *np,
+ const char *phandle_name, int index)
+{
+ return NULL;
+}
+
+int of_root_parse_phandle_with_args(struct device_node *root,
+ const struct device_node *np,
+ const char *list_name, const char *cells_name,
+ int cell_count, int index,
+ struct of_phandle_args *out_args)
+{
+ return -ENOSYS;
+}
+
+int of_root_count_phandle_with_args(struct device_node *root,
+ const struct device_node *np,
+ const char *list_name, const char *cells_name,
+ int cell_count)
+{
+ return -ENOSYS;
+}
+
+struct device_node *of_parse_phandle(const struct device_node *np,
+ const char *phandle_name, int index)
+{
+ return NULL;
+}
+
+int of_parse_phandle_with_args(const struct device_node *np,
+ const char *list_name, const char *cells_name,
+ int cell_count, int index,
+ struct of_phandle_args *out_args)
+{
+ return -ENOSYS;
+}
+
+int of_count_phandle_with_args(const struct device_node *np,
+ const char *list_name, const char *cells_name,
+ int cell_count)
+{
+ return -ENOSYS;
+}
+
+int of_alias_scan(void)
+{
+ return -ENOSYS;
+}
+
+int of_alias_get_id(const struct device_node *np, const char *stem)
+{
+ return -ENOSYS;
+}
+
+int of_alias_get_highest_id(const char *stem)
+{
+ return -ENOSYS;
+}
+
+struct device_node *of_get_stdout(void)
+{
+ return NULL;
+}
+
+int of_write_prop(struct device_node *np, const char *propname, int len,
+ const void *value)
+{
+ return -ENOSYS;
+}
+
+int of_add_subnode(struct device_node *parent, const char *name, int len,
+ struct device_node **childp)
+{
+ return -ENOSYS;
+}
+
+int of_remove_property(struct device_node *np, struct property *prop)
+{
+ return -ENOSYS;
+}
+
+int of_remove_node(struct device_node *to_remove)
+{
+ return -ENOSYS;
+}
diff --git a/drivers/core/nof_addr.c b/drivers/core/nof_addr.c
new file mode 100644
index 00000000000..8f619f9ec33
--- /dev/null
+++ b/drivers/core/nof_addr.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * This file contains dummy function implementations that are only needed
+ * when compiling with -Og. In this case the optimizer does not remove
+ * function calls based on CONFIG_$(PHASE_)OF_LIVE.
+ */
+
+#include <dm/of_addr.h>
+#include <linux/errno.h>
+
+const __be32 *of_get_address(const struct device_node *dev, int index,
+ u64 *size, unsigned int *flags)
+{
+ return NULL;
+}
+
+u64 of_translate_address(const struct device_node *dev, const __be32 *in_addr)
+{
+ return -ENOSYS;
+}
+
+u64 of_translate_dma_address(const struct device_node *dev, const __be32 *in_addr)
+{
+ return -ENOSYS;
+}
+
+int of_get_dma_range(const struct device_node *dev, phys_addr_t *cpu,
+ dma_addr_t *bus, u64 *size)
+{
+ return -ENOSYS;
+}
+
+int of_address_to_resource(const struct device_node *dev, int index,
+ struct resource *r)
+{
+ return -ENOSYS;
+}
--
2.51.0
More information about the U-Boot
mailing list