Commit fffa24d7c5998a5821c423ef07bdbc8c4d7bdcf1

Authored by Simon Glass
1 parent 5c33c9fdbb

dm: Move device display into its own function

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>

Showing 1 changed file with 19 additions and 8 deletions Side-by-side Diff

... ... @@ -16,6 +16,22 @@
16 16 #include <dm/test.h>
17 17 #include <dm/uclass-internal.h>
18 18  
  19 +/**
  20 + * dm_display_line() - Display information about a single device
  21 + *
  22 + * Displays a single line of information with an option prefix
  23 + *
  24 + * @dev: Device to display
  25 + * @buf: Prefix to display at the start of the line
  26 + */
  27 +static void dm_display_line(struct udevice *dev, char *buf)
  28 +{
  29 + printf("%s- %c %s @ %08lx", buf,
  30 + dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
  31 + dev->name, (ulong)map_to_sysmem(dev));
  32 + puts("\n");
  33 +}
  34 +
19 35 static int display_succ(struct udevice *in, char *buf)
20 36 {
21 37 int len;
... ... @@ -23,10 +39,7 @@
23 39 char local[16];
24 40 struct udevice *pos, *n, *prev = NULL;
25 41  
26   - printf("%s- %c %s @ %08lx", buf,
27   - in->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
28   - in->name, (ulong)map_to_sysmem(in));
29   - puts("\n");
  42 + dm_display_line(in, buf);
30 43  
31 44 if (list_empty(&in->child_head))
32 45 return 0;
... ... @@ -84,9 +97,7 @@
84 97 for (ret = uclass_first_device(id, &dev);
85 98 dev;
86 99 ret = uclass_next_device(&dev)) {
87   - printf(" %c %s @ %08lx:\n",
88   - dev->flags & DM_FLAG_ACTIVATED ? '*' : ' ',
89   - dev->name, (ulong)map_to_sysmem(dev));
  100 + dm_display_line(dev, "");
90 101 }
91 102 puts("\n");
92 103 }
... ... @@ -135,7 +146,7 @@
135 146 U_BOOT_CMD(
136 147 dm, 2, 1, do_dm,
137 148 "Driver model low level access",
138   - "tree Dump driver model tree\n"
  149 + "tree Dump driver model tree ('*' = activated)\n"
139 150 "dm uclass Dump list of instances for each uclass"
140 151 TEST_HELP
141 152 );