summaryrefslogtreecommitdiff
path: root/common/host_command.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-07-15 02:30:59 +0100
committerGerrit <chrome-bot@google.com>2012-07-22 00:36:39 -0700
commit949d525e2a4de87da034f7fd89c6cb0f04d8f1c4 (patch)
tree24a54fe35b41e310bd3b5f18ad326bfd25de1edc /common/host_command.c
parentc26eb30863f5a2b9b28ba4e2eb97c53f57cd24d1 (diff)
downloadchrome-ec-949d525e2a4de87da034f7fd89c6cb0f04d8f1c4.tar.gz
host_command: Add send_result() to the arg structure
It's a bit odd that the drivers package up a command to be processed by host_command, but then host_command calls a global function to pass the response back. This adds ambiguity in the host_send_response() implementations as to whether the command being responded to really is using the same buffers that the driver set up. Add a function pointer to the command, and have host_command call that. Add status to the args structure also, which removes some of the special case logic for error handling. BUG=chrome-os-partner:11317 TEST=manual and a bit ad-hoc: (note, this testing is not completed yet) Check that snow and link still process commands correctly over I2C from U-Boot. At this stage only the old interface is supported. SMDK5250 # mkbp test Old interface: New interface: Version 0: ec_command() returned error Test failed with error -1 SMDK5250 # Change-Id: Ic4afdcd7689666cc0f6af228abc6cffe41b0fcbf Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27468
Diffstat (limited to 'common/host_command.c')
-rw-r--r--common/host_command.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/common/host_command.c b/common/host_command.c
index 1420e79434..1a1c21fd40 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -49,15 +49,19 @@ void host_command_received(struct host_cmd_handler_args *args)
if (args->command == EC_CMD_REBOOT) {
system_reset(SYSTEM_RESET_HARD);
/* Reset should never return; if it does, post an error */
- host_send_response(EC_RES_ERROR);
- return;
+ args->result = EC_RES_ERROR;
}
- /* Save the command */
- pending_args = args;
+ /* If the driver has signalled an error, send the response now */
+ if (args->result) {
+ args->send_response(args);
+ } else {
+ /* Save the command */
+ pending_args = args;
- /* Wake up the task to handle the command */
- task_set_event(TASK_ID_HOSTCMD, TASK_EVENT_CMD_PENDING, 0);
+ /* Wake up the task to handle the command */
+ task_set_event(TASK_ID_HOSTCMD, TASK_EVENT_CMD_PENDING, 0);
+ }
}
/*
@@ -224,8 +228,9 @@ void host_command_task(void)
int evt = task_wait_event(-1);
/* process it */
if ((evt & TASK_EVENT_CMD_PENDING) && pending_args) {
- enum ec_status res = host_command_process(pending_args);
- host_send_response(res);
+ pending_args->result =
+ host_command_process(pending_args);
+ pending_args->send_response(pending_args);
}
}
}