浏览代码

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>
Christophe Ricard 11 年之前
父节点
当前提交
4294e32040
共有 2 个文件被更改,包括 8 次插入15 次删除
  1. 4 15
      drivers/nfc/st21nfcb/i2c.c
  2. 4 0
      drivers/nfc/st21nfcb/ndlc.h

+ 4 - 15
drivers/nfc/st21nfcb/i2c.c

@@ -55,12 +55,6 @@ struct st21nfcb_i2c_phy {
 	unsigned int irq_polarity;
 	unsigned int irq_polarity;
 
 
 	int powered;
 	int powered;
-
-	/*
-	 * < 0 if hardware error occured (e.g. i2c err)
-	 * and prevents normal operation.
-	 */
-	int hard_fault;
 };
 };
 
 
 #define I2C_DUMP_SKB(info, skb)					\
 #define I2C_DUMP_SKB(info, skb)					\
@@ -114,8 +108,8 @@ static int st21nfcb_nci_i2c_write(void *phy_id, struct sk_buff *skb)
 
 
 	I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb);
 	I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb);
 
 
-	if (phy->hard_fault != 0)
-		return phy->hard_fault;
+	if (phy->ndlc->hard_fault != 0)
+		return phy->ndlc->hard_fault;
 
 
 	r = i2c_master_send(client, skb->data, skb->len);
 	r = i2c_master_send(client, skb->data, skb->len);
 	if (r == -EREMOTEIO) {  /* Retry, chip was in standby */
 	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)
 	client = phy->i2c_dev;
 	client = phy->i2c_dev;
 	dev_dbg(&client->dev, "IRQ\n");
 	dev_dbg(&client->dev, "IRQ\n");
 
 
-	if (phy->hard_fault)
+	if (phy->ndlc->hard_fault)
 		return IRQ_HANDLED;
 		return IRQ_HANDLED;
 
 
 	if (!phy->powered) {
 	if (!phy->powered) {
@@ -227,13 +221,8 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id)
 	}
 	}
 
 
 	r = st21nfcb_nci_i2c_read(phy, &skb);
 	r = st21nfcb_nci_i2c_read(phy, &skb);
-	if (r == -EREMOTEIO) {
-		phy->hard_fault = r;
-		ndlc_recv(phy->ndlc, NULL);
-		return IRQ_HANDLED;
-	} else if (r == -ENOMEM || r == -EBADMSG) {
+	if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG)
 		return IRQ_HANDLED;
 		return IRQ_HANDLED;
-	}
 
 
 	ndlc_recv(phy->ndlc, skb);
 	ndlc_recv(phy->ndlc, skb);
 
 

+ 4 - 0
drivers/nfc/st21nfcb/ndlc.h

@@ -42,6 +42,10 @@ struct llt_ndlc {
 
 
 	struct device *dev;
 	struct device *dev;
 
 
+	/*
+	 * < 0 if hardware error occured
+	 * and prevents normal operation.
+	 */
 	int hard_fault;
 	int hard_fault;
 };
 };