net: can: xilinx_can: fix extended frame handling
Subsystems (5)
PATCH 1/1 net: can: xilinx_can: fix extended frame handling
Using IDR_SRR in RXFIFO_ID to test for the presence of data is only valid for standard frames. For extended frames the bit is always 1 and IDR_RTR should be used instead. This patch switches the check to use CAN_RTR_FLAG which is correctly set when reading the ID.
The patch also changes the DW1/DW2 to be read unconditionally, since this is necessary to remove the frame from the RXFIFO.
--- drivers/net/can/xilinx_can.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/can/xilinx_can.c +4 -3
@@ -509,10 +509,11 @@ static int xcan_rx(struct net_device *ndev) cf->can_id |=CAN_RTR_FLAG ; } -if (!(id_xcan &XCAN_IDR_SRR_MASK )) { - data[0 ] = priv->read_reg (priv,XCAN_RXFIFO_DW1_OFFSET ); - data[1 ] = priv->read_reg (priv,XCAN_RXFIFO_DW2_OFFSET ); +/* DW1/DW2 must always be read to remove message from RXFIFO */ + data[0 ] = priv->read_reg (priv,XCAN_RXFIFO_DW1_OFFSET ); + data[1 ] = priv->read_reg (priv,XCAN_RXFIFO_DW2_OFFSET ); +if (!(cf->can_id &CAN_RTR_FLAG )) {/* Change Xilinx CAN data format to socketCAN data format */ if (cf->can_dlc >0 ) *(__be32 *)(cf->data) =cpu_to_be32 (data[0 ]);
Signature · 1 line
2.1.0
Quoted 10 lines · Jeppe Ledet-Pedersen
Using
IDR_SRRinRXFIFO_IDto test for the presence of data is only valid for standard frames. For extended frames the bit is always 1 andIDR_RTRshould be used instead. This patch switches the check to useCAN_RTR_FLAGwhich is correctly set when reading the ID.The patch also changes the DW1/DW2 to be read unconditionally, since this is necessary to remove the frame from the RXFIFO.
Signed-off-by Jeppe Ledet-Pedersen <[email protected]>
Applied to can. Added stable on Cc.
Thanks,
Marc
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 |