Skip to contentSkip to conversation

can: fix SJA1000 dlc for RTR packets

PATCH Applied Kurt Van Dijck 3 participants 3 messages May 2, 2011 – May 5, 2011 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 can: fix SJA1000 dlc for RTR packets

RTR frames do have a valid data length code on CAN. The driver for SJA1000 did not handle that situation properly.

---
 drivers/net/can/sja1000/sja1000.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/can/sja1000/sja1000.c +1 -1
index a358ea9..f501bba 100644
@@ -346,10 +346,10 @@ static void sja1000_rx(struct net_device *dev)
 		    | (priv->read_reg(priv, REG_ID2) >> 5);
 	}
 
+	cf->can_dlc = get_can_dlc(fi & 0x0F);
 	if (fi & FI_RTR) {
 		id |= CAN_RTR_FLAG;
 	} else {
-		cf->can_dlc = get_can_dlc(fi & 0x0F);
 		for (i = 0; i < cf->can_dlc; i++)
 			cf->data[i] = priv->read_reg(priv, dreg++);
 	}

A message that is not in the archive (sent off-list or not yet received): 20110502145048.GF338-MxZ6Iy/zr/UdbCeoMzGj59i2O/[email protected]

#2 lore raw
Quoted 2 lines · Kurt Van Dijck

RTR frames do have a valid data length code on CAN. The driver for SJA1000 did not handle that situation properly.

Looks good!

Quoted 2 lines
Quoted 24 lines
---
 drivers/net/can/sja1000/sja1000.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/can/sja1000/sja1000.c +1 -1
index a358ea9..f501bba 100644
@@ -346,10 +346,10 @@ static void sja1000_rx(struct net_device *dev)
 		    | (priv->read_reg(priv, REG_ID2) >> 5);
 	}
 
+	cf->can_dlc = get_can_dlc(fi & 0x0F);
 	if (fi & FI_RTR) {
 		id |= CAN_RTR_FLAG;
 	} else {
-		cf->can_dlc = get_can_dlc(fi & 0x0F);
 		for (i = 0; i < cf->can_dlc; i++)
 			cf->data[i] = priv->read_reg(priv, dreg++);
 	}

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

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