[PATCH v14 02/18] bitfield: Add less-checking __FIELD_{GET,PREP}()
Tom Rini
trini at konsulko.com
Fri Jul 3 17:16:57 CEST 2026
On Fri, Jul 03, 2026 at 02:18:08PM +0300, Mikhail Kshevetskiy wrote:
>
> On 7/3/26 14:07, Mikhail Kshevetskiy wrote:
> > On 7/2/26 16:59, Tom Rini wrote:
> >> 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.
> > There are several commits where something similar were used:
> >
> > 86a720aafce5b2 ("mtd: Introduce mtd_block_isreserved()")
> > [scottwood: Cherry-picked from Linux 8471bb73ba10ed67]
> > Signed-off-by: Scott Wood <scottwood at freescale.com>
> >
> > 88f95bbadda89b ("libfdt: Add fdt_next_subnode() to permit easy subnode
> > iteration")
> > (Cherry-picked from dtc commit 4e76ec79)
> > Acked-by: Gerald Van Baren <vanbaren at cideas.com>
> >
> > c9fbe861a2fc1c ("arm64: dts: allwinner: h616: Add r_i2c pinctrl nodes")
> > (cherry-picked from commit 1665557aa57c2140d014d68dfe1a1f92f9baac82)
> > Reviewed-by: Andre Przywara <andre.przywara at arm.com>
> >
> > 13f3b04f61aa6a ("mtd: add mtd_ooblayout_xxx() helper functions")
> > [Linux commit: 75eb2cec251fda33c9bb716ecc372819abb9278a]
> > [masahiro: cherry-pick more code from
> > adbbc3bc827eb1f43a932d783f09ba55c8ec8379]
> > Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
> >
> > 1fb87de83dd6e7 ("mtd: nand: Support controllers with custom page")
> > [Linux commit: 3371d663bb4579f1b2003a92162edd6d90edd089]
> > Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
> >
> > and so on
Yes, and to try and be clearer, none of these are using the literal tag
"Cherry-picked-from", which is what I was noting. Tags are not "free
form".
> I think we need some policy about cherry-picked commits. It should include:
> * who should be an author of cherry-picked commits
> * should or should not be original Signed-off-by/Reviewed-by/Acked-by
> be kept * how original commit should be referred
Yes, this has been done at:
https://docs.u-boot-project.org/en/latest/develop/sending_patches.html#attributing-code-copyrights-signing
--
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/20260703/603cdb9d/attachment.sig>
More information about the U-Boot
mailing list