From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32FD1302779; Thu, 14 Aug 2025 09:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163911; cv=none; b=Bf3YNCHbFhyY0+yL5NTvCCQEmp0wmOy0FTEKPMFx8UqiouHPN9oVViOcH4xz1nqxequPVNmj8Qsz1/TG9o8oekMb+IZVZ24p9R64WfKj6uJa2JS0Wudy7O+rlDr1wZWZuFpBsZ5KZ4fL8kdm0mabTmDCWHhEZwGKVuO3BfhJGGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755163911; c=relaxed/simple; bh=e9mgz8XbeaX7DTGVgHJOp/zC3oQa22JUfQ5bhgnwxPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b8dJiVAnqkbpMI47zMgS/GEcE8SeaXaX55Yw6kofb5XmUNTYZMOFCFuxjrQAo2PtbHxf9eOdTXSYyDsUdxU1j/rbDEZ1/NnOgkjqR8d5q9yznQiKQHgh/hUxPaxkbBR449sJ5ZPui7URlQRhQv/2iDrbUe3WX2foI4DthsxAuQE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hpc3ENZq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hpc3ENZq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE206C4CEEF; Thu, 14 Aug 2025 09:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755163910; bh=e9mgz8XbeaX7DTGVgHJOp/zC3oQa22JUfQ5bhgnwxPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hpc3ENZqf4EbC8ZV20nW0mMu+FBQ1KYLpSHcZAao2EFG7uE/JCFGYRuYUvC0U5XIc g00C41cxSR9+hEzl+sDRTJQXSnS4nN4JK4MhJebJCOBOSqEQc2ipwsDOW28k15PY+a JcnXvgXuATAr8CXmYGFjWVFK4dCMwFA9zI+VOTd7b4cHFXMP0mI9V9St1Mk7sXy6l6 KodOd66b5OBvXiN3H3HJOKai3aoJMoMYi/MX8JtMnsmmT5nigw1mnPXZquwOH1e3Kc rzvb3oBJqzD5v50ZNRsp9aTxtTCWwNxtQrI0XqREZ536vkfwKPfeC64g/Z0wszrs5M 6UmzJHcfCaTWQ== From: Benno Lossin To: "Rafael J. Wysocki" , Viresh Kumar , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich Cc: linux-pm@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/11] rust: cpufreq: replace `MaybeUninit::zeroed().assume_init()` with `pin_init::zeroed()` Date: Thu, 14 Aug 2025 11:30:38 +0200 Message-ID: <20250814093046.2071971-12-lossin@kernel.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250814093046.2071971-1-lossin@kernel.org> References: <20250814093046.2071971-1-lossin@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- rust/kernel/cpufreq.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs index afc15e72a7c3..be2dffbdb546 100644 --- a/rust/kernel/cpufreq.rs +++ b/rust/kernel/cpufreq.rs @@ -27,7 +27,6 @@ use core::{ cell::UnsafeCell, marker::PhantomData, - mem::MaybeUninit, ops::{Deref, DerefMut}, pin::Pin, ptr, @@ -1013,8 +1012,7 @@ impl Registration { } 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] { -- 2.50.1