drivers: can: rcar: only copy frame data for non-RTR frames

Only copy frame data for non-RTR frames as RTR frames do not carry any
data.

Fixes: #57002

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2023-10-11 13:34:16 +02:00 committed by Johan Hedberg
parent 443847f0f6
commit bb4a22fdbc

View file

@ -399,10 +399,6 @@ static void can_rcar_rx_isr(const struct device *dev)
frame.id = (val & RCAR_CAN_MB_SID_MASK) >> RCAR_CAN_MB_SID_SHIFT;
}
if (val & RCAR_CAN_MB_RTR) {
frame.flags |= CAN_FRAME_RTR;
}
frame.dlc = sys_read16(config->reg_addr +
RCAR_CAN_MB_60 + RCAR_CAN_MB_DLC_OFFSET) & 0xF;
@ -413,9 +409,13 @@ static void can_rcar_rx_isr(const struct device *dev)
frame.dlc = CAN_MAX_DLC;
}
for (i = 0; i < frame.dlc; i++) {
frame.data[i] = sys_read8(config->reg_addr +
RCAR_CAN_MB_60 + RCAR_CAN_MB_DATA_OFFSET + i);
if (val & RCAR_CAN_MB_RTR) {
frame.flags |= CAN_FRAME_RTR;
} else {
for (i = 0; i < frame.dlc; i++) {
frame.data[i] = sys_read8(config->reg_addr +
RCAR_CAN_MB_60 + RCAR_CAN_MB_DATA_OFFSET + i);
}
}
#if defined(CONFIG_CAN_RX_TIMESTAMP)
/* read upper byte */
@ -914,9 +914,11 @@ static int can_rcar_send(const struct device *dev, const struct can_frame *frame
sys_write16(frame->dlc, config->reg_addr
+ RCAR_CAN_MB_56 + RCAR_CAN_MB_DLC_OFFSET);
for (i = 0; i < frame->dlc; i++) {
sys_write8(frame->data[i], config->reg_addr
+ RCAR_CAN_MB_56 + RCAR_CAN_MB_DATA_OFFSET + i);
if ((frame->flags & CAN_FRAME_RTR) == 0) {
for (i = 0; i < frame->dlc; i++) {
sys_write8(frame->data[i], config->reg_addr
+ RCAR_CAN_MB_56 + RCAR_CAN_MB_DATA_OFFSET + i);
}
}
compiler_barrier();