Re: [net-next 09/17] can: length: can_fd_len2dlc(): simplify length calculcation
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2021-01-15 13:52:39
Attachments
- signature.asc [application/pgp-signature] 488 bytes
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2021-01-15 13:52:39
On 1/15/21 2:20 PM, Vincent MAILHOL wrote:
/* map the data length to an appropriate data length code */
u8 can_fd_len2dlc(u8 len)
{
switch(len) {
case 0 ... 8:
return len;
case 9 ... 12:
return 9;
case 13 ... 16:
return 10;
case 17 ... 20:
return 11;
case 21 ... 24:
return 12;
case 25 ... 32:
return 13;
case 33 ... 48:
return 14;
case 49 ... 64:
default:
return CANFD_MAX_DLC;
}
}
And we will just leave the optimizations in the hand of the compiler.I've already tried this. It results in a longer object file on ARM, even if you remove the array.... Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |