summaryrefslogtreecommitdiff
path: root/common/host_command.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-03-29 12:40:07 -0700
committerChromeBot <chrome-bot@google.com>2013-03-29 15:39:34 -0700
commit97bf36c9d3ad3d96ad6dea7cd6e6f3e164297c43 (patch)
tree5d4ba65334beb071e4cc09d8a404e859bca398ac /common/host_command.c
parentc317992194ea089a97c4d54ef77ff4b1e283c248 (diff)
downloadchrome-ec-97bf36c9d3ad3d96ad6dea7cd6e6f3e164297c43.tar.gz
Add parse_bool() to centralize parsing boolean options
This way debug commands which previously took only yes/no or on/off or enable/disable can take any of those options. BUG=chrome-os-partner:18467 BRANCH=none TEST=Try "on", "off", "yes", "no", "true", "false", "ena", "disable", for each of the following commands: - ilim (spring) - pll (link) - power (spring/snow) - hcdebug (all) - kblog (link) - ksscan (all) - lp5562 (spring) Change-Id: Ie8e0fae3775b1da711864bcba6682ba5e68a06f1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46900 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r--common/host_command.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/common/host_command.c b/common/host_command.c
index 7dd0a2a90c..264c3dca8e 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -447,14 +447,8 @@ DECLARE_CONSOLE_COMMAND(hostcmd, command_host_command,
static int command_hcdebug(int argc, char **argv)
{
- if (argc > 1) {
- if (!strcasecmp(argv[1], "on"))
- hcdebug = 1;
- else if (!strcasecmp(argv[1], "off"))
- hcdebug = 0;
- else
- return EC_ERROR_PARAM1;
- }
+ if (argc > 1 && !parse_bool(argv[1], &hcdebug))
+ return EC_ERROR_PARAM1;
ccprintf("Host command debug is %s\n", hcdebug ? "on" : "off");
return EC_SUCCESS;