[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a3SxeON4m8bjehjNKtX_T75udDFEEXnQ4j2KDe3vKz5vA@mail.gmail.com>
Date: Fri, 19 Jan 2018 21:42:17 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Serge Semin <fancer.lancer@...il.com>
Cc: jdmason@...zu.us, Dave Jiang <dave.jiang@...el.com>,
Allen.Hubbe@...il.com, "Hook, Gary" <gary.hook@....com>,
Sergey.Semin@...latforms.ru, linux-ntb@...glegroups.com,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] NTB: ntb_perf: fix cast to restricted __le32
On Fri, Jan 19, 2018 at 6:30 PM, Serge Semin <fancer.lancer@...il.com> wrote:
> Sparse is whining about the u32 and __le32 mixed usage in the
> driver.
>
> drivers/ntb/test/ntb_perf.c:288:21: warning: cast to restricted __le32
> drivers/ntb/test/ntb_perf.c:295:37: warning: incorrect type in argument 4 (different base types)
> drivers/ntb/test/ntb_perf.c:295:37: expected unsigned int [unsigned] [usertype] val
> drivers/ntb/test/ntb_perf.c:295:37: got restricted __le32 [usertype] <noident>
> ...
>
> The NTB API can't be changed so ntb_spad_*() methods
> would return either pure __le32 or __be32, since the scratchpad
> data can have arbitrary endianness in general. In this case we
> need to forcibly cast all the u32 to be __le32 and vise-versa
> where it's supposed to be in accordance with the driver logic.
>
There's got to be a better way to do this than sprinkling lots of __force
typecasts throughout the code.
It looks like all those casts are about
ntb_peer_spad_read()/ntb_peer_msg_write() calls, so why not change
those function prototypes to work on __le32 types?
There should also be some form of documentation regarding why you
need to swap the data twice, since all the ntb drivers later end up
doing another cpu_to_le32() on the little-endian data.
Arnd
Powered by blists - more mailing lists