summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRakesh Goyal <rgoyal@nvidia.com>2012-03-09 11:37:11 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-03-09 11:37:11 -0800
commitda7d267e855affe83c0bc5958292fe74d6e27d7e (patch)
tree3569bcf55eb229078126821864bdcf9dc8e6748f
parentbbda017196474931e686669f0b6bc749f6dc1b0a (diff)
parent3f791036276b6f535ad253dd25650fad60c72695 (diff)
downloadexternal_libnfc-nxp-da7d267e855affe83c0bc5958292fe74d6e27d7e.zip
external_libnfc-nxp-da7d267e855affe83c0bc5958292fe74d6e27d7e.tar.gz
external_libnfc-nxp-da7d267e855affe83c0bc5958292fe74d6e27d7e.tar.bz2
am 3f791036: nfc-hal: generalize error handling in Reader thread.
* commit '3f791036276b6f535ad253dd25650fad60c72695': nfc-hal: generalize error handling in Reader thread.
-rw-r--r--Linux_x86/phDal4Nfc.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/Linux_x86/phDal4Nfc.c b/Linux_x86/phDal4Nfc.c
index 3e031f1..ae2d3bf 100644
--- a/Linux_x86/phDal4Nfc.c
+++ b/Linux_x86/phDal4Nfc.c
@@ -718,8 +718,17 @@ int phDal4Nfc_ReaderThread(void * pArg)
int i;
int i2c_error_count;
int i2c_workaround;
+ int i2c_device_address = 0x57;
if (gDalContext.pDev != NULL) {
i2c_workaround = gDalContext.pDev->enable_i2c_workaround;
+ if (gDalContext.pDev->i2c_device_address) {
+ i2c_device_address = gDalContext.pDev->i2c_device_address;
+ if (i2c_workaround && i2c_device_address < 32)
+ {
+ LOGE("i2c_device_address not set to valid value");
+ return NFCSTATUS_FAILED;
+ }
+ }
} else {
LOGE("gDalContext.pDev is not set");
return NFCSTATUS_FAILED;
@@ -758,15 +767,17 @@ retry:
/* Wait for IRQ !!! */
gReadWriteContext.nNbOfBytesRead = gLinkFunc.read(gReadWriteContext.pReadBuffer, gReadWriteContext.nNbOfBytesToRead);
- /* Reading the value 0x57 indicates a HW I2C error at I2C address 0x57
+ /* A read value equal to the i2c_device_address indicates a HW I2C error at I2C address i2c_device_address
* (pn544). There should not be false positives because a read of length 1
- * must be a HCI length read, and a length of 0x57 is impossible (max is 33).
+ * must be a HCI length read, and a length of i2c_device_address is impossible (max is 33).
*/
- if(i2c_workaround && gReadWriteContext.nNbOfBytesToRead == 1 &&
- gReadWriteContext.pReadBuffer[0] == 0x57)
+ if (i2c_workaround && gReadWriteContext.nNbOfBytesToRead == 1 &&
+ gReadWriteContext.pReadBuffer[0] == i2c_device_address)
{
i2c_error_count++;
- DAL_DEBUG("RX Thread Read 0x57 %d times\n", i2c_error_count);
+ DAL_DEBUG("RX Thread Read 0x%02x ", i2c_device_address);
+ DAL_DEBUG("%d times\n", i2c_error_count);
+
if (i2c_error_count < 5) {
usleep(2000);
goto retry;