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 <vpalatin@chromium.org>

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 <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Vincent Palatin
2018-03-06 16:48:36 +01:00
committed by chrome-bot
parent 7f4018c41f
commit 258b9b1ebe

View File

@@ -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",