From e723318ec139e6729e4f2aa20cdde32f04960922 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 26 May 2012 13:35:01 -0700 Subject: Remove unnecessary host_send_result() This seems to be a hangover from the LPC protocol. We can send a result just by sending a response with no data. Drop this function and remove all uses of it. Also use 'enum ec_status' instead of int, since this is the correct response type. BUG=chrome-os-partner:10533 TEST=manual: build for all boards build and boot on daisy Change-Id: I93a029bd6ba8cec567b61af3b410bcead015b5c0 Signed-off-by: Simon Glass Reviewed-on: https://gerrit.chromium.org/gerrit/25980 --- chip/lm4/lpc.c | 16 +++++++--------- chip/stm32/i2c.c | 14 +++++--------- common/host_command.c | 10 ++++------ common/system_common.c | 6 +++--- include/host_command.h | 11 +++-------- 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c index b44ff86005..fdf491563b 100644 --- a/chip/lm4/lpc.c +++ b/chip/lm4/lpc.c @@ -126,7 +126,7 @@ uint8_t *lpc_get_memmap_range(void) } -void host_send_result(int slot, int result) +static void send_result(int slot, enum ec_status result) { int ch = slot ? LPC_CH_USER : LPC_CH_KERNEL; @@ -151,20 +151,18 @@ void host_send_result(int slot, int result) lpc_generate_sci(); } -void host_send_response(int slot, const uint8_t *data, int size) +void host_send_response(int slot, enum ec_status result, const uint8_t *data, + int size) { uint8_t *out = host_get_buffer(slot); /* Fail if response doesn't fit in the param buffer */ - if (size < 0 || size > EC_PARAM_SIZE) { - host_send_result(slot, EC_RES_ERROR); - return; - } - - if (data != out) + if (size < 0 || size > EC_PARAM_SIZE) + result = EC_RES_ERROR; + else if (data != out) memcpy(out, data, size); - host_send_result(slot, EC_RES_SUCCESS); + send_result(slot, result); } /* Return true if the TOH is still set */ diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index f9fd2bd144..7717dc280c 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -121,7 +121,7 @@ static int i2c_write_raw(int port, void *buf, int len) return len; } -static void _send_result(int slot, int result, int size) +static void _send_result(int slot, enum ec_status result, int size) { int i; int len = 1; @@ -142,19 +142,15 @@ static void _send_result(int slot, int result, int size) i2c_write_raw(I2C2, host_buffer, len); } -void host_send_result(int slot, int result) -{ - _send_result(slot, result, 0); -} - -void host_send_response(int slot, const uint8_t *data, int size) +void host_send_response(int slot, enum ec_status result, const uint8_t *data, + int size) { uint8_t *out = host_get_buffer(slot); - if (data != out) + if (size > 0 && data != out) memcpy(out, data, size); - _send_result(slot, EC_RES_SUCCESS, size); + _send_result(slot, result, size); } uint8_t *host_get_buffer(int slot) diff --git a/common/host_command.c b/common/host_command.c index 93e66b68ad..4de9f36404 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -34,7 +34,7 @@ void host_command_received(int slot, int command) if (command == EC_CMD_REBOOT) { system_reset(1); /* Reset should never return; if it does, post an error */ - host_send_result(slot, EC_RES_ERROR); + host_send_response(slot, EC_RES_ERROR, NULL, 0); return; } @@ -144,12 +144,10 @@ static void command_process(int slot) if (cmd) { int size = 0; int res = cmd->handler(data, &size); - if ((res == EC_RES_SUCCESS) && size) - host_send_response(slot, data, size); - else - host_send_result(slot, res); + + host_send_response(slot, res, data, size); } else { - host_send_result(slot, EC_RES_INVALID_COMMAND); + host_send_response(slot, EC_RES_INVALID_COMMAND, data, 0); } } diff --git a/common/system_common.c b/common/system_common.c index 353068365f..f4cb3f1755 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -741,10 +741,10 @@ int host_command_reboot(uint8_t *data, int *resp_size) #ifdef CONFIG_TASK_HOSTCMD #ifdef CONFIG_LPC /* Clean busy bits on host */ - host_send_result(0, EC_RES_SUCCESS); - host_send_result(1, EC_RES_SUCCESS); + host_send_response(0, EC_RES_SUCCESS, NULL, 0); + host_send_response(1, EC_RES_SUCCESS, NULL, 0); #elif defined CONFIG_I2C - host_send_result(0, EC_RES_SUCCESS); + host_send_response(0, EC_RES_SUCCESS, NULL, 0); #endif #endif diff --git a/include/host_command.h b/include/host_command.h index 245d39a162..ea31bdcc41 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -26,20 +26,15 @@ struct host_command { command slots (0=kernel, 1=user). */ void host_command_received(int slot, int command); -/* Send errors or success result code to a host command, - * without response data. - * is 0 for kernel-originated commands, - * 1 for usermode-originated commands. - * is the error code. */ -void host_send_result(int slot, int result); - // success results with response data /* Send a successful result code along with response data to a host command. * is 0 for kernel-originated commands, * 1 for usermode-originated commands. + * is the result code for the command (EC_RES_...) * is the buffer with the response payload. * is the size of the response buffer. */ -void host_send_response(int slot, const uint8_t *data, int size); +void host_send_response(int slot, enum ec_status result, const uint8_t *data, + int size); /* Return a pointer to the host command data buffer. This buffer must * only be accessed between a notification to host_command_received() -- cgit v1.2.1