[U-Boot] [PATCH 6/6] cmd: led: add command led list
techping.chan at gmail.com
techping.chan at gmail.com
Mon Mar 27 14:38:43 UTC 2017
From: Ziping Chen <techping.chan at gmail.com>
Add command "led list" to list all led(s) can be operated.
Signed-off-by: Ziping Chen <techping.chan at gmail.com>
---
cmd/led.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/cmd/led.c b/cmd/led.c
index 3849a79..3f70666 100644
--- a/cmd/led.c
+++ b/cmd/led.c
@@ -230,6 +230,30 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
if (error_count != 0)
return CMD_RET_FAILURE;
+ } else if (strcmp("list", argv[1]) == 0) {
+ int node, len;
+ match = 1;
+ node = fdt_path_offset(gd->fdt_blob, "/leds");
+ if (node < 0) {
+ printf("led: null led found\n");
+ return CMD_RET_FAILURE;
+ }
+ node = fdt_first_subnode(gd->fdt_blob, node);
+ if (node < 0) {
+ printf("led: null led found\n");
+ return CMD_RET_FAILURE;
+ }
+ printf(" led_name\n");
+ printf("----------------------------------------\n");
+ printf(" %s\n", fdt_getprop(gd->fdt_blob, node,
+ "label", &len));
+ while (1) {
+ node = fdt_next_subnode(gd->fdt_blob, node);
+ if (node < 0)
+ break;
+ printf(" %s\n", fdt_getprop(gd->fdt_blob, node,
+ "label", &len));
+ }
} else if (argc > 2) {
match = 1;
if (dm_led_set(argv[1], cmd) < 0)
@@ -287,6 +311,7 @@ U_BOOT_CMD(
U_BOOT_CMD(
led, 4, 1, do_led,
"operate led(s)",
- "[all|led_name] [on|off|toggle] - sets or clears led(s)"
+ "[all|led_name] [on|off|toggle] - sets or clears led(s)\n"
+ "led list - list all led(s) can be operated"
);
#endif
--
2.7.4
More information about the U-Boot
mailing list