summaryrefslogtreecommitdiff
path: root/common/lightbar.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-11 11:18:17 -0700
committerGerrit <chrome-bot@google.com>2012-07-11 14:46:30 -0700
commit07ca0977fe554696288048c5c691aa5b9cfa7ac8 (patch)
treeaade5d33536338c2baa869c1865e4eb11b390e3e /common/lightbar.c
parent61e0e5508a559cc9935951be4f68455809300a2e (diff)
downloadchrome-ec-07ca0977fe554696288048c5c691aa5b9cfa7ac8.tar.gz
Refactor API for host commands, and handle variable length data better
Added version mask field to DECLARE_HOST_COMMAND() because it's convenient to do so when I'm touching all host command implementations, but all commands simply declare version 0 and nothing checks it yet. Will add version support in a followup CL. This change is internal to the EC; it does not change the data sent over the host interface. BUG=chrome-os-partner:11275 TEST=manual ectool version && ectool echash; should get sane data from both ectool flashread 0x80 0x40 /tmp/foo && od -tx1 /tmp/foo should match data from offset 0x80 of ec.bin (od -j128 -n64 -tx1 ec.bin) Change-Id: I5699f72b8d5e1ac23929353c9a34158d76c44206 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27172 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/lightbar.c')
-rw-r--r--common/lightbar.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/common/lightbar.c b/common/lightbar.c
index 2e8434423f..bb7805c98d 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -5,7 +5,7 @@
* LED controls.
*/
-#include "board.h"
+#include "common.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
@@ -678,15 +678,24 @@ static void do_cmd_rgb(uint8_t led,
/* Host commands via LPC bus */
/****************************************************************************/
-static int lpc_cmd_lightbar(uint8_t *data, int *resp_size)
+static int lpc_cmd_lightbar(struct host_cmd_handler_args *args)
{
struct ec_params_lightbar_cmd *ptr =
- (struct ec_params_lightbar_cmd *)data;
+ (struct ec_params_lightbar_cmd *)args->response;
+
+ /*
+ * TODO: (crosbug.com/p/11277) Now that params and response are
+ * separate pointers, they need to be propagated to the lightbar
+ * sub-commands. For now, just copy params to response so the
+ * sub-commands above will work unchanged.
+ */
+ if (args->params != args->response)
+ memcpy(args->response, args->params, args->params_size);
switch (ptr->in.cmd) {
case LIGHTBAR_CMD_DUMP:
do_cmd_dump(ptr);
- *resp_size = sizeof(struct ec_params_lightbar_cmd);
+ args->response_size = sizeof(struct ec_params_lightbar_cmd);
break;
case LIGHTBAR_CMD_OFF:
lightbar_off();
@@ -716,7 +725,7 @@ static int lpc_cmd_lightbar(uint8_t *data, int *resp_size)
break;
case LIGHTBAR_CMD_GET_SEQ:
ptr->out.get_seq.num = current_state;
- *resp_size = sizeof(struct ec_params_lightbar_cmd);
+ args->response_size = sizeof(struct ec_params_lightbar_cmd);
break;
default:
CPRINTF("[%T LB bad cmd 0x%x]\n", ptr->in.cmd);
@@ -726,7 +735,10 @@ static int lpc_cmd_lightbar(uint8_t *data, int *resp_size)
return EC_RES_SUCCESS;
}
-DECLARE_HOST_COMMAND(EC_CMD_LIGHTBAR_CMD, lpc_cmd_lightbar);
+DECLARE_HOST_COMMAND(EC_CMD_LIGHTBAR_CMD,
+ lpc_cmd_lightbar,
+ EC_VER_MASK(0));
+
/****************************************************************************/