[U-Boot] [PATCH] cmd: console: Add serial devices probe command

Simon Glass sjg at chromium.org
Thu Jan 18 23:01:02 UTC 2018


Hi Wilson,

On 6 November 2017 at 00:50, Wilson Lee <wilson.lee at ni.com> wrote:
> U-boot will only probe and register single serial device that selected

U-Boot

> to be used as stdio device. This will cause changing of stdio devices
> from one serial devices to another serial devices is not possible due
> to others serial devices are not registered on the stdio list. This
> command will allow user to probe others possible serial console and
> register them to stdio list for stdio switching.

The wording of this seems confusing to me. How about this as a suggestion:

U-Boot only probes a single serial device to be used as a stdio
device. This means that changing from one serial device to another is
not possible.

Add a command to ...

Anyway, please see below

>
> Signed-off-by: Wilson Lee <wilson.lee at ni.com>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Keng Soon Cheah <keng.soon.cheah at ni.com>
> Cc: Chen Yee Chew <chen.yee.chew at ni.com>
> ---
>  cmd/console.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/cmd/console.c b/cmd/console.c
> index 9a356ec..5bf897f 100644
> --- a/cmd/console.c
> +++ b/cmd/console.c
> @@ -8,6 +8,7 @@
>  /*
>   * Boot support
>   */
> +#include <dm.h>
>  #include <common.h>
>  #include <command.h>
>  #include <stdio_dev.h>
> @@ -43,6 +44,22 @@ static int do_coninfo(cmd_tbl_t *cmd, int flag, int argc, char * const argv[])
>         return 0;
>  }
>
> +static int do_conprobe(cmd_tbl_t *cmd, int flag, int argc, char * const argv[])
> +{
> +       struct udevice *dev;
> +       struct uclass *uc;
> +
> +       uclass_get(UCLASS_SERIAL, &uc);

This needs error checking.

> +       uclass_foreach_dev(dev, uc) {
> +               /*
> +                * Loop through all serial devices, probe and register
> +                * them with stdio services.
> +                */
> +               if (device_probe(dev))
> +                       debug("%s: %s: PROBE FAIL\n", __func__, dev->name);
> +       }
> +       return 0;
> +}

Do you think it would be safe to add this code in serial_stdio_init()
instead? We do this for UCLASS_VIDEO and UCLASS_KEYBOARD. See
stdio_add_devices() for this logic.

Then we would not need this command.

>
>  /***************************************************/
>
> @@ -51,3 +68,9 @@ U_BOOT_CMD(
>         "print console devices and information",
>         ""
>  );
> +
> +U_BOOT_CMD(
> +       conprobe,       3,      1,      do_conprobe,
> +       "probe serial devices and register with stdio list",
> +       ""
> +);
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

Regards,
Simon


More information about the U-Boot mailing list