Skip to content

Commit

Permalink
can: length: canfd_sanitize_len(): add function to sanitize CAN-FD da…
Browse files Browse the repository at this point in the history
…ta 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>
  • Loading branch information
Marc Kleine-Budde committed Jan 14, 2021
1 parent 652562e commit 99b7beb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/can/length.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 99b7beb

Please sign in to comment.