From 4c708232ac82e2c0bfe075027fbe88afd9456535 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Fri, 10 Jul 2015 14:50:53 -0700 Subject: [PATCH] Cr50: cleanup: Rename the "sps" console command "spshc" The "sps" console command declared in sps_hc.c is misleading. It shouldn't be "sps", when it's actually part of the host command protocol stuff. This CL changes the command name to "spshc" instead. The command just enables or disables SPS host commands. Note that because there's no notification if something else calls sps_unregister_rx_handler(), there's no way for the sps_hc.c module to know whether it's still registered. BUG=none BRANCH=none TEST=make buildall Using a test program, such as extra/ftdi_hostcmd/, I can send host commands to an EC attached via an FTDI USB-to-SPI adapter. On the EC console, this: spshc off causes the test program to fail, and this: spshc causes it to work again. Change-Id: Ie0edbde179b570f170ff9464313e5e33ab985f21 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/284942 Reviewed-by: Randall Spangler --- chip/g/sps_hc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/chip/g/sps_hc.c b/chip/g/sps_hc.c index d0c16ba2fe..e3eb043018 100644 --- a/chip/g/sps_hc.c +++ b/chip/g/sps_hc.c @@ -290,22 +290,20 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, static int command_sps(int argc, char **argv) { if (argc > 1) { - if (!strcasecmp(argv[1], "reset") || - !strcasecmp(argv[1], "on")) - sps_hc_enable(); - else if (!strcasecmp(argv[1], "off")) - sps_hc_disable(); - else + if (0 != strcasecmp(argv[1], "off")) return EC_ERROR_PARAM1; + + sps_hc_disable(); + ccprintf("SPS host commands disabled\n"); + return EC_SUCCESS; } - ccprintf("state=%d rxbuf_count=%d rxbuf_needed=%d, discard=%d\n", - state, rxbuf_count, rxbuf_needed, discard_response); - + sps_hc_enable(); + ccprintf("SPS host commands enabled\n"); return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(sps, command_sps, - "[reset|off|on]", - "With no args, print some info", +DECLARE_CONSOLE_COMMAND(spshc, command_sps, + "[off]", + "Enable (default) or disable SPS host commands", NULL);