[PATCH] rust: of: use safe zero initialization for struct of_device_id

From: Thorsten Blum

Date: Sun Oct 11 2026 - 13:03:15 EST


Since bindings::of_device_id implements Zeroable, use pin_init::zeroed()
instead of core::mem::zeroed().

Signed-off-by: Thorsten Blum <blum@xxxxxxxxxx>
---
rust/kernel/of.rs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/rust/kernel/of.rs b/rust/kernel/of.rs
index d0318f62afd7..75d5004d2221 100644
--- a/rust/kernel/of.rs
+++ b/rust/kernel/of.rs
@@ -31,9 +31,7 @@ impl DeviceId {
/// Create a new device id from an OF 'compatible' string.
pub const fn new(compatible: &'static CStr) -> Self {
let src = compatible.to_bytes_with_nul();
- // Replace with `bindings::of_device_id::default()` once stabilized for `const`.
- // SAFETY: FFI type is valid to be zero-initialized.
- let mut of: bindings::of_device_id = unsafe { core::mem::zeroed() };
+ let mut of: bindings::of_device_id = pin_init::zeroed();

// TODO: Use `copy_from_slice` once stabilized for `const`.
let mut i = 0;