From: Boris Brezillon <boris.brezillon@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 6/6] cmd: adc: Use the sub-command infrastructure
Date: Mon, 3 Dec 2018 22:54:23 +0100 [thread overview]
Message-ID: <20181203215423.18772-7-boris.brezillon@bootlin.com> (raw)
In-Reply-To: <20181203215423.18772-1-boris.brezillon@bootlin.com>
And you get sub-command auto-completion for free.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in v4:
-None
Changes in v3:
- Add Tom's R-b
Changes in v2:
- New patch
---
cmd/adc.c | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/cmd/adc.c b/cmd/adc.c
index 2d635acbd950..381961cf51a4 100644
--- a/cmd/adc.c
+++ b/cmd/adc.c
@@ -146,37 +146,14 @@ static int do_adc_scan(cmd_tbl_t *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}
-static cmd_tbl_t cmd_adc_sub[] = {
- U_BOOT_CMD_MKENT(list, 1, 1, do_adc_list, "", ""),
- U_BOOT_CMD_MKENT(info, 2, 1, do_adc_info, "", ""),
- U_BOOT_CMD_MKENT(single, 3, 1, do_adc_single, "", ""),
- U_BOOT_CMD_MKENT(scan, 3, 1, do_adc_scan, "", ""),
-};
-
-static int do_adc(cmd_tbl_t *cmdtp, int flag, int argc,
- char *const argv[])
-{
- cmd_tbl_t *c;
-
- if (argc < 2)
- return CMD_RET_USAGE;
-
- /* Strip off leading 'adc' command argument */
- argc--;
- argv++;
-
- c = find_cmd_tbl(argv[0], &cmd_adc_sub[0], ARRAY_SIZE(cmd_adc_sub));
-
- if (c)
- return c->cmd(cmdtp, flag, argc, argv);
- else
- return CMD_RET_USAGE;
-}
-
static char adc_help_text[] =
"list - list ADC devices\n"
"adc info <name> - Get ADC device info\n"
"adc single <name> <channel> - Get Single data of ADC device channel\n"
"adc scan <name> [channel mask] - Scan all [or masked] ADC channels";
-U_BOOT_CMD(adc, 4, 1, do_adc, "ADC sub-system", adc_help_text);
+U_BOOT_CMD_WITH_SUBCMDS(adc, "ADC sub-system", adc_help_text,
+ U_BOOT_SUBCMD_MKENT(list, 1, 1, do_adc_list),
+ U_BOOT_SUBCMD_MKENT(info, 2, 1, do_adc_info),
+ U_BOOT_SUBCMD_MKENT(single, 3, 1, do_adc_single),
+ U_BOOT_SUBCMD_MKENT(scan, 3, 1, do_adc_scan));
--
2.17.1
next prev parent reply other threads:[~2018-12-03 21:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-03 21:54 [U-Boot] [PATCH v4 0/6] cmd: Simplify support for sub-commands Boris Brezillon
2018-12-03 21:54 ` [U-Boot] [PATCH v4 1/6] common: command: Fix command auto-completion Boris Brezillon
2018-12-11 1:04 ` Simon Glass
2018-12-11 11:24 ` Boris Brezillon
2018-12-11 20:37 ` Simon Glass
2019-01-16 2:39 ` [U-Boot] [U-Boot, v4, " Tom Rini
2018-12-03 21:54 ` [U-Boot] [PATCH v4 2/6] common: command: Expose a generic helper to auto-complete sub commands Boris Brezillon
2019-01-16 2:39 ` [U-Boot] [U-Boot, v4, " Tom Rini
2018-12-03 21:54 ` [U-Boot] [PATCH v4 3/6] common: command: Rework the 'cmd is repeatable' logic Boris Brezillon
2019-01-16 2:38 ` [U-Boot] [U-Boot, v4, " Tom Rini
2019-01-16 2:39 ` Tom Rini
2018-12-03 21:54 ` [U-Boot] [PATCH v4 4/6] command: commands: Add macros to declare commands with subcmds Boris Brezillon
2019-01-16 2:39 ` [U-Boot] [U-Boot, v4, " Tom Rini
2018-12-03 21:54 ` [U-Boot] [PATCH v4 5/6] cmd: mtd: Use the subcmd infrastructure to declare mtd sub-commands Boris Brezillon
2019-01-16 2:39 ` [U-Boot] [U-Boot, v4, " Tom Rini
2018-12-03 21:54 ` Boris Brezillon [this message]
2019-01-16 2:39 ` [U-Boot] [U-Boot, v4, 6/6] cmd: adc: Use the sub-command infrastructure Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181203215423.18772-7-boris.brezillon@bootlin.com \
--to=boris.brezillon@bootlin.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.