diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2014-09-13 04:28:47 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-09-23 20:02:23 -0400 |
commit | 4294e32040b5142824f420d4a3ae604b92f1d1b5 (patch) | |
tree | 8664b73eb8e97b974c209c75c5084cc1a16fa6b9 /drivers/nfc | |
parent | f06d87a5b5a01fced0493651a12c002906d0bb69 (diff) |
NFC: st21nfcb: Fix improper management of -EREMOTEIO error code.
On st21nfcb the irq line might be kept to active state because of other
interfaces activity. This may generate i2c read tentative resulting in
i2c NACK.
This fix will currently let NDLC upper layer to decide when it is relevent
to signal to the physical layer when the chip as muted.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/st21nfcb/i2c.c | 19 | ||||
-rw-r--r-- | drivers/nfc/st21nfcb/ndlc.h | 4 |
2 files changed, 8 insertions, 15 deletions
diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c index 83423462663d..0b8f72176de0 100644 --- a/drivers/nfc/st21nfcb/i2c.c +++ b/drivers/nfc/st21nfcb/i2c.c | |||
@@ -55,12 +55,6 @@ struct st21nfcb_i2c_phy { | |||
55 | unsigned int irq_polarity; | 55 | unsigned int irq_polarity; |
56 | 56 | ||
57 | int powered; | 57 | int powered; |
58 | |||
59 | /* | ||
60 | * < 0 if hardware error occured (e.g. i2c err) | ||
61 | * and prevents normal operation. | ||
62 | */ | ||
63 | int hard_fault; | ||
64 | }; | 58 | }; |
65 | 59 | ||
66 | #define I2C_DUMP_SKB(info, skb) \ | 60 | #define I2C_DUMP_SKB(info, skb) \ |
@@ -114,8 +108,8 @@ static int st21nfcb_nci_i2c_write(void *phy_id, struct sk_buff *skb) | |||
114 | 108 | ||
115 | I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb); | 109 | I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb); |
116 | 110 | ||
117 | if (phy->hard_fault != 0) | 111 | if (phy->ndlc->hard_fault != 0) |
118 | return phy->hard_fault; | 112 | return phy->ndlc->hard_fault; |
119 | 113 | ||
120 | r = i2c_master_send(client, skb->data, skb->len); | 114 | r = i2c_master_send(client, skb->data, skb->len); |
121 | if (r == -EREMOTEIO) { /* Retry, chip was in standby */ | 115 | if (r == -EREMOTEIO) { /* Retry, chip was in standby */ |
@@ -218,7 +212,7 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id) | |||
218 | client = phy->i2c_dev; | 212 | client = phy->i2c_dev; |
219 | dev_dbg(&client->dev, "IRQ\n"); | 213 | dev_dbg(&client->dev, "IRQ\n"); |
220 | 214 | ||
221 | if (phy->hard_fault) | 215 | if (phy->ndlc->hard_fault) |
222 | return IRQ_HANDLED; | 216 | return IRQ_HANDLED; |
223 | 217 | ||
224 | if (!phy->powered) { | 218 | if (!phy->powered) { |
@@ -227,13 +221,8 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id) | |||
227 | } | 221 | } |
228 | 222 | ||
229 | r = st21nfcb_nci_i2c_read(phy, &skb); | 223 | r = st21nfcb_nci_i2c_read(phy, &skb); |
230 | if (r == -EREMOTEIO) { | 224 | if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG) |
231 | phy->hard_fault = r; | ||
232 | ndlc_recv(phy->ndlc, NULL); | ||
233 | return IRQ_HANDLED; | ||
234 | } else if (r == -ENOMEM || r == -EBADMSG) { | ||
235 | return IRQ_HANDLED; | 225 | return IRQ_HANDLED; |
236 | } | ||
237 | 226 | ||
238 | ndlc_recv(phy->ndlc, skb); | 227 | ndlc_recv(phy->ndlc, skb); |
239 | 228 | ||
diff --git a/drivers/nfc/st21nfcb/ndlc.h b/drivers/nfc/st21nfcb/ndlc.h index c30a2f0faa5f..b28140e0cd78 100644 --- a/drivers/nfc/st21nfcb/ndlc.h +++ b/drivers/nfc/st21nfcb/ndlc.h | |||
@@ -42,6 +42,10 @@ struct llt_ndlc { | |||
42 | 42 | ||
43 | struct device *dev; | 43 | struct device *dev; |
44 | 44 | ||
45 | /* | ||
46 | * < 0 if hardware error occured | ||
47 | * and prevents normal operation. | ||
48 | */ | ||
45 | int hard_fault; | 49 | int hard_fault; |
46 | }; | 50 | }; |
47 | 51 | ||