lkml.org 
[lkml]   [2025]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH v2 0/4] Improve bitfield support in Rust
Date
These patches extract and enhance the bitfield support in the register macro
and introduces a new macro called bitstruct which allows to define Rust
structures with bitfields. This is extremely useful as it allows clean Rust
structure definitions without requiring explicit masks and shifts.

See [1] for an example of code I am working on.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git/patch/?id=76797b31facae8f1a1be139412c78568df1da9f3

v1 of the patches is at:
https://lore.kernel.org/all/20250824135954.2243774-1-joelagnelf@nvidia.com/

v1->v2:
* Use build_assert in bitstruct
* Split move and enhance patches for easier review
* Move out of Nova into kernel crate for other drivers like Tyr which will use.
* Miscellaneous cosmetic improvements.

Joel Fernandes (4):
nova-core: bitstruct: Move bitfield-specific code from register! into
new macro
nova-core: bitstruct: Add support for different storage widths
nova-core: bitstruct: Add support for custom visiblity
rust: Move register and bitstruct macros out of Nova

drivers/gpu/nova-core/falcon.rs | 2 +-
drivers/gpu/nova-core/falcon/gsp.rs | 3 +-
drivers/gpu/nova-core/falcon/sec2.rs | 2 +-
drivers/gpu/nova-core/regs.rs | 5 +-
rust/kernel/bitstruct.rs | 281 +++++++++++++++
rust/kernel/lib.rs | 2 +
rust/kernel/prelude.rs | 2 +
.../regs/macros.rs => rust/kernel/register.rs | 339 +++---------------
8 files changed, 347 insertions(+), 289 deletions(-)
create mode 100644 rust/kernel/bitstruct.rs
rename drivers/gpu/nova-core/regs/macros.rs => rust/kernel/register.rs (70%)

--
2.34.1


\
 
 \ /
  Last update: 2025-09-03 23:55    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog