summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/comm-dev.c6
-rw-r--r--util/comm-host.c22
2 files changed, 7 insertions, 21 deletions
diff --git a/util/comm-dev.c b/util/comm-dev.c
index cdbbbdf48e..4fdef31cb5 100644
--- a/util/comm-dev.c
+++ b/util/comm-dev.c
@@ -144,11 +144,7 @@ int comm_init_dev(const char *device_name)
ec_readmem = ec_readmem_dev;
/*
- * TODO(crosbug.com/p/23823): Need a way to get this from the driver
- * and EC. For now, pick a magic lowest common denominator value. The
- * ec_max_outsize is set to handle v3 EC protocol. The ec_max_insize
- * needs to be set to the largest value that can be returned from the
- * EC, EC_PROTO2_MAX_PARAM_SIZE.
+ * Set temporary size, will be updated later.
*/
ec_max_outsize = EC_PROTO2_MAX_PARAM_SIZE - 8;
ec_max_insize = EC_PROTO2_MAX_PARAM_SIZE;
diff --git a/util/comm-host.c b/util/comm-host.c
index b5cd51adfe..7da86316fb 100644
--- a/util/comm-host.c
+++ b/util/comm-host.c
@@ -78,7 +78,6 @@ int ec_command(int command, int version,
int comm_init(int interfaces, const char *device_name)
{
struct ec_response_get_protocol_info info;
- int new_size;
/* Default memmap access */
ec_readmem = fake_readmem;
@@ -109,25 +108,16 @@ int comm_init(int interfaces, const char *device_name)
return 1;
}
- /*
- * read max request / response size from ec and reduce buffer size
- * if the size supported by ec is less than the default value.
- */
+ /* read max request / response size from ec for protocol v3+ */
if (ec_command(EC_CMD_GET_PROTOCOL_INFO, 0, NULL, 0, &info,
sizeof(info)) == sizeof(info)) {
- new_size = info.max_request_packet_size -
- sizeof(struct ec_host_request);
- if (ec_max_outsize > new_size) {
- ec_max_outsize = new_size;
- ec_outbuf = realloc(ec_outbuf, ec_max_outsize);
- }
- new_size = info.max_response_packet_size -
+ ec_max_outsize = info.max_request_packet_size -
+ sizeof(struct ec_host_request);
+ ec_max_insize = info.max_response_packet_size -
sizeof(struct ec_host_response);
- if (ec_max_insize > new_size) {
- ec_max_insize = new_size;
- ec_inbuf = realloc(ec_inbuf, ec_max_insize);
- }
+ ec_outbuf = realloc(ec_outbuf, ec_max_outsize);
+ ec_inbuf = realloc(ec_inbuf, ec_max_insize);
if (!ec_outbuf || !ec_inbuf) {
fprintf(stderr, "Unable to reallocate buffers\n");