<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/include/linux/bitfield.h, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/u-boot.git/atom/include/linux/bitfield.h?h=main</id>
<link rel='self' href='http://cgit.235523.xyz/u-boot.git/atom/include/linux/bitfield.h?h=main'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<updated>2026-07-08T19:29:18Z</updated>
<entry>
<title>bitfield: Add non-constant field_{prep, get}() helpers</title>
<updated>2026-07-08T19:29:18Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert+renesas@glider.be</email>
</author>
<published>2026-07-03T11:56:12Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=da10fca9b062bde09144d65a0559676c658ac0ae'/>
<id>urn:sha1:da10fca9b062bde09144d65a0559676c658ac0ae</id>
<content type='text'>
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
&lt;linux/bitfield.h&gt;, 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 &lt;geert+renesas@glider.be&gt;
Acked-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Acked-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Acked-by: Crt Mori &lt;cmo@melexis.com&gt;
Acked-by: Nuno Sá &lt;nuno.sa@analog.com&gt;
Acked-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Reviewed-by: Andy Shevchenko &lt;andriy.shevchenko@intel.com&gt;
Reviewed-by: Yury Norov (NVIDIA) &lt;yury.norov@gmail.com&gt;
Signed-off-by: Yury Norov (NVIDIA) &lt;yury.norov@gmail.com&gt;
[Linux commit: c1c6ab80b25c8db1e2ef5ae3ac8075d2c242ae13]
Signed-off-by: Mikhail Kshevetskiy &lt;mikhail.kshevetskiy@iopsys.eu&gt;
Reviewed-by: David Lechner &lt;dlechner@baylibre.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
</entry>
<entry>
<title>bitfield: Add less-checking __FIELD_{GET,PREP}()</title>
<updated>2026-07-08T19:29:18Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert+renesas@glider.be</email>
</author>
<published>2026-07-03T11:56:11Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=9c10cba536874641bbc70a53588d6a59c9292e2e'/>
<id>urn:sha1:9c10cba536874641bbc70a53588d6a59c9292e2e</id>
<content type='text'>
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 &lt;geert+renesas@glider.be&gt;
Signed-off-by: Yury Norov (NVIDIA) &lt;yury.norov@gmail.com&gt;
[Linux commit: 2a6c045640c38a407a39cd40c3c4d8dd2fd89aa8]
Signed-off-by: Mikhail Kshevetskiy &lt;mikhail.kshevetskiy@iopsys.eu&gt;
Reviewed-by: David Lechner &lt;dlechner@baylibre.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
Signed-off-by: Scott Wood &lt;scottwood@freescale.com&gt;
Acked-by: Gerald Van Baren &lt;vanbaren@cideas.com&gt;
Reviewed-by: Andre Przywara &lt;andre.przywara@arm.com&gt;
Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
<entry>
<title>linux/bitfield.h: sync &lt;linux/bitfield.h&gt; from Linux 6.15</title>
<updated>2025-06-14T15:11:10Z</updated>
<author>
<name>Christian Marangi</name>
<email>ansuelsmth@gmail.com</email>
</author>
<published>2025-06-07T21:11:20Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=01cc7046ad2a1537791cda5175bce281f0a0acfc'/>
<id>urn:sha1:01cc7046ad2a1537791cda5175bce281f0a0acfc</id>
<content type='text'>
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 &lt;ansuelsmth@gmail.com&gt;
</content>
</entry>
<entry>
<title>linux/bitfield.h: Add primitives for manipulating bitfields both in host- and fixed-endian</title>
<updated>2020-07-10T09:47:12Z</updated>
<author>
<name>Nicolas Saenz Julienne</name>
<email>nsaenzjulienne@suse.de</email>
</author>
<published>2020-05-25T11:39:56Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=c92921bb52a7e104e0a48740d518c41ec4c86097'/>
<id>urn:sha1:c92921bb52a7e104e0a48740d518c41ec4c86097</id>
<content type='text'>
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 &lt;nsaenzjulienne@suse.de&gt;
[s.nawrocki: added empty lines between functions and macros]
Signed-off-by: Sylwester Nawrocki &lt;s.nawrocki@samsung.com&gt;
[mb: squash fix including byteorder.h]
Signed-off-by: Matthias Brugger &lt;mbrugger@suse.com&gt;
</content>
</entry>
<entry>
<title>linux/bitfield.h: import &lt;linux/bitfield.h&gt; from Linux 4.13</title>
<updated>2017-10-04T16:00:21Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2017-09-29T01:35:17Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=6990e91f0971b877cd636e646f93587b1afbb284'/>
<id>urn:sha1:6990e91f0971b877cd636e646f93587b1afbb284</id>
<content type='text'>
Copied from Linux 4.13.

Commit log of 3e9b3112ec74 of Linux explains well why this header
is useful.

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
</feed>
