[U-Boot] [PATCH] dm: core: Show driver name with 'dm tree'

Bin Meng bmeng.cn at gmail.com
Sun Jul 23 03:59:50 UTC 2017


Hi Simon,

On Sun, Jul 16, 2017 at 7:40 AM, Simon Glass <sjg at chromium.org> wrote:
> It is often useful to see which driver was actually selected for each
> device. Add a new 'Driver' column to provide this information. Sample
> output:
>
>  Class       Probed   Driver     Name
> ----------------------------------------
>  root        [ + ]    root_drive root_driver
>  keyboard    [ + ]    i8042_kbd  |-- keyboard
>  serial      [ + ]    ns16550_se |-- serial
>  rtc         [   ]    rtc_mc1468 |-- rtc
>  timer       [ + ]    tsc_timer  |-- tsc-timer
>  syscon      [ + ]    ich6_pinct |-- pch_pinctrl
>  pci         [ + ]    pci_x86    |-- pci
>  northbridge [ + ]    bd82x6x_no |   |-- northbridge at 0,0
>  video       [ + ]    bd82x6x_vi |   |-- gma at 2,0
>  vidconsole0 [ + ]    vidconsole |   |   `-- gma at 2,0.vidconsole0
> ...
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  drivers/core/dump.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
Tested-by: Bin Meng <bmeng.cn at gmail.com>

But please see comments below:

> diff --git a/drivers/core/dump.c b/drivers/core/dump.c
> index c3e109e7ed..98e2b3cd23 100644
> --- a/drivers/core/dump.c
> +++ b/drivers/core/dump.c
> @@ -18,8 +18,8 @@ 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,
> -              dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ');
> +       printf(" %-11s [ %c ]    %-10.10s ", class_name,

How about using the same %-10.10s for the class_name as well? This
eliminates the need of strlcpy() above, and keeps consistent with the
driver name length we are adding.

> +              dev->flags & DM_FLAG_ACTIVATED ? '+' : ' ', dev->driver->name);
>
>         for (i = depth; i >= 0; i--) {
>                 is_last = (last_flag >> i) & 1;
> @@ -50,7 +50,7 @@ void dm_dump_all(void)
>
>         root = dm_root();
>         if (root) {
> -               printf(" Class       Probed   Name\n");
> +               printf(" Class       Probed   Driver     Name\n");

Can we just leave one space between "Probed" and "Driver"?

>                 printf("----------------------------------------\n");
>                 show_devices(root, -1, 0);
>         }
> --

Regards,
Bin


More information about the U-Boot mailing list