| Age | Commit message (Collapse) | Author |
|
The existing FIELD_{GET,PREP}() macros are limited to compile-time
constants. However, it is very common to prepare or extract bitfield
elements where the bitfield mask is not a compile-time constant.
To avoid this limitation, the AT91 clock driver and several other
drivers already have their own non-const field_{prep,get}() macros.
Make them available for general use by adding them to
<linux/bitfield.h>, and improve them slightly:
1. Avoid evaluating macro parameters more than once,
2. Replace "ffs() - 1" by "__ffs()",
3. Support 64-bit use on 32-bit architectures,
4. Wire field_{get,prep}() to FIELD_{GET,PREP}() when mask is
actually constant.
This is deliberately not merged into the existing FIELD_{GET,PREP}()
macros, as people expressed the desire to keep stricter variants for
increased safety, or for performance critical paths.
Yury: use __mask within new macros.
Signed-off-by: Geert Uytterhoeven <[email protected]>
Acked-by: Alexandre Belloni <[email protected]>
Acked-by: Jonathan Cameron <[email protected]>
Acked-by: Crt Mori <[email protected]>
Acked-by: Nuno Sá <[email protected]>
Acked-by: Richard Genoud <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Yury Norov (NVIDIA) <[email protected]>
Signed-off-by: Yury Norov (NVIDIA) <[email protected]>
[Linux commit: c1c6ab80b25c8db1e2ef5ae3ac8075d2c242ae13]
Signed-off-by: Mikhail Kshevetskiy <[email protected]>
Reviewed-by: David Lechner <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
|
|
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.
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.
Signed-off-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Yury Norov (NVIDIA) <[email protected]>
[Linux commit: 2a6c045640c38a407a39cd40c3c4d8dd2fd89aa8]
Signed-off-by: Mikhail Kshevetskiy <[email protected]>
Reviewed-by: David Lechner <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Signed-off-by: Scott Wood <[email protected]>
Acked-by: Gerald Van Baren <[email protected]>
Reviewed-by: Andre Przywara <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
|
|
Sync bitfield.h header with Linux 6.15 version. Mainly is to permit the
introduction of FIELD_PREP_CONST. The bug.h header changed to
build_bug.h doesn't cause any regression as we also ship split header
similar to how it's done with in Linux.
Signed-off-by: Christian Marangi <[email protected]>
|
|
and fixed-endian
Imports Al Viro's original Linux commit 00b0c9b82663a, which contains
an in depth explanation and two fixes from Johannes Berg:
e7d4a95da86e0 "bitfield: fix *_encode_bits()",
37a3862e12382 "bitfield: add u8 helpers".
Signed-off-by: Nicolas Saenz Julienne <[email protected]>
[s.nawrocki: added empty lines between functions and macros]
Signed-off-by: Sylwester Nawrocki <[email protected]>
[mb: squash fix including byteorder.h]
Signed-off-by: Matthias Brugger <[email protected]>
|
|
Copied from Linux 4.13.
Commit log of 3e9b3112ec74 of Linux explains well why this header
is useful.
Signed-off-by: Masahiro Yamada <[email protected]>
|