summaryrefslogtreecommitdiff
path: root/util/comm-host.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-16 11:43:31 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-17 16:09:43 -0700
commit5dfe8d26740ab4521f0f177c23b763eef6d8c1fa (patch)
treef002a2a696d05eb010dbc7e0aa50dc6933351b28 /util/comm-host.c
parentac26c227a86b3262ae6da01b3e2d09f4913e9104 (diff)
downloadchrome-ec-5dfe8d26740ab4521f0f177c23b763eef6d8c1fa.tar.gz
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 <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/300024 Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'util/comm-host.c')
-rw-r--r--util/comm-host.c14
1 files changed, 8 insertions, 6 deletions
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);