Skip to contentSkip to conversation

can: EG20T PCH: Fix incorrect return processing

PATCH Superseded Tomoya MORINAGA 2 participants 2 messages Nov 19, 2010

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 16/17 can: EG20T PCH: Fix incorrect return processing

Fix incorrect return processing

---
 drivers/net/can/pch_can.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/net/can/pch_can.c +12 -8
index c612a99..48f4a2e 100644
@@ -589,10 +589,12 @@ static irqreturn_t pch_can_interrupt(int irq, void *dev_id)
 	struct net_device *ndev = (struct net_device *)dev_id;
 	struct pch_can_priv *priv = netdev_priv(ndev);
 
-	pch_can_set_int_enables(priv, PCH_CAN_NONE);
-	napi_schedule(&priv->napi);
-
-	return IRQ_HANDLED;
+	if ((pch_can_int_pending(priv) > 0) && (dev_id != NULL)) {
+		pch_can_set_int_enables(priv, PCH_CAN_NONE);
+		napi_schedule(&priv->napi);
+		return IRQ_HANDLED;
+	}
+	return IRQ_NONE;
 }
 
 static void pch_fifo_thresh(struct pch_can_priv *priv, int obj_id)
@@ -674,7 +676,7 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 obj_num, int quota)
 		if (reg & PCH_IF_MCONT_MSGLOST) {
 			rtn = pch_can_rx_msg_lost(ndev, obj_num);
 			if (!rtn)
-				return rtn;
+				return rcv_pkts;
 			rcv_pkts++;
 			quota--;
 			obj_num++;
@@ -777,10 +779,12 @@ static int pch_can_poll(struct napi_struct *napi, int quota)
 		goto end;
 
 	if ((int_stat >= PCH_RX_OBJ_START) && (int_stat <= PCH_RX_OBJ_END)) {
-		rcv_pkts += pch_can_rx_normal(ndev, int_stat, quota);
-		quota -= rcv_pkts;
-		if (quota < 0)
+		rcv_pkts = pch_can_rx_normal(ndev, int_stat, quota);
+		if (rcv_pkts < 0) {
+			rcv_pkts = 0;
 			goto end;
+		}
+		quota -= rcv_pkts;
 	} else if ((int_stat >= PCH_TX_OBJ_START) &&
 		   (int_stat <= PCH_TX_OBJ_END)) {
 		/* Handle transmission interrupt */
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 1 line · Tomoya MORINAGA

Fix incorrect return processing

The description is correct. But you change several things that have nothing to do. The frist hunk fixes shared irq handlers, the others the quota calculation in the napi handler.

Marc

Quoted 11 lines
---
 drivers/net/can/pch_can.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/net/can/pch_can.c +0 -0
index c612a99..48f4a2e 100644

drivers/net/can/pch_can.c static irqreturn_t pch_can_interrupt(int irq, void *dev_id) · line 592

Quoted 8 lines
drivers/net/can/pch_can.c +1 -4
@@ -589,10 +589,12 @@ static irqreturn_t pch_can_interrupt(int irq, void *dev_id)
 	struct net_device *ndev = (struct net_device *)dev_id;
 	struct pch_can_priv *priv = netdev_priv(ndev);
 
-	pch_can_set_int_enables(priv, PCH_CAN_NONE);
-	napi_schedule(&priv->napi);
-
-	return IRQ_HANDLED;
+	if ((pch_can_int_pending(priv) > 0) && (dev_id != NULL)) {

dev_id is always != NULL, because you registered your IRQ handler with it. (BTW: dev_id has already been dereferenced in netdev_priv(), so if this code is executed, dev_if is != NULL)

Just write:

if (!pch_can_int_pending(priv))

	return IRQ_NONE;
Quoted 18 lines
drivers/net/can/pch_can.c +6 -1
+		pch_can_set_int_enables(priv, PCH_CAN_NONE);
+		napi_schedule(&priv->napi);
+		return IRQ_HANDLED;
+	}
+	return IRQ_NONE;
 }
 
 static void pch_fifo_thresh(struct pch_can_priv *priv, int obj_id)
@@ -674,7 +676,7 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 obj_num, int quota)
 		if (reg & PCH_IF_MCONT_MSGLOST) {
 			rtn = pch_can_rx_msg_lost(ndev, obj_num);
 			if (!rtn)
-				return rtn;
+				return rcv_pkts;
 			rcv_pkts++;
 			quota--;
 			obj_num++;

drivers/net/can/pch_can.c static int pch_can_poll(struct napi_struct *napi, int quota) · line 782

Quoted 7 lines
drivers/net/can/pch_can.c +1 -3
@@ -777,10 +779,12 @@ static int pch_can_poll(struct napi_struct *napi, int quota)
 		goto end;
 
 	if ((int_stat >= PCH_RX_OBJ_START) && (int_stat <= PCH_RX_OBJ_END)) {
-		rcv_pkts += pch_can_rx_normal(ndev, int_stat, quota);
-		quota -= rcv_pkts;
-		if (quota < 0)
+		rcv_pkts = pch_can_rx_normal(ndev, int_stat, quota);

maybe it's better to rx as much packages in rx_normal as possible and not return if you failed to alloc a can_frame.

Quoted 8 lines
drivers/net/can/pch_can.c +4 -0
+		if (rcv_pkts < 0) {
+			rcv_pkts = 0;
 			goto end;
+		}
+		quota -= rcv_pkts;
 	} else if ((int_stat >= PCH_TX_OBJ_START) &&
 		   (int_stat <= PCH_TX_OBJ_END)) {
 		/* Handle transmission interrupt */
Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core