diff options
author | Simon Glass <sjg@chromium.org> | 2012-07-23 12:23:26 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-23 23:55:53 -0700 |
commit | 3120c479ec3e797bd1fdb4023e4f23f58a3794b1 (patch) | |
tree | 5d68fe10d93eb3e814c2ad66e07438a9d92a10ec | |
parent | 1661f1cef07f5b29b7e9c06fb3220fb48d110686 (diff) | |
download | chrome-ec-3120c479ec3e797bd1fdb4023e4f23f58a3794b1.tar.gz |
Revert "Revert "i2c: Move host command processing into a function""
This reverts commit 353bc6826033c0681394f0c49701dd5678422a0c
Change-Id: I9c7d7264db158f242b9b869f903e57b111d6f2c5
Reviewed-on: https://gerrit.chromium.org/gerrit/28188
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
-rw-r--r-- | chip/stm32/i2c.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index 248eed7237..31c5174c55 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -141,6 +141,23 @@ static void i2c_send_response(struct host_cmd_handler_args *args) i2c_write_raw(I2C2, host_buffer, out - host_buffer); } +/* Process the command in the i2c host buffer */ +static void i2c_process_command(void) +{ + /* we have an available command : execute it */ + host_cmd_args.command = host_buffer[0]; + host_cmd_args.result = EC_RES_SUCCESS; + host_cmd_args.send_response = i2c_send_response; + host_cmd_args.version = 0; + host_cmd_args.params = host_buffer + 1; + host_cmd_args.params_size = EC_HOST_PARAM_SIZE; + /* skip room for error code */ + host_cmd_args.response = host_buffer + 1; + host_cmd_args.response_max = EC_HOST_PARAM_SIZE; + host_cmd_args.response_size = 0; + host_command_received(&host_cmd_args); +} + static void i2c_event_handler(int port) { @@ -174,19 +191,7 @@ static void i2c_event_handler(int port) if (i2c_sr1[port] & (1 << 7)) { if (port == I2C2) { /* AP is waiting for EC response */ if (rx_index) { - /* we have an available command : execute it */ - host_cmd_args.command = host_buffer[0]; - host_cmd_args.result = EC_RES_SUCCESS; - host_cmd_args.send_response = - i2c_send_response; - host_cmd_args.version = 0; - host_cmd_args.params = host_buffer + 1; - host_cmd_args.params_size = EC_HOST_PARAM_SIZE; - /* skip room for error code */ - host_cmd_args.response = host_buffer + 1; - host_cmd_args.response_max = EC_HOST_PARAM_SIZE; - host_cmd_args.response_size = 0; - host_command_received(&host_cmd_args); + i2c_process_command(); /* reset host buffer after end of transfer */ rx_index = 0; } else { |