[PATCH v14 02/18] bitfield: Add less-checking __FIELD_{GET,PREP}()
Tom Rini
trini at konsulko.com
Thu Jul 2 15:59:18 CEST 2026
On Thu, Jul 02, 2026 at 11:53:05AM +0100, Simon Glass wrote:
> Hi Mikhail,
>
> On 2026-07-02T05:57:27, Mikhail Kshevetskiy
> <mikhail.kshevetskiy at iopsys.eu> wrote:
> > bitfield: Add less-checking __FIELD_{GET,PREP}()
> >
> > The BUILD_BUG_ON_MSG() check against '~0ull' works only with "unsigned
> > (long) long" _mask types. For constant masks, that condition is usually
> > met, as GENMASK() yields an UL value. The few places where the
> > constant mask is stored in an intermediate variable were fixed by
> > changing the variable type to u64 (see e.g. [1] and [2]).
> >
> > However, for non-constant masks, smaller unsigned types should be valid,
> > too, but currently lead to "result of comparison of constant
> > 18446744073709551615 with expression of type ... is always
> > false"-warnings with clang and W=1.
> >
> > Hence refactor the __BF_FIELD_CHECK() helper, and factor out
> > __FIELD_{GET,PREP}(). The later lack the single problematic check, but
> > are otherwise identical to FIELD_{GET,PREP}(), and are intended to be
> > used in the fully non-const variants later.
> >
> > [1] commit 5c667d5a5a3ec166 ("clk: sp7021: Adjust width of _m in
> > HWM_FIELD_PREP()")
> > [...]
> >
> > include/linux/bitfield.h | 36 ++++++++++++++++++++++++++++--------
> > 1 file changed, 28 insertions(+), 8 deletions(-)
>
> > Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
> > Link: https://git.kernel.org/torvalds/c/5c667d5a5a3ec166 [1]
> > Signed-off-by: Yury Norov (NVIDIA) <yury.norov at gmail.com>
> > Reviewed-by: David Lechner <dlechner at baylibre.com>
>
> Reviewed-by: Simon Glass <sjg at chromium.org>
>
> Please can you add your own Signed-off-by at the end of the chain?
>
> It's a bit confusing that you seem to refer to Linux commit hashes in
> the commit. So maybe this should have a Cherry-picked-from: line
> indicating it came from Linux?
We don't use Cherry-picked-from (does anything?), we just mention what
the upstream commit was.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260702/f60feef5/attachment.sig>
More information about the U-Boot
mailing list