diff mbox

[v2,07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency

Message ID 1455376535-9549-8-git-send-email-christophe-h.ricard@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe Ricard Feb. 13, 2016, 3:15 p.m. UTC
Add check in st33zp24_spi_evaluate_latency helping to diagnose if the chip
is present or in a bad state.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
 drivers/char/tpm/st33zp24/spi.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 0af836a..7cabf1d 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -213,6 +213,11 @@  static int st33zp24_spi_evaluate_latency(void *phy_id)
 						&data, 1);
 		latency++;
 	}
+	if (status < 0)
+		return status;
+	if (latency == MAX_SPI_LATENCY)
+		return -ENODEV;
+
 	return latency - 1;
 } /* evaluate_latency() */