diff mbox

[RFC,6/9] tpm_tis_spi: fix sending wrong data during wait state handling

Message ID 20171208184658.9588-7-Alexander.Steffen@infineon.com (mailing list archive)
State Rejected
Headers show

Commit Message

Alexander Steffen Dec. 8, 2017, 6:46 p.m. UTC
When the TPM signals wait states, the driver has to repeat the last byte
until the TPM stops signaling wait states and accepts that byte. It should
not send a dummy byte, even though that might work with some TPM
implementations.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
 drivers/char/tpm/tpm_tis_spi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jarkko Sakkinen Jan. 18, 2018, 6:26 p.m. UTC | #1
On Fri, Dec 08, 2017 at 07:46:55PM +0100, Alexander Steffen wrote:
> When the TPM signals wait states, the driver has to repeat the last byte
> until the TPM stops signaling wait states and accepts that byte. It should
> not send a dummy byte, even though that might work with some TPM
> implementations.
> 
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> ---
>  drivers/char/tpm/tpm_tis_spi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
> index c4f511b..2758b41 100644
> --- a/drivers/char/tpm/tpm_tis_spi.c
> +++ b/drivers/char/tpm/tpm_tis_spi.c
> @@ -88,9 +88,8 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
>  
>  		if ((phy->iobuf[3] & 0x01) == 0) {
>  			// handle SPI wait states
> -			phy->iobuf[0] = 0;
> -
>  			for (i = 0; i < TPM_RETRY; i++) {
> +				phy->iobuf[0] = addr;

Why it has to be moved inside the loop?

/Jarkko
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
index c4f511b..2758b41 100644
--- a/drivers/char/tpm/tpm_tis_spi.c
+++ b/drivers/char/tpm/tpm_tis_spi.c
@@ -88,9 +88,8 @@  static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
 
 		if ((phy->iobuf[3] & 0x01) == 0) {
 			// handle SPI wait states
-			phy->iobuf[0] = 0;
-
 			for (i = 0; i < TPM_RETRY; i++) {
+				phy->iobuf[0] = addr;
 				spi_xfer.len = 1;
 				spi_message_init(&m);
 				spi_message_add_tail(&spi_xfer, &m);