From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/7] command.c: Expose the core of do_help as _do_help to the rest of u-boot.
Date: Wed, 25 Mar 2009 17:27:52 +0100 [thread overview]
Message-ID: <1237998478-18452-2-git-send-email-dzu@denx.de> (raw)
In-Reply-To: <1237998478-18452-1-git-send-email-dzu@denx.de>
Other commands implementing subcommands can reuse this code nicely.
Signed-off-by: Detlev Zundel <dzu@denx.de>
Signed-off-by: Andreas Pfefferle <ap@denx.de>
---
common/command.c | 20 +++++++++++++-------
include/command.h | 4 +++-
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/common/command.c b/common/command.c
index 3b9ccc9..c9a3f5b 100644
--- a/common/command.c
+++ b/common/command.c
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2000-2003
+ * (C) Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering, wd at denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -233,20 +233,19 @@ U_BOOT_CMD(
* Use puts() instead of printf() to avoid printf buffer overflow
* for long help messages
*/
-int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+
+int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
+ flag, int argc, char *argv[])
{
int i;
int rcode = 0;
if (argc == 1) { /*show list of commands */
-
- int cmd_items = &__u_boot_cmd_end -
- &__u_boot_cmd_start; /* pointer arith! */
cmd_tbl_t *cmd_array[cmd_items];
int i, j, swaps;
/* Make array of commands from .uboot_cmd section */
- cmdtp = &__u_boot_cmd_start;
+ cmdtp = cmd_start;
for (i = 0; i < cmd_items; i++) {
cmd_array[i] = cmdtp++;
}
@@ -286,7 +285,7 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
* command help (long version)
*/
for (i = 1; i < argc; ++i) {
- if ((cmdtp = find_cmd (argv[i])) != NULL) {
+ if ((cmdtp = find_cmd_tbl (argv[i], cmd_start, cmd_items )) != NULL) {
#ifdef CONFIG_SYS_LONGHELP
/* found - print (long) help info */
puts (cmdtp->name);
@@ -313,6 +312,13 @@ int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
return rcode;
}
+int do_help (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+ return _do_help(&__u_boot_cmd_start,
+ &__u_boot_cmd_end - &__u_boot_cmd_start,
+ cmdtp, flag, argc, argv);
+}
+
U_BOOT_CMD(
help, CONFIG_SYS_MAXARGS, 1, do_help,
diff --git a/include/command.h b/include/command.h
index d7321af..bd47853 100644
--- a/include/command.h
+++ b/include/command.h
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2000
+ * (C) Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering, wd at denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -66,6 +66,8 @@ extern cmd_tbl_t __u_boot_cmd_end;
/* common/command.c */
+int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
+ flag, int argc, char *argv[]);
cmd_tbl_t *find_cmd(const char *cmd);
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);
--
1.6.0.6
next prev parent reply other threads:[~2009-03-25 16:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 16:27 [U-Boot] [PATCH v2 0/7] Update for inka4x0 plus some new features Detlev Zundel
2009-03-25 16:27 ` Detlev Zundel [this message]
2009-03-25 16:27 ` [U-Boot] [PATCH v2 2/7] mpc5xxx: Add structure definition for several more register blocks Detlev Zundel
2009-03-25 16:27 ` [U-Boot] [PATCH v2 3/7] drivers/twserial: Add protocol driver for "three wire serial" interface Detlev Zundel
2009-03-25 16:27 ` [U-Boot] [PATCH v2 4/7] rtc: add support for 4543 RTC (manufactured by e.g. EPSON) Detlev Zundel
2009-03-25 16:27 ` [U-Boot] [PATCH v2 5/7] inka4x0: Add hardware diagnosis functions for inka4x0 Detlev Zundel
2009-03-25 16:27 ` [U-Boot] [PATCH v2 6/7] inka4x0: Add hardware diagnosis and RTC in configuration Detlev Zundel
2009-03-25 16:27 ` [U-Boot] [PATCH v2 7/7] inka4x0: Use proper accessor macros for memory mapped registers Detlev Zundel
2009-03-27 10:33 ` [U-Boot] [PATCH v2 4/7] rtc: add support for 4543 RTC (manufactured by e.g. EPSON) Anatolij Gustschin
2009-03-27 10:51 ` Wolfgang Denk
2009-03-27 11:13 ` Detlev Zundel
2009-03-27 12:43 ` Anatolij Gustschin
2009-03-27 12:53 ` Jerry Van Baren
2009-03-27 13:00 ` Detlev Zundel
2009-03-27 16:06 ` Scott Wood
2009-03-25 19:19 ` [U-Boot] [PATCH v2 3/7] drivers/twserial: Add protocol driver for "three wire serial" interface Wolfgang Denk
2009-03-26 9:33 ` Detlev Zundel
2009-03-26 15:23 ` Detlev Zundel
2009-03-27 20:08 ` Wolfgang Denk
2009-03-27 10:02 ` Anatolij Gustschin
2009-03-27 10:33 ` Detlev Zundel
2009-03-27 20:06 ` [U-Boot] [PATCH v2 1/7] command.c: Expose the core of do_help as _do_help to the rest of u-boot Wolfgang Denk
2009-03-25 16:36 ` [U-Boot] [PATCH v2 0/7] Update for inka4x0 plus some new features Detlev Zundel
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=1237998478-18452-2-git-send-email-dzu@denx.de \
--to=dzu@denx.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox