[PATCH 15/19] dm: devres: Convert to use logging

Simon Glass sjg at chromium.org
Mon Dec 30 05:19:24 CET 2019


At present when CONFIG_DEBUG_DEVRES is enabled, U-Boot prints log messages
to the console with every devres allocation/free event. This causes most
tests to fail since the console output is not as expected.

In particular this prevents us from adding a device to sandbox which uses
devres in its bind method.

Move devres over to use U-Boot's logging feature instead, and add a new
category for devres.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/core/devres.c | 6 ++++--
 include/log.h         | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index a3f915dd73..9c04499c6d 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -7,6 +7,8 @@
  * Copyright (c) 2006  Tejun Heo <teheo at suse.de>
  */
 
+#define LOG_CATEGORY LOGC_DEVRES
+
 #include <common.h>
 #include <linux/compat.h>
 #include <linux/kernel.h>
@@ -46,8 +48,8 @@ static void set_node_dbginfo(struct devres *dr, const char *name, size_t size)
 static void devres_log(struct udevice *dev, struct devres *dr,
 		       const char *op)
 {
-	printf("%s: DEVRES %3s %p %s (%lu bytes)\n",
-	       dev->name, op, dr, dr->name, (unsigned long)dr->size);
+	log_debug("%s: DEVRES %3s %p %s (%lu bytes)\n", dev->name, op, dr,
+		  dr->name, (unsigned long)dr->size);
 }
 #else /* CONFIG_DEBUG_DEVRES */
 #define set_node_dbginfo(dr, n, s)	do {} while (0)
diff --git a/include/log.h b/include/log.h
index c6f2f023b1..64b787d0ba 100644
--- a/include/log.h
+++ b/include/log.h
@@ -49,6 +49,7 @@ enum log_category_t {
 	LOGC_ALLOC,	/* Memory allocation */
 	LOGC_SANDBOX,	/* Related to the sandbox board */
 	LOGC_BLOBLIST,	/* Bloblist */
+	LOGC_DEVRES,	/* Device resources (devres_... functions) */
 
 	LOGC_COUNT,	/* Number of log categories */
 	LOGC_END,	/* Sentinel value for a list of log categories */
-- 
2.24.1.735.g03f4e72817-goog



More information about the U-Boot mailing list