]> git.baikalelectronics.ru Git - kernel.git/commit
can: length: can_fd_len2dlc(): simplify length calculcation
authorMarc Kleine-Budde <mkl@pengutronix.de>
Mon, 11 Jan 2021 14:19:23 +0000 (15:19 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 14 Jan 2021 07:43:41 +0000 (08:43 +0100)
commit0eb5e838ff31b3d9755dc498ae0bfbc6c1d133ee
treeb04614d048d1d4fdd30bd9f088d5bef3dc6f7880
parent1d3bd71910dac6d0de11aec6b6e9d447fe2ba7c1
can: length: can_fd_len2dlc(): simplify length calculcation

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>
drivers/net/can/dev/length.c