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 <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25980
This commit is contained in:
Simon Glass
2012-05-26 13:35:01 -07:00
committed by Gerrit
parent ed9d6282d4
commit e723318ec1
5 changed files with 22 additions and 35 deletions

View File

@@ -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 */

View File

@@ -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)

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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.
* <slot> is 0 for kernel-originated commands,
* 1 for usermode-originated commands.
* <result> 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.
* <slot> is 0 for kernel-originated commands,
* 1 for usermode-originated commands.
* <result> is the result code for the command (EC_RES_...)
* <data> is the buffer with the response payload.
* <size> 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()