mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: of: use safe zero initialization for struct of_device_id
@ 2026-10-11 13:23 Thorsten Blum
  2026-10-11 13:58 ` Miguel Ojeda
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-10-11 13:23 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan
  Cc: Thorsten Blum, devicetree, rust-for-linux, linux-kernel

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

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] rust: of: use safe zero initialization for struct of_device_id
  2026-10-11 13:23 [PATCH] rust: of: use safe zero initialization for struct of_device_id Thorsten Blum
@ 2026-10-11 13:58 ` Miguel Ojeda
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2026-10-11 13:58 UTC (permalink / raw)
  To: Thorsten Blum, Nils Lehnen
  Cc: Rob Herring, Saravana Kannan, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, devicetree, rust-for-linux,
	linux-kernel

On Sun, Oct 11, 2026 at 3:24 PM Thorsten Blum <blum@kernel.org> wrote:
>
> Since bindings::of_device_id implements Zeroable, use pin_init::zeroed()
> instead of core::mem::zeroed().
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>

This is:

  https://lore.kernel.org/rust-for-linux/20260828122444.475-1-nils.lehnen@proton.me/

Cc'ing Nils.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-11 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 13:23 [PATCH] rust: of: use safe zero initialization for struct of_device_id Thorsten Blum
2026-10-11 13:58 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®