lkml.org 
[lkml]   [2021]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] tpm_tis_spi_main: set cs_change = 0 when timesout
Date
The cs cannot change back to 'high' when the count is 
TPM_RETRY. So the TPM chips thought this communication
is not over. And next times communication cannot be
effective because the communications mixed up with the
last time.

v1 -> v2:
- fix spi_xfer.cs_change to spi_xfer->cs_change

Signed-off-by: wanghongzhe <wanghongzhe@huawei.com>
---
drivers/char/tpm/tpm_tis_spi_main.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c
index 3856f6ebcb34..6c52cbb28881 100644
--- a/drivers/char/tpm/tpm_tis_spi_main.c
+++ b/drivers/char/tpm/tpm_tis_spi_main.c
@@ -64,8 +64,18 @@ static int tpm_tis_spi_flow_control(struct tpm_tis_spi_phy *phy,
break;
}

- if (i == TPM_RETRY)
+ if (i == TPM_RETRY) {
+ /* change back to 'high',
+ * So the TPM chips thinks the last communication
+ * is done.
+ */
+ spi_xfer->cs_change = 0;
+ spi_xfer->len = 1;
+ spi_message_init(&m);
+ spi_message_add_tail(spi_xfer, &m);
+ ret = spi_sync_locked(phy->spi_device, &m);
return -ETIMEDOUT;
+ }
}

return 0;
--
2.19.1
\
 
 \ /
  Last update: 2021-02-08 03:00    [W:0.044 / U:3.768 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site