aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2014-09-03 17:30:26 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2014-09-07 18:29:50 -0400
commitac633ba6acb94a11b09a7ec417c72f65c6308b7a (patch)
treef1406c1dac972c3911d7f5666155c8332b7b6928
parent56f1ffcccd784672654918f9214979b4918c2544 (diff)
NFC: st21nfcb: Fix logic when running into i2c read retry
When retrying to read the NCI header, the CLF might not be available the first time. However it may not be successful the second time and this may cause an error in the function. Enforce the retrieve data length is as expected. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/st21nfcb/i2c.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c
index ff67bbf53011..02fac319dfa9 100644
--- a/drivers/nfc/st21nfcb/i2c.c
+++ b/drivers/nfc/st21nfcb/i2c.c
@@ -168,7 +168,9 @@ static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy,
168 if (r == -EREMOTEIO) { /* Retry, chip was in standby */ 168 if (r == -EREMOTEIO) { /* Retry, chip was in standby */
169 usleep_range(1000, 4000); 169 usleep_range(1000, 4000);
170 r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE); 170 r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
171 } else if (r != ST21NFCB_NCI_I2C_MIN_SIZE) { 171 }
172
173 if (r != ST21NFCB_NCI_I2C_MIN_SIZE) {
172 nfc_err(&client->dev, "cannot read ndlc & nci header\n"); 174 nfc_err(&client->dev, "cannot read ndlc & nci header\n");
173 return -EREMOTEIO; 175 return -EREMOTEIO;
174 } 176 }