]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: cpufreq: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()`
authorBenno Lossin <lossin@kernel.org>
Thu, 14 Aug 2025 09:30:38 +0000 (11:30 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 8 Sep 2025 12:03:29 +0000 (14:03 +0200)
All types in `bindings` implement `Zeroable` if they can, so use
`pin_init::zeroed` instead of relying on `unsafe` code.

If this ends up not compiling in the future, something in bindgen or on
the C side changed and is most likely incorrect.

Signed-off-by: Benno Lossin <lossin@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/cpufreq.rs

index afc15e72a7c37ac781f25a8a6edd804fa4c9658a..be2dffbdb5462838a001ad594bf1682abdaacf46 100644 (file)
@@ -27,7 +27,6 @@ use crate::clk::Clk;
 use core::{
     cell::UnsafeCell,
     marker::PhantomData,
-    mem::MaybeUninit,
     ops::{Deref, DerefMut},
     pin::Pin,
     ptr,
@@ -1013,8 +1012,7 @@ impl<T: Driver> Registration<T> {
         } else {
             None
         },
-        // SAFETY: All zeros is a valid value for `bindings::cpufreq_driver`.
-        ..unsafe { MaybeUninit::zeroed().assume_init() }
+        ..pin_init::zeroed()
     };
 
     const fn copy_name(name: &'static CStr) -> [c_char; CPUFREQ_NAME_LEN] {