diff options
author | Simon Glass <sjg@chromium.org> | 2012-05-26 17:42:32 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-03 13:24:28 -0700 |
commit | 9a4205faf3a378987cf534018e30be3892fcce26 (patch) | |
tree | 7069ffb7ce22c3e802ad873668549c3801d9f5fb /common/host_command.c | |
parent | 24acac67a3ee3038145ff329a85c83fcf37ce84e (diff) | |
download | chrome-ec-9a4205faf3a378987cf534018e30be3892fcce26.tar.gz |
Add host_command_process() to process a command immediately
Rather than go through the task queue, host_command_process() processes
the command immediately, has all of its required state passed in,
allowing the caller complete control of the buffers.
BUG=chrome-os-partner:10533
TEST=manual:
build and boot on link, see that messages are stil processed
build and boot on snow, which uses this new command
See that the SPI keyboard works now
Change-Id: Ib7587de10c42caf01bc95bb4d515fd0afc3da7d8
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25983
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r-- | common/host_command.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/common/host_command.c b/common/host_command.c index 4de9f36404..cc7de1e473 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -132,25 +132,34 @@ static const struct host_command *find_host_command(int command) } -/* Handle a LPC command */ -static void command_process(int slot) +enum ec_status host_command_process(int slot, int command, uint8_t *data, + int *response_size) { - int command = host_command[slot]; - uint8_t *data = host_get_buffer(slot); const struct host_command *cmd = find_host_command(command); + enum ec_status res = EC_RES_INVALID_COMMAND; CPRINTF("[hostcmd%d 0x%02x]\n", slot, command); - if (cmd) { - int size = 0; - int res = cmd->handler(data, &size); + *response_size = 0; + if (cmd) + res = cmd->handler(data, response_size); - host_send_response(slot, res, data, size); - } else { - host_send_response(slot, EC_RES_INVALID_COMMAND, data, 0); - } + return res; } +/* Handle a host command */ +static void command_process(int slot) +{ + int size; + int res; + + CPRINTF("[hostcmd%d 0x%02x]\n", slot, host_command[slot]); + + res = host_command_process(slot, host_command[slot], + host_get_buffer(slot), &size); + + host_send_response(slot, res, host_get_buffer(slot), size); +} /*****************************************************************************/ /* Initialization / task */ |