diff options
author | Simon Glass <sjg@chromium.org> | 2012-07-15 02:30:59 +0100 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-23 13:23:06 -0700 |
commit | 6147b158d5f94a1df9beedf3d76b3e9d383d4741 (patch) | |
tree | 8ad210fa671137b9742d3286e0211cf44c2ab480 /include | |
parent | ff57dbce86eb5941528c0c7c29b34e5a3e591483 (diff) | |
download | chrome-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 'include')
-rw-r--r-- | include/host_command.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/include/host_command.h b/include/host_command.h index 65cf849c6a..a88761a6e2 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -13,10 +13,16 @@ /* Args for host command handler */ struct host_cmd_handler_args { + /* + * The driver that receives the command sets up the send_response() + * handler. Once the command is processed this handler is called to + * send the response back to the host. + */ + void (*send_response)(struct host_cmd_handler_args *args); uint8_t command; /* Command (e.g., EC_CMD_FLASH_GET_INFO) */ uint8_t version; /* Version of command (0-31) */ - const uint8_t *params; /* Input parameters */ uint8_t params_size; /* Size of input parameters in bytes */ + const uint8_t *params; /* Input parameters */ /* * Pointer to output response data buffer. On input to the handler, * points to a buffer of size response_max. Command handler can change @@ -31,6 +37,17 @@ struct host_cmd_handler_args { */ uint8_t response_max; uint8_t response_size; /* Size of data pointed to by resp_ptr */ + + /* + * This is the result returned by command and therefore the status to + * be reported from the command execution to the host. The driver + * should set this to EC_RES_SUCCESS on receipt of a valid command. + * It is then passed back to the driver via send_response() when + * command execution is complete. The driver may still override this + * when sending the response back to the host if it detects an error + * in the response or in its own operation. + */ + enum ec_status result; }; /* Host command */ @@ -100,16 +117,6 @@ uint32_t host_get_events(void); */ void host_command_received(struct host_cmd_handler_args *args); -/** - * Send a successful result code to a host command. - * - * Response data, if any, has been stored in the args passed to - * host_command_received(). - * - * @param result Result code for the command (EC_RES_...) - */ -void host_send_response(enum ec_status result); - /* Register a host command handler */ #define DECLARE_HOST_COMMAND(command, routine, version_mask) \ const struct host_command __host_cmd_##command \ |