]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tpm: add sleep only for retry in i2c_nuvoton_write_status()
authorNayna Jain <nayna@linux.vnet.ibm.com>
Fri, 10 Mar 2017 18:45:54 +0000 (13:45 -0500)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 3 Apr 2017 19:46:02 +0000 (22:46 +0300)
Currently, there is an unnecessary 1 msec delay added in
i2c_nuvoton_write_status() for the successful case. This
function is called multiple times during send() and recv(),
which implies adding multiple extra delays for every TPM
operation.

This patch calls usleep_range() only if retry is to be done.

Signed-off-by: Nayna Jain <nayna@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org (linux-4.8)
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm_i2c_nuvoton.c

index 0c98c424d792d7e0fd5b4c88601c608e5e604371..c6428771841f814a891719fab16e92d7e0723fc7 100644 (file)
@@ -124,8 +124,9 @@ static s32 i2c_nuvoton_write_status(struct i2c_client *client, u8 data)
        /* this causes the current command to be aborted */
        for (i = 0, status = -1; i < TPM_I2C_RETRY_COUNT && status < 0; i++) {
                status = i2c_nuvoton_write_buf(client, TPM_STS, 1, &data);
-               usleep_range(TPM_I2C_BUS_DELAY, TPM_I2C_BUS_DELAY
-                            + TPM_I2C_DELAY_RANGE);
+               if (status < 0)
+                       usleep_range(TPM_I2C_BUS_DELAY, TPM_I2C_BUS_DELAY
+                                    + TPM_I2C_DELAY_RANGE);
        }
        return status;
 }