[PATCH v3 00/11] `Zeroable` improvements & bindings integration
From: Benno Lossin <lossin@kernel.org>
Date: 2025-08-14 09:31:04
This came from a discussion at [1]. And I added some more useful parts to the original idea. I'm not sure on the impact of build times and rust-analyzer. We're adding a derive macro to every struct and union emitted by bindgen. Building using my test-config took 27.7s before and 28.2s after this change, but those are only two runs on my machine with a very reduced config (that enables all Rust code that we have at the moment). Maybe we have to reevaluate this when more C code is scanned by bindgen. [1]: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/Zeroable.20trait.20for.20C.20structs/with/509711564 Changelog ========= * v3: - removed already applied patches - added more patches replacing usage of `mem::zeroed` and `MaybeUninit::zeroed().assume_init()` with the new `pin_init::zeroed` - fix rusttest target * v2: - added patches with more extensive pin-init changes to `Zeroable` & related methods. for the upstream PR, see https://github.com/Rust-for-Linux/pin-init/pull/56 - added patches replacing usage of `mem::zeroed` and `MaybeUninit::zeroed().assume_init()` with the new `pin_init::zeroed` - fix rust-analyzer support - use import in `{uapi,bindings}/lib.rs` to avoid the `pin_init::` prefix * v1: https://lore.kernel.org/all/20250520192307.259142-1-lossin@kernel.org (local) Benno Lossin (11): rust: add `pin-init` as a dependency to `bindings` and `uapi` rust: derive `Zeroable` for all structs & unions generated by bindgen where possible rust: miscdevice: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` rust: phy: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` rust: block: replace `core::mem::zeroed` with `pin_init::zeroed` rust: of: replace `core::mem::zeroed` with `pin_init::zeroed` rust: security: replace `core::mem::zeroed` with `pin_init::zeroed` rust: drm: replace `core::mem::zeroed` with `pin_init::zeroed` rust: auxiliary: replace `core::mem::zeroed` with `pin_init::zeroed` rust: acpi: replace `core::mem::zeroed` with `pin_init::zeroed` rust: cpufreq: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` rust/Makefile | 14 ++++++++------ rust/bindgen_parameters | 4 ++++ rust/bindings/lib.rs | 8 ++++++++ rust/kernel/acpi.rs | 4 +--- rust/kernel/auxiliary.rs | 6 +----- rust/kernel/block/mq/gen_disk.rs | 3 +-- rust/kernel/block/mq/tag_set.rs | 4 +--- rust/kernel/cpufreq.rs | 4 +--- rust/kernel/drm/gem/mod.rs | 4 +--- rust/kernel/miscdevice.rs | 8 +++----- rust/kernel/net/phy.rs | 4 +--- rust/kernel/of.rs | 4 +--- rust/kernel/security.rs | 3 +-- rust/uapi/lib.rs | 2 ++ scripts/generate_rust_analyzer.py | 4 ++-- 15 files changed, 36 insertions(+), 40 deletions(-) base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585 -- 2.50.1