summaryrefslogtreecommitdiff
path: root/drivers/net/can/dev/length.c
AgeCommit message (Collapse)Author
2021-01-27can: length: can_fd_len2dlc(): make legnth calculation readable againMarc Kleine-Budde
In commit 652562e5ff06 ("can: length: can_fd_len2dlc(): simplify length calculcation") the readability of the code degraded and became more error prone. To counteract this, partially convert that patch and replace open coded values (of the original code) with proper defines. Fixes: 652562e5ff06 ("can: length: can_fd_len2dlc(): simplify length calculcation") Cc: Vincent MAILHOL <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210118201346.79422-1-socketcan@hartkopp.net Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-01-14can: length: can_skb_get_frame_len(): introduce function to get data length ↵Vincent Mailhol
of frame in data link layer This patch adds the function can_skb_get_frame_len() which returns the length of a CAN frame on the data link layer, including Start-of-frame, Identifier, various other bits, the actual data, the CRC, the End-of-frame, the Inter frame spacing. Co-developed-by: Arunachalam Santhanam <arunachalam.santhanam@in.bosch.com> Signed-off-by: Arunachalam Santhanam <arunachalam.santhanam@in.bosch.com> Co-developed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Co-developed-by: Marc Kleine-Budde <mkl@pengutronix.de> Link: https://lore.kernel.org/r/20210111141930.693847-11-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-01-14can: length: can_fd_len2dlc(): simplify length calculcationMarc Kleine-Budde
If the length paramter in len2dlc() exceeds the size of the len2dlc array, we return 0xF. This is equal to the last 16 members of the array. This patch removes these members from the array, uses ARRAY_SIZE() for the length check, and returns CANFD_MAX_DLC (which is 0xf). Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-9-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-01-13can: length: convert to kernel coding styleMarc Kleine-Budde
This patch converts the file into the kernel coding style. Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-8-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-01-13can: dev: move length related code into seperate fileMarc Kleine-Budde
This patch moves all CAN frame length related code of the CAN device infrastructure into a separate file. Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-5-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>