summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRakesh Goyal <rgoyal@nvidia.com>2012-03-09 11:43:57 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-03-09 11:43:57 -0800
commiteee41c4238e2a6101d2b701184ba7a6b4ea60339 (patch)
tree75046d30fce14b825477918f38814a055a81fced
parentffc175ebc90780a9812ca51bad168c543cbaa7ca (diff)
parentda7d267e855affe83c0bc5958292fe74d6e27d7e (diff)
downloadexternal_libnfc-nxp-eee41c4238e2a6101d2b701184ba7a6b4ea60339.zip
external_libnfc-nxp-eee41c4238e2a6101d2b701184ba7a6b4ea60339.tar.gz
external_libnfc-nxp-eee41c4238e2a6101d2b701184ba7a6b4ea60339.tar.bz2
am da7d267e: am 3f791036: nfc-hal: generalize error handling in Reader thread.
* commit 'da7d267e855affe83c0bc5958292fe74d6e27d7e': 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 4086434..dbc0976 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 {
ALOGE("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;