From 5dfe8d26740ab4521f0f177c23b763eef6d8c1fa Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Wed, 16 Sep 2015 11:43:31 -0700 Subject: ectool: fix sizes one more time. ectool is only sending payload. kernel is adding header for v3 commands. (length, crc, ...) Put back the header I previously deleted in cl:274086 BRANCH=ryu BUG=chrome-os-partner:45304 TEST=ectool flashwrite now works. Change-Id: I40fa30bc477a090261048eb51b382483f28d4ab1 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/300024 Reviewed-by: Shawn N --- util/comm-host.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'util') diff --git a/util/comm-host.c b/util/comm-host.c index 601411d74f..31ad56343e 100644 --- a/util/comm-host.c +++ b/util/comm-host.c @@ -120,12 +120,14 @@ int comm_init(int interfaces, const char *device_name) /* 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)) { - if ((allow_large_buffer) || - (info.max_request_packet_size < ec_max_outsize)) - ec_max_outsize = info.max_request_packet_size; - if ((allow_large_buffer) || - (info.max_request_packet_size < ec_max_insize)) - ec_max_insize = info.max_response_packet_size; + int outsize = info.max_request_packet_size - + sizeof(struct ec_host_request); + int insize = info.max_response_packet_size - + sizeof(struct ec_host_response); + if ((allow_large_buffer) || (outsize < ec_max_outsize)) + ec_max_outsize = outsize; + if ((allow_large_buffer) || (insize < ec_max_insize)) + ec_max_insize = insize; ec_outbuf = realloc(ec_outbuf, ec_max_outsize); ec_inbuf = realloc(ec_inbuf, ec_max_insize); -- cgit v1.2.1