[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251129122753.23022-1-atharvd440@gmail.com>
Date: Sat, 29 Nov 2025 17:57:53 +0530
From: Atharv Dubey <atharvd440@...il.com>
To: rafael@...nel.org,
lenb@...nel.org
Cc: ojeda@...nel.org,
alex.gaynor@...il.com,
boqun.feng@...il.com,
gary@...yguo.net,
bjorn3_gh@...tonmail.com,
lossin@...nel.org,
a.hindborg@...nel.org,
aliceryhl@...gle.com,
tmgross@...ch.edu,
dakr@...nel.org,
linux-acpi@...r.kernel.org,
rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org,
Atharv Dubey <atharvd440@...il.com>
Subject: [PATCH] rust: acpi: replace manual zero-initialization with `pin_init::zeroed()`
Use `pin_init::zeroed()` instead of `core::mem::zeroed()` for initializing
`acpi_device_id`. This removes an explicit unsafe block and aligns ACPI
initialization with the pin-init conversion used across the Rust tree.
Link: https://github.com/Rust-for-Linux/linux/issues/1189
Signed-off-by: Atharv Dubey <atharvd440@...il.com>
---
rust/kernel/acpi.rs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/rust/kernel/acpi.rs b/rust/kernel/acpi.rs
index 37e1161c1298..9b8efa623130 100644
--- a/rust/kernel/acpi.rs
+++ b/rust/kernel/acpi.rs
@@ -39,9 +39,7 @@ impl DeviceId {
pub const fn new(id: &'static CStr) -> Self {
let src = id.to_bytes_with_nul();
build_assert!(src.len() <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");
- // Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
- // SAFETY: FFI type is valid to be zero-initialized.
- let mut acpi: bindings::acpi_device_id = unsafe { core::mem::zeroed() };
+ let mut acpi: bindings::acpi_device_id = pin_init::zeroed();
let mut i = 0;
while i < src.len() {
acpi.id[i] = src[i];
--
2.43.0
Powered by blists - more mailing lists