From 6147b158d5f94a1df9beedf3d76b3e9d383d4741 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 15 Jul 2012 02:30:59 +0100 Subject: 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 Reviewed-on: https://gerrit.chromium.org/gerrit/28154 Reviewed-by: Randall Spangler --- common/host_command.c | 21 +++++++++++++-------- common/system_common.c | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'common') 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); -- cgit v1.2.1