dm: replace dm_dbg() with pr_debug()
As we discussed before in ML, dm_dbg() causes undefined reference
error if #define DEBUG is added to users, but not drivers/core/util.c
We do not need this macro because we can use pr_debug() instead, and
it is pretty easy to enable it for the DM core by using ccflags-y.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 7afef1f..e8ba20c 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -45,6 +45,12 @@
This will cause dm_warn() to be compiled out - it will do nothing
when called.
+config DM_DEBUG
+ bool "Enable debug messages in driver model core"
+ depends on DM
+ help
+ Say Y here if you want to compile in debug messages in DM core.
+
config DM_DEVICE_REMOVE
bool "Support device removal"
depends on DM
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 3d68c70..a5039c5 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -16,3 +16,5 @@
obj-$(CONFIG_OF_CONTROL) += read.o
endif
obj-$(CONFIG_OF_CONTROL) += of_extra.o ofnode.o read_extra.o
+
+ccflags-$(CONFIG_DM_DEBUG) += -DDEBUG
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 5463d1f..de63e53 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -161,7 +161,7 @@
}
if (parent)
- dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
+ pr_debug("Bound device %s to %s\n", dev->name, parent->name);
if (devp)
*devp = dev;
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 6067914..6fa5d10 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -139,12 +139,13 @@
if (devp)
*devp = NULL;
name = ofnode_get_name(node);
- dm_dbg("bind node %s\n", name);
+ pr_debug("bind node %s\n", name);
compat_list = ofnode_get_property(node, "compatible", &compat_length);
if (!compat_list) {
if (compat_length == -FDT_ERR_NOTFOUND) {
- dm_dbg("Device '%s' has no compatible string\n", name);
+ pr_debug("Device '%s' has no compatible string\n",
+ name);
return 0;
}
@@ -159,8 +160,8 @@
*/
for (i = 0; i < compat_length; i += strlen(compat) + 1) {
compat = compat_list + i;
- dm_dbg(" - attempt to match compatible string '%s'\n",
- compat);
+ pr_debug(" - attempt to match compatible string '%s'\n",
+ compat);
for (entry = driver; entry != driver + n_ents; entry++) {
ret = driver_check_compatible(entry->of_match, &id,
@@ -171,11 +172,11 @@
if (entry == driver + n_ents)
continue;
- dm_dbg(" - found match at '%s'\n", entry->name);
+ pr_debug(" - found match at '%s'\n", entry->name);
ret = device_bind_with_driver_data(parent, entry, name,
id->data, node, &dev);
if (ret == -ENODEV) {
- dm_dbg("Driver '%s' refuses to bind\n", entry->name);
+ pr_debug("Driver '%s' refuses to bind\n", entry->name);
continue;
}
if (ret) {
@@ -191,7 +192,7 @@
}
if (!found && !result && ret != -ENODEV)
- dm_dbg("No match for node '%s'\n", name);
+ pr_debug("No match for node '%s'\n", name);
return result;
}
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 757d109..976e2c4 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -227,7 +227,7 @@
!of_find_property(np, "u-boot,dm-pre-reloc", NULL))
continue;
if (!of_device_is_available(np)) {
- dm_dbg(" - ignoring disabled device\n");
+ pr_debug(" - ignoring disabled device\n");
continue;
}
err = lists_bind_fdt(parent, np_to_ofnode(np), NULL);
@@ -270,7 +270,7 @@
!dm_fdt_pre_reloc(blob, offset))
continue;
if (!fdtdec_get_is_enabled(blob, offset)) {
- dm_dbg(" - ignoring disabled device\n");
+ pr_debug(" - ignoring disabled device\n");
continue;
}
err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL);
diff --git a/drivers/core/util.c b/drivers/core/util.c
index 2e232d5..aaaed4e 100644
--- a/drivers/core/util.c
+++ b/drivers/core/util.c
@@ -20,17 +20,6 @@
}
#endif
-#ifdef DEBUG
-void dm_dbg(const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- vprintf(fmt, args);
- va_end(args);
-}
-#endif
-
int list_count_items(struct list_head *head)
{
struct list_head *node;