Re: [PATCH v2 2/6] can: dev: add a helper function

2020-10-01 Thread Marc Kleine-Budde
On 10/1/20 5:45 PM, Vincent Mailhol wrote: >>> +static inline int get_can_len(struct sk_buff *skb) >> >> make this return an u8 >> make the skb const >> >>> +{ >>> + struct canfd_frame *cf =3D (struct canfd_frame *)skb->data; >> >> const >> >>> + >>> + if (can_is_canfd_skb(skb)) >>> +

Re: [PATCH v2 2/6] can: dev: add a helper function

2020-10-01 Thread Vincent Mailhol
> > +static inline int get_can_len(struct sk_buff *skb) > > make this return an u8 > make the skb const > > > +{ > > + struct canfd_frame *cf =3D (struct canfd_frame *)skb->data; > > const > > > + > > + if (can_is_canfd_skb(skb)) > > + return min_t(__u8, cf->len, CANFD_MAX_DLEN);

Re: [PATCH v2 2/6] can: dev: add a helper function to get the correct length of Classical frames

2020-09-30 Thread Marc Kleine-Budde
On 9/30/20 4:45 PM, Vincent Mailhol wrote: > In classical CAN, the length of the data (i.e. CAN payload) is not > always equal to the DLC! If the frame is a Remote Transmission Request > (RTR), data length is always zero regardless of DLC value and else, if > the DLC is greater than 8, the length i

[PATCH v2 2/6] can: dev: add a helper function to get the correct length of Classical frames

2020-09-30 Thread Vincent Mailhol
In classical CAN, the length of the data (i.e. CAN payload) is not always equal to the DLC! If the frame is a Remote Transmission Request (RTR), data length is always zero regardless of DLC value and else, if the DLC is greater than 8, the length is 8. Contrary to common belief, ISO 11898-1 Chapter