summaryrefslogtreecommitdiff
path: root/common/keyboard_scan.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/keyboard_scan.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/keyboard_scan.c')
-rw-r--r--common/keyboard_scan.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index 45eb45a35a..7f17d8c237 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -587,18 +587,12 @@ DECLARE_HOST_COMMAND(EC_CMD_MKBP_SIMULATE_KEY,
static int command_ksstate(int argc, char **argv)
{
- if (argc > 1) {
- if (!strcasecmp(argv[1], "on"))
- print_state_changes = 1;
- else if (!strcasecmp(argv[1], "off"))
- print_state_changes = 0;
- else
- return EC_ERROR_PARAM1;
- } else {
- print_state(debounced_state, "debounced ");
- print_state(prev_state, "prev ");
- print_state(debouncing, "debouncing");
- }
+ if (argc > 1 && !parse_bool(argv[1], &print_state_changes))
+ return EC_ERROR_PARAM1;
+
+ print_state(debounced_state, "debounced ");
+ print_state(prev_state, "prev ");
+ print_state(debouncing, "debouncing");
ccprintf("Keyboard scan state printing %s\n",
print_state_changes ? "on" : "off");