Thread (32 messages) 32 messages, 3 authors, 2021-01-17

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

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 |

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help