diff mbox series

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

Message ID 1509958213-6547-1-git-send-email-wilson.lee@ni.com
State Changes Requested
Delegated to: Simon Glass
Headers show
Series [U-Boot] cmd: console: Add serial devices probe command | expand

Commit Message

Wilson Lee Nov. 6, 2017, 8:50 a.m. UTC
U-boot will only probe and register single serial device that selected
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.

Signed-off-by: Wilson Lee <wilson.lee@ni.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Keng Soon Cheah <keng.soon.cheah@ni.com>
Cc: Chen Yee Chew <chen.yee.chew@ni.com>
---
 cmd/console.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Simon Glass Jan. 18, 2018, 11:01 p.m. UTC | #1
Hi Wilson,

On 6 November 2017 at 00:50, Wilson Lee <wilson.lee@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@ni.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Keng Soon Cheah <keng.soon.cheah@ni.com>
> Cc: Chen Yee Chew <chen.yee.chew@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@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

Regards,
Simon
diff mbox series

Patch

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);
+	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;
+}
 
 /***************************************************/
 
@@ -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",
+	""
+);