]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFC: st21nfcb: Retry i2c_master_send if it returns a negative value
authorChristophe Ricard <christophe.ricard@gmail.com>
Tue, 31 Mar 2015 06:02:15 +0000 (08:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 20:01:53 +0000 (22:01 +0200)
commit d4a41d10b2cb5890aeda6b2912973b2a754b05b1 upstream.

i2c_master_send may return many negative values different than
-EREMOTEIO.
In case an i2c transaction is NACK'ed, on raspberry pi B+
kernel 3.18, -EIO is generated instead.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nfc/st21nfcb/i2c.c

index 01ba865863ee93dfb6843ae26d182efa288b6284..b5eb3754578c2b38a34a002a7a4e3281b5862219 100644 (file)
@@ -109,7 +109,7 @@ static int st21nfcb_nci_i2c_write(void *phy_id, struct sk_buff *skb)
                return phy->ndlc->hard_fault;
 
        r = i2c_master_send(client, skb->data, skb->len);
-       if (r == -EREMOTEIO) {  /* Retry, chip was in standby */
+       if (r < 0) {  /* Retry, chip was in standby */
                usleep_range(1000, 4000);
                r = i2c_master_send(client, skb->data, skb->len);
        }
@@ -148,7 +148,7 @@ static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy,
        struct i2c_client *client = phy->i2c_dev;
 
        r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
-       if (r == -EREMOTEIO) {  /* Retry, chip was in standby */
+       if (r < 0) {  /* Retry, chip was in standby */
                usleep_range(1000, 4000);
                r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
        }