summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaewon Kim <jaewon02.kim@samsung.com>2014-10-17 11:55:07 +0900
committerChanho Park <chanho61.park@samsung.com>2014-11-18 12:01:01 +0900
commite2ae146ce61c03b5bfecae78735bcfa5c3911a72 (patch)
treea668da1c27e2485c593c4cbbdbeaa82d80b57ac7
parenta5f5f3e6e6f03a139df6e26fd05bf6fa23b12cad (diff)
downloadlinux-3.10-e2ae146ce61c03b5bfecae78735bcfa5c3911a72.tar.gz
linux-3.10-e2ae146ce61c03b5bfecae78735bcfa5c3911a72.tar.bz2
linux-3.10-e2ae146ce61c03b5bfecae78735bcfa5c3911a72.zip
sensorhub: Fix temporary spi_read error
When try to read SPI, sometimes buffer filled with zero. And spi_read does not return error. In normal case, first byte of buffer is used to command byte. And this is not zero. So, this patch checks first byte of buffer. Change-Id: If75d57c0426d819476d87e82391901dfb8fa1652 Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
-rw-r--r--drivers/sensorhub/stm/ssp_spi.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/sensorhub/stm/ssp_spi.c b/drivers/sensorhub/stm/ssp_spi.c
index 039624c66a9..d6c33a169e6 100644
--- a/drivers/sensorhub/stm/ssp_spi.c
+++ b/drivers/sensorhub/stm/ssp_spi.c
@@ -16,6 +16,7 @@
#define LIMIT_DELAY_CNT 200
#define RECEIVEBUFFERSIZE 12
+#define MAX_SPI_READ_RETRY 3
#define DEBUG_SHOW_DATA 0
static void clean_msg(struct ssp_msg *msg)
@@ -142,7 +143,7 @@ int select_irq_msg(struct ssp_data *data)
bool found = false;
u16 chLength = 0, msg_options = 0;
u8 msg_type = 0;
- int iRet = 0;
+ int iRet = 0, i = 0;
char* buffer;
char chTempBuf[4] = { -1 };
@@ -210,11 +211,24 @@ exit:
iRet = -ENOMEM;
break;
}
- iRet = spi_read(data->spi, buffer, chLength);
- if (iRet < 0)
- ssp_err("spi_read fail\n");
- else
- parse_dataframe(data, buffer, chLength);
+
+ /* FIXME : spi_read error
+ * When try to read spi ,sometimes buffer filled with 0.
+ * But spi_read dees not return error.
+ * In this case, retry spi_read again.
+ */
+ for (i = 0; i < MAX_SPI_READ_RETRY; i++) {
+ iRet = spi_read(data->spi, buffer, chLength);
+ if (iRet < 0) {
+ ssp_err("spi_read fail\n");
+ return ERROR;
+ }
+
+ if (buffer[0] != 0)
+ break;
+ }
+
+ parse_dataframe(data, buffer, chLength);
kfree(buffer);
break;
default: