From 258b9b1ebe223a87d2a8159db5d5720b30ea014e Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Tue, 6 Mar 2018 16:48:36 +0100 Subject: [PATCH] ectool: fix error codes for servo v2 spi support When the EC sends back an error code inside the 'result' field of the v3 protocol, the transport is supposed to return -EECRESULT-error_code. Fix the the servo spi transport to do so. Signed-off-by: Vincent Palatin BRANCH=none BUG=b:72360575 TEST=with ZerbleBarn connected to a Servo v2, run 'ectool_servo fpinfo' and 'ectool_servo fptemplate badfile.bin' Change-Id: I54eec9194cfefd422078344500685736aadaffcf Reviewed-on: https://chromium-review.googlesource.com/951682 Commit-Ready: Vincent Palatin Tested-by: Vincent Palatin Reviewed-by: Randall Spangler --- util/comm-servo-spi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/util/comm-servo-spi.c b/util/comm-servo-spi.c index 6d9d095be4..4010d2ec64 100644 --- a/util/comm-servo-spi.c +++ b/util/comm-servo-spi.c @@ -236,7 +236,7 @@ static int get_response(uint8_t *bodydest, size_t bodylen) return -EC_RES_ERROR; } - return 0; + return hdr.result ? -EECRESULT - hdr.result : 0; read_error: fprintf(stderr, "Read failed: %s\n", ftdi_get_error_string(&ftdi)); @@ -256,9 +256,8 @@ static int ec_command_servo_spi(int cmd, int version, return -EC_RES_ERROR; } - if (send_request(cmd, version, outdata, outsize) == 0 && - get_response(indata, insize) == 0) - ret = 0; + if (send_request(cmd, version, outdata, outsize) == 0) + ret = get_response(indata, insize); if (mpsse_set_pins(CS_L) != 0) { fprintf(stderr, "Stop failed: %s\n",