From: Luu An Phu <hidden> Date: 2017-12-19 08:50:32
From: "phu.luuan" <redacted>
flexcan_start_xmit should write data to register when can_dlc > 4.
Because can_dlc is data length and it has value from 1 to 8. But CAN data
index has value from 0 to 7. So in case we have data in cf->data[4],
the can_dlc has value is more than 4.
Signed-off-by: Luu An Phu <redacted>
---
drivers/net/can/flexcan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
From: Oliver Hartkopp <socketcan@hartkopp.net> Date: 2017-12-25 11:38:11
This patch looks wrong to me.
On 12/19/2017 09:40 AM, Luu An Phu wrote:
From: "phu.luuan" <redacted>
flexcan_start_xmit should write data to register when can_dlc > 4.
Because can_dlc is data length and it has value from 1 to 8.
No. can_dlc can contain values from 0 to 8. Even 0 is a valid DLC.
quoted hunk
But CAN data
index has value from 0 to 7. So in case we have data in cf->data[4],
the can_dlc has value is more than 4.
Signed-off-by: Luu An Phu <redacted>
---
drivers/net/can/flexcan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
This is correct as data[0 .. 3] are filled from the code above. And if can_dlc is greater than 3 (== 4 .. 8) the following 4 bytes are copied into the registers.
So everything is correct with the current code.
quoted hunk
+ if (cf->can_dlc > 4) { data = be32_to_cpup((__be32 *)&cf->data[4]); flexcan_write(data, &priv->tx_mb->data[1]); }
From: Oliver Hartkopp <socketcan@hartkopp.net> Date: 2017-12-25 11:58:59
Answering myself after reading my own comment once more:
In fact the code fix seems to be correct but the commit comment was completely wrong which lead to my answer ...
can_dlc can hold values from 0 .. 8.
The first 4 bytes are placed in data[0..3]. When we have more(!) than 4 bytes in can_dlc, the bytes 5..8 are placed in data[4..7].
The good thing was, that the current check was more conservative than your suggestion so that we did not detect any data loss.
Please send a V2 patch with corrected commit message.
Thanks,
Oliver
ps.
A one-liner contribution like this tiny fix usually does not lead to an attribution in the copyrights. Your contribution is already perfectly recorded by the Signed-off-by tag.