From 97bf36c9d3ad3d96ad6dea7cd6e6f3e164297c43 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 29 Mar 2013 12:40:07 -0700 Subject: 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 Reviewed-on: https://gerrit.chromium.org/gerrit/46900 Reviewed-by: Bill Richardson --- common/host_command.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'common/host_command.c') 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; -- cgit v1.2.1