From bcef77324e5e52fa546e0cf25d9609697167633c Mon Sep 17 00:00:00 2001 From: Harini Jayaraman Date: Thu, 1 Sep 2011 12:12:58 -0600 Subject: [PATCH] spi_qsd: Fix for SPI Operational State Invalid error This error is reproted randomly when the SPI core is put into RUN state and occurs when the ACPU clock is low. When the timer expires, we check again to ensure that the STATE_VALID bit is set before returning. CRs-fixed: 304672 Signed-off-by: Harini Jayaraman --- drivers/spi/spi_qsd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi_qsd.c b/drivers/spi/spi_qsd.c index 23fd1fe8a53..b42ba07a54a 100644 --- a/drivers/spi/spi_qsd.c +++ b/drivers/spi/spi_qsd.c @@ -837,14 +837,19 @@ static inline int msm_spi_wait_valid(struct msm_spi *dd) */ if (delay < SPI_DELAY_THRESHOLD) delay = SPI_DELAY_THRESHOLD; - timeout = jiffies + msecs_to_jiffies(delay * SPI_DEFAULT_TIMEOUT); + + /* Adding one to round off to the nearest jiffy */ + timeout = jiffies + msecs_to_jiffies(delay * SPI_DEFAULT_TIMEOUT) + 1; while (!msm_spi_is_valid_state(dd)) { if (time_after(jiffies, timeout)) { - if (dd->cur_msg) - dd->cur_msg->status = -EIO; - dev_err(dd->dev, "%s: SPI operational state not valid" - "\n", __func__); - return -1; + if (!msm_spi_is_valid_state(dd)) { + if (dd->cur_msg) + dd->cur_msg->status = -EIO; + dev_err(dd->dev, "%s: SPI operational state" + "not valid\n", __func__); + return -ETIMEDOUT; + } else + return 0; } /* * For smaller values of delay, context switch time