Browse Source

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>
Christophe Ricard 11 years ago
parent
commit
ac633ba6ac
1 changed files with 3 additions and 1 deletions
  1. 3 1
      drivers/nfc/st21nfcb/i2c.c

+ 3 - 1
drivers/nfc/st21nfcb/i2c.c

@@ -168,7 +168,9 @@ static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy,
 	if (r == -EREMOTEIO) {  /* Retry, chip was in standby */
 		usleep_range(1000, 4000);
 		r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
-	} else if (r != ST21NFCB_NCI_I2C_MIN_SIZE) {
+	}
+
+	if (r != ST21NFCB_NCI_I2C_MIN_SIZE) {
 		nfc_err(&client->dev, "cannot read ndlc & nci header\n");
 		return -EREMOTEIO;
 	}