diff mbox

[2/4] tpm_i2c_interface: set timeout before each request

Message ID 1479879962-1943-2-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Nov. 23, 2016, 5:46 a.m. UTC
The i2c code manipulates req->timeout, so it has to be reset before
re-sending.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 libstb/drivers/tpm_i2c_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Claudio Carvalho Nov. 24, 2016, 3:18 a.m. UTC | #1
Tested-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com>

On 11/23/2016 03:46 AM, Stewart Smith wrote:
> The i2c code manipulates req->timeout, so it has to be reset before
> re-sending.
> 
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
> ---
>  libstb/drivers/tpm_i2c_interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libstb/drivers/tpm_i2c_interface.c b/libstb/drivers/tpm_i2c_interface.c
> index 4d136fd..89f5ba6 100644
> --- a/libstb/drivers/tpm_i2c_interface.c
> +++ b/libstb/drivers/tpm_i2c_interface.c
> @@ -99,11 +99,11 @@ int tpm_i2c_request_send(int tpm_bus_id, int tpm_dev_addr, int read_write,
>  	 * since the I2C master's timeout is too short (1ms per byte).
>  	 */
>  	timeout = (buflen + offset_bytes + 2) * I2C_BYTE_TIMEOUT_MS;
> -	i2c_set_req_timeout(req, timeout);
>  
>  	for (retries = 0; retries <= TPM_MAX_NACK_RETRIES; retries++) {
>  		rc = 1;
>  		waited = 0;
> +		i2c_set_req_timeout(req, timeout);
>  		i2c_queue_req(req);
>  
>  		do {
>
diff mbox

Patch

diff --git a/libstb/drivers/tpm_i2c_interface.c b/libstb/drivers/tpm_i2c_interface.c
index 4d136fd..89f5ba6 100644
--- a/libstb/drivers/tpm_i2c_interface.c
+++ b/libstb/drivers/tpm_i2c_interface.c
@@ -99,11 +99,11 @@  int tpm_i2c_request_send(int tpm_bus_id, int tpm_dev_addr, int read_write,
 	 * since the I2C master's timeout is too short (1ms per byte).
 	 */
 	timeout = (buflen + offset_bytes + 2) * I2C_BYTE_TIMEOUT_MS;
-	i2c_set_req_timeout(req, timeout);
 
 	for (retries = 0; retries <= TPM_MAX_NACK_RETRIES; retries++) {
 		rc = 1;
 		waited = 0;
+		i2c_set_req_timeout(req, timeout);
 		i2c_queue_req(req);
 
 		do {