[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMZ6RqKPbv+mMY0W4P9YR-HoiRAMg7VZgSrs2emnAOrBQyoWxg@mail.gmail.com>
Date: Tue, 9 May 2023 17:25:37 +0900
From: Vincent MAILHOL <mailhol.vincent@...adoo.fr>
To: Marc Kleine-Budde <mkl@...gutronix.de>
Cc: Frank Jungclaus <Frank.Jungclaus@....eu>, Stefan Mätje <Stefan.Maetje@....eu>,
"linux-can@...r.kernel.org" <linux-can@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>, "wg@...ndegger.com" <wg@...ndegger.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] can: esd_usb: Add support for esd CAN-USB/3
On Tue. 9 May 2023 at 16:12, Marc Kleine-Budde <mkl@...gutronix.de> 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.
Powered by blists - more mailing lists