[tpmdd-devel,v3,07/12] tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
diff mbox

Message ID 1456262751-12096-8-git-send-email-christophe-h.ricard@st.com
State New
Headers show

Commit Message

Christophe Ricard Feb. 23, 2016, 9:25 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(+)

Patch
diff mbox

diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 08e6bf5..a2ef8ec 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -214,6 +214,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() */