]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bitmap: introduce hardware-specific bitfield operations
authorNicolas Frattaroli <nicolas.frattaroli@collabora.com>
Mon, 25 Aug 2025 08:28:21 +0000 (10:28 +0200)
committerYury Norov <yury.norov@gmail.com>
Tue, 2 Sep 2025 23:59:16 +0000 (19:59 -0400)
commit21368fcbb124d51b5d8bd8fa0a286a23c34a0888
treec3169474ac77876583ff585b599b3bc8d20b1fa3
parenta3fecb9160482367365cc384c59dd220b162b066
bitmap: introduce hardware-specific bitfield operations

Hardware of various vendors, but very notably Rockchip, often uses
32-bit registers where the upper 16-bit half of the register is a
write-enable mask for the lower half.

This type of hardware setup allows for more granular concurrent register
write access.

Over the years, many drivers have hand-rolled their own version of this
macro, usually without any checks, often called something like
HIWORD_UPDATE or FIELD_PREP_HIWORD, commonly with slightly different
semantics between them.

Clearly there is a demand for such a macro, and thus the demand should
be satisfied in a common header file. As this is a convention that spans
across multiple vendors, and similar conventions may also have
cross-vendor adoption, it's best if it lives in a vendor-agnostic header
file that can be expanded over time.

Add hw_bitfield.h with two macros: FIELD_PREP_WM16, and
FIELD_PREP_WM16_CONST. The latter is a version that can be used in
initializers, like FIELD_PREP_CONST.

Suggested-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
MAINTAINERS
include/linux/hw_bitfield.h [new file with mode: 0644]