tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
authorChristophe RICARD <christophe.ricard@gmail.com>
Sat, 13 Feb 2016 15:15:30 +0000 (16:15 +0100)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 25 Jun 2016 14:26:35 +0000 (17:26 +0300)
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 <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/st33zp24/spi.c

index 08e6bf54d7dd8cea50d6cc84ff61ba5ef4ae2624..a2ef8ec4ba8036ac17f29c3ce40142b952c3e252 100644 (file)
@@ -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() */