summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2021-01-11 15:19:24 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-01-14 08:43:41 +0100
commit99b7beb0431a4b9728023e9169ed15af678d2c7f (patch)
tree769fdd74658e90b5e090ddfb458f674c0deab913 /include
parent652562e5ff06d27b9b83c8166cb71845a55607ad (diff)
downloadlinux-next-99b7beb0431a4b9728023e9169ed15af678d2c7f.tar.gz
can: length: canfd_sanitize_len(): add function to sanitize CAN-FD data length
The data field in CAN-FD frames have specifig frame length (0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64). This function "rounds" up a given length to the next valid CAN-FD frame length. Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/r/20210111141930.693847-10-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/can/length.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/can/length.h b/include/linux/can/length.h
index 156b9d17969a..b2313b2a0b02 100644
--- a/include/linux/can/length.h
+++ b/include/linux/can/length.h
@@ -45,4 +45,10 @@ u8 can_fd_dlc2len(u8 dlc);
/* map the sanitized data length to an appropriate data length code */
u8 can_fd_len2dlc(u8 len);
+/* map the data length to an appropriate data link layer length */
+static inline u8 canfd_sanitize_len(u8 len)
+{
+ return can_fd_dlc2len(can_fd_len2dlc(len));
+}
+
#endif /* !_CAN_LENGTH_H */