Re: [PATCH 2/2] can: esd_usb: Add support for esd CAN-USB/3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue. 9 May 2023 at 16:12, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote:
> On 09.05.2023 10:28:13, Vincent MAILHOL wrote:
> > > > And because hdr.len is initially 3, hdr.len becomes 5. Right? Shouldn't it be 8?
> > >
> > > It might be a little confusing, but I think it's fine.
> > > hdr.len is given in units of longwords (4 bytes each)! Therefore we
> > > have 12 bytes (the initial 3 longwords) for struct tx_msg before
> > > tx_msg.data[].
> > > Than (8 + 3)/4=2 gives us 2 additional longwords for the 8 data bytes.
> > > So that 3+2=5 (equal to 20 bytes) should be ok.
>
> I think the term longword is more commonly used in non-Unix operating
> systems :)
>
> > OK. So you want to round up the length to the next sizeof(long) multiple, right?
> >
> > First, sizeof(long) being platform specific, you need to declare a
> > macro to make your intent explicit.
> >
> > /* Size of a long int on esd devices */
> > #define USB_ESD_SIZEOF_LONG 4
> >
> > Please test, but for what I understand, below line is an equivalent
> > and a more readable way to achieve your goal:
> >
> >           msg->hdr.len = DIV_ROUND_UP(cf->len, USB_ESD_SIZEOF_LONG);
>
> use "sizeof(u32)"

Marc is right, forget about USB_ESD_SIZEOF_LONG. sizeof(u32) does the
job better.



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux