diff mbox

[U-Boot,v2,15/29] dm: Move device display into its own function

Message ID 1404877099-7314-16-git-send-email-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass July 9, 2014, 3:38 a.m. UTC
The device display for 'dm tree' and 'dm uclass' is mostly the same, so
move it into a common function.

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

Changes in v2: None

 test/dm/cmd_dm.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

Comments

Marek Vasut July 10, 2014, 11:33 p.m. UTC | #1
On Wednesday, July 09, 2014 at 05:38:05 AM, Simon Glass wrote:
> The device display for 'dm tree' and 'dm uclass' is mostly the same, so
> move it into a common function.

Is this going to become a dev_{info/warn/err/crit/...}() kind of output function 
eventually ?

Best regards,
Marek Vasut
Simon Glass July 11, 2014, 4:27 a.m. UTC | #2
Hi Marek,

On 10 July 2014 17:33, Marek Vasut <marex@denx.de> wrote:
> On Wednesday, July 09, 2014 at 05:38:05 AM, Simon Glass wrote:
>> The device display for 'dm tree' and 'dm uclass' is mostly the same, so
>> move it into a common function.
>
> Is this going to become a dev_{info/warn/err/crit/...}() kind of output function
> eventually ?

dm_display_line() is just for the 'dm' command - we can certainly add
those functions for devices to use. I haven't really got that far yet.

Regards,
Simon
diff mbox

Patch

diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c
index 96f10f3..9b77a7f 100644
--- a/test/dm/cmd_dm.c
+++ b/test/dm/cmd_dm.c
@@ -16,6 +16,22 @@ 
 #include <dm/test.h>
 #include <dm/uclass-internal.h>
 
+/**
+ * dm_display_line() - Display information about a single device
+ *
+ * Displays a single line of information with an option prefix
+ *
+ * @dev:	Device to display
+ * @buf:	Prefix to display at the start of the line
+ */
+static void dm_display_line(struct udevice *dev, char *buf)
+{
+	printf("%s- %c %s @ %08lx", buf,
+	       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
+	       dev->name, (ulong)map_to_sysmem(dev));
+	puts("\n");
+}
+
 static int display_succ(struct udevice *in, char *buf)
 {
 	int len;
@@ -23,10 +39,7 @@  static int display_succ(struct udevice *in, char *buf)
 	char local[16];
 	struct udevice *pos, *n, *prev = NULL;
 
-	printf("%s- %c %s @ %08lx", buf,
-	       in->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
-	       in->name, (ulong)map_to_sysmem(in));
-	puts("\n");
+	dm_display_line(in, buf);
 
 	if (list_empty(&in->child_head))
 		return 0;
@@ -84,9 +97,7 @@  static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
 		for (ret = uclass_first_device(id, &dev);
 		     dev;
 		     ret = uclass_next_device(&dev)) {
-			printf("  %c %s @ %08lx:\n",
-			       dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
-			       dev->name, (ulong)map_to_sysmem(dev));
+			dm_display_line(dev, "");
 		}
 		puts("\n");
 	}
@@ -135,7 +146,7 @@  static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 U_BOOT_CMD(
 	dm,	2,	1,	do_dm,
 	"Driver model low level access",
-	"tree         Dump driver model tree\n"
+	"tree         Dump driver model tree ('*' = activated)\n"
 	"dm uclass        Dump list of instances for each uclass"
 	TEST_HELP
 );