From 5b166f1690fa11a9d1344ade9cf6e24361b59a03 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineeringinc.com>
Date: Mon, 18 Apr 2016 16:40:35 +0000
Subject: [PATCH 02/15] drivers/core: Add helpful debugging statements

Signed-off-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
---
 drivers/core/device.c |  6 ++++++
 drivers/core/dump.c   |  2 +-
 drivers/core/root.c   | 28 +++++++++++++++++++++++++++-
 drivers/core/uclass.c |  6 ++++++
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index cb24a61..ce03a72 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -24,6 +24,8 @@
 #include <linux/err.h>
 #include <linux/list.h>
 
+// #define EXTRA_DEBUG
+
 DECLARE_GLOBAL_DATA_PTR;
 
 int device_bind(struct udevice *parent, const struct driver *drv,
@@ -230,6 +232,10 @@ int device_probe(struct udevice *dev)
 	int ret;
 	int seq;
 
+#ifdef EXTRA_DEBUG
+	debug("%s %p\n", __func__, dev);
+#endif
+
 	if (!dev)
 		return -EINVAL;
 
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index fd4596e..f25cf41 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -17,7 +17,7 @@ static void show_devices(struct udevice *dev, int depth, int last_flag)
 
 	/* print the first 11 characters to not break the tree-format. */
 	strlcpy(class_name, dev->uclass->uc_drv->name, sizeof(class_name));
-	printf(" %-11s [ %c ]    ", class_name,
+	printf(" %s [ %c ]    ", class_name,
 	       dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ');
 
 	for (i = depth; i >= 0; i--) {
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 13c2713..b9b9b44 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -21,6 +21,8 @@
 #include <dm/util.h>
 #include <linux/list.h>
 
+// #define EXTRA_DEBUG
+
 DECLARE_GLOBAL_DATA_PTR;
 
 struct root_priv {
@@ -128,6 +130,10 @@ int dm_init(void)
 {
 	int ret;
 
+#ifdef EXTRA_DEBUG
+	debug("%s\n", __func__);
+#endif
+
 	if (gd->dm_root) {
 		dm_warn("Virtual root driver already exists!\n");
 		return -EINVAL;
@@ -164,6 +170,10 @@ int dm_scan_platdata(bool pre_reloc_only)
 {
 	int ret;
 
+#ifdef EXTRA_DEBUG
+	debug("%s\n", __func__);
+#endif
+
 	ret = lists_bind_drivers(DM_ROOT_NON_CONST, pre_reloc_only);
 	if (ret == -ENOENT) {
 		dm_warn("Some drivers were not found\n");
@@ -179,12 +189,22 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
 {
 	int ret = 0, err;
 
+#ifdef EXTRA_DEBUG
+	debug("%s offset: %d pre_reloc_only: %d\n", __func__, offset, pre_reloc_only);
+#endif
+
 	for (offset = fdt_first_subnode(blob, offset);
 	     offset > 0;
 	     offset = fdt_next_subnode(blob, offset)) {
+#ifdef EXTRA_DEBUG
+		debug("offset: %d u-boot,dm-pre-reloc: %d\n", offset, fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL));
+#endif
 		if (pre_reloc_only &&
 		    !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
 			continue;
+#ifdef EXTRA_DEBUG
+		debug("offset: %d enabled: %d\n", offset, fdtdec_get_is_enabled(blob, offset));
+#endif
 		if (!fdtdec_get_is_enabled(blob, offset)) {
 			dm_dbg("   - ignoring disabled device\n");
 			continue;
@@ -218,6 +238,10 @@ int dm_init_and_scan(bool pre_reloc_only)
 {
 	int ret;
 
+#ifdef EXTRA_DEBUG
+	debug("%s\n", __func__);
+#endif
+
 	ret = dm_init();
 	if (ret) {
 		debug("dm_init() failed: %d\n", ret);
@@ -238,8 +262,10 @@ int dm_init_and_scan(bool pre_reloc_only)
 	}
 
 	ret = dm_scan_other(pre_reloc_only);
-	if (ret)
+	if (ret) {
+		debug("dm_scan_other() failed: %d\n", ret);
 		return ret;
+	}
 
 	return 0;
 }
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 12095e7..c49006b 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -17,6 +17,8 @@
 #include <dm/uclass-internal.h>
 #include <dm/util.h>
 
+// #define EXTRA_DEBUG
+
 DECLARE_GLOBAL_DATA_PTR;
 
 struct uclass *uclass_find(enum uclass_id key)
@@ -314,6 +316,10 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
 int uclass_get_device_tail(struct udevice *dev, int ret,
 				  struct udevice **devp)
 {
+#ifdef EXTRA_DEBUG
+	debug("%s %p %d\n", __func__, dev, ret);
+#endif
+
 	if (ret)
 		return ret;
 
-- 
1.9.1

