Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: add sleep only for retry in i2c_nuvoton_write_status()

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>

authored by

Nayna Jain and committed by
Jarkko Sakkinen
0afb7118 2d2e376f

+3 -2
+3 -2
drivers/char/tpm/tpm_i2c_nuvoton.c
··· 124 124 /* this causes the current command to be aborted */ 125 125 for (i = 0, status = -1; i < TPM_I2C_RETRY_COUNT && status < 0; i++) { 126 126 status = i2c_nuvoton_write_buf(client, TPM_STS, 1, &data); 127 - usleep_range(TPM_I2C_BUS_DELAY, TPM_I2C_BUS_DELAY 128 - + TPM_I2C_DELAY_RANGE); 127 + if (status < 0) 128 + usleep_range(TPM_I2C_BUS_DELAY, TPM_I2C_BUS_DELAY 129 + + TPM_I2C_DELAY_RANGE); 129 130 } 130 131 return status; 131 132 }