]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: extract `bitfield!` macro from `register!`
authorAlexandre Courbot <acourbot@nvidia.com>
Sat, 6 Jun 2026 12:43:04 +0000 (21:43 +0900)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 9 Jun 2026 02:12:51 +0000 (04:12 +0200)
commitb7b8b4ccdad45a59aafa5cfc32a51fe1ee5cb680
treec9b5b2febb146c97e81be72dca9a6d1e89efc2c0
parent09699b24199ac546037de252ba4907d99f4a8c7a
rust: extract `bitfield!` macro from `register!`

Extract the bitfield-defining part of the `register!` macro into an
independent macro used to define bitfield types with bounds-checked
accessors.

Each field is represented as a `Bounded` of the appropriate bit width,
ensuring field values are never silently truncated.

Fields can optionally be converted to/from custom types, either fallibly
or infallibly.

Appropriate documentation is also added, and a MAINTAINERS entry created
for the new module.

Two minor fixups are also applied: the private accessors are inlined,
and a couple of missing fully qualified types in the macro are fixed.

Acked-by: Yury Norov <ynorov@nvidia.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Yury Norov <ynorov@nvidia.com>
Link: https://patch.msgid.link/20260606-bitfield-v5-1-b92188820914@nvidia.com
[ Added some more intra-doc links. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
MAINTAINERS
rust/kernel/bitfield.rs [new file with mode: 0644]
rust/kernel/lib.rs