From: Christophe Ricard Date: Wed, 3 Sep 2014 21:30:26 +0000 (+0200) Subject: NFC: st21nfcb: Fix logic when running into i2c read retry X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ac633ba6acb94a11b09a7ec417c72f65c6308b7a;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Signed-off-by: Samuel Ortiz --- 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, 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; }