summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-07-15 02:30:59 +0100
committerGerrit <chrome-bot@google.com>2012-07-23 13:23:06 -0700
commit6147b158d5f94a1df9beedf3d76b3e9d383d4741 (patch)
tree8ad210fa671137b9742d3286e0211cf44c2ab480 /common
parentff57dbce86eb5941528c0c7c29b34e5a3e591483 (diff)
downloadchrome-ec-6147b158d5f94a1df9beedf3d76b3e9d383d4741.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: I816738150bce3f8d78e7cd32abf361621aa12312 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28154 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/host_command.c21
-rw-r--r--common/system_common.c3
2 files changed, 15 insertions, 9 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);
}
}
}
diff --git a/common/system_common.c b/common/system_common.c
index 198257057f..22e42272c2 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -805,7 +805,8 @@ int host_command_reboot(struct host_cmd_handler_args *args)
#ifdef CONFIG_TASK_HOSTCMD
/* Clean busy bits on host */
- host_send_response(EC_RES_SUCCESS);
+ args->result = EC_RES_SUCCESS;
+ args->send_response(args);
#endif
CPRINTF("[%T Executing host reboot command %d]\n", p.cmd);