From: Christophe RICARD Date: Sat, 13 Feb 2016 15:15:30 +0000 (+0100) Subject: tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=10460bc1cfdea19dbab2289a63b4be0c874d29f2;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency Add check in st33zp24_spi_evaluate_latency helping to diagnose if the chip is present or in a bad state. Signed-off-by: Christophe Ricard Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen --- diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index 08e6bf54d7dd..a2ef8ec4ba80 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() */