diff options
Diffstat (limited to 'util/comm-host.c')
-rw-r--r-- | util/comm-host.c | 22 |
1 files changed, 6 insertions, 16 deletions
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"); |