trunks: retry in case of Remote I/O errors

Retry writing to /dev/tpm0 once in case of EREMOTEIO error
during the first write attempt.
The i2c driver may return this error if the tpm or the i2c
controller is sleeping when a command is sent.
In this case, the first write wakes the device, and the
second one succeeds.

BUG=b:35648537
TEST=Provoke EREMOTEIO errors, check in the logs that
     trunksd retries and recovers successfully.

Change-Id: I90733c3280c8e49c3255be5c0b62c21bba0b1a61
Reviewed-on: https://chromium-review.googlesource.com/450059
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
1 file changed