From nobody Mon Jun 8 14:52:52 2026 Received: from latitanza.investici.org (latitanza.investici.org [185.218.207.228]) (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 4CA243328FD; Fri, 29 May 2026 15:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.218.207.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780069716; cv=none; b=q3Tg2sesRNx76YFr8j3WInqae2haRzxgCaPi2ty4S76IcmtMWRskyYYhaR0cVQxdd5U3IFnPzQHBG5vrhkhKWjERPTAMaCIP2DxdfYb4/8KD4dq6z7vv2EQ+K0SsiMOUt+RyUzP8kNfY7A+crHBoiTdXYBJyUGwAB+0AuZohTAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780069716; c=relaxed/simple; bh=y/UeTu/E1r5exlVyd6PZjhTTC8A/Dm1i+hrIlYJiOko=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HkOOp9Rg9rZjMYa9bvo+9pcaLBKL93igFeDhDoPVH5vMoNux/EG2DffE+y9Nzv2ouRAKdDdsqifJNDziA+mRX56Wocj6QqE1fsUZdsBYCReq7jn70i2IuE2S5cVidP/1IdMbkSwSjw0rCuwq37Ng49z9vn8QjmkDhP/sEWd4fk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=privacyrequired.com; spf=pass smtp.mailfrom=privacyrequired.com; dkim=pass (1024-bit key) header.d=privacyrequired.com header.i=@privacyrequired.com header.b=hWq0NfUP; arc=none smtp.client-ip=185.218.207.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=privacyrequired.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=privacyrequired.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=privacyrequired.com header.i=@privacyrequired.com header.b="hWq0NfUP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=privacyrequired.com; s=stigmate; t=1780069119; bh=nE54WBHYh18XBHfnL0b5qXxtCiVRQLEV3D90GwnfxZ0=; h=From:To:Cc:Subject:Date:From; b=hWq0NfUPgqiqJmc3usdGSgAYA58479noSbGOwGZyMsmyweq3POdX1KE49t6RqFWCK +fEZXwmhvCefNA6y7RPPynrDHf/U0gqwOQWXew4uEvak6grMVvzy3aRI6Fjxa499cX T5/TA5t7Hrp5F+go+BR3JDpjBHmxu0eMcQQafi+8= Received: from mx3.investici.org (unknown [127.0.0.1]) by latitanza.investici.org (Postfix) with ESMTP id 4gRnZR0G95zGpC7; Fri, 29 May 2026 15:38:39 +0000 (UTC) Received: from [185.218.207.228] (mx3.investici.org [185.218.207.228]) (Authenticated sender: laniel_francis@privacyrequired.com) by localhost (Postfix) with ESMTPSA id 4gRnZP4RyDzGp9y; Fri, 29 May 2026 15:38:37 +0000 (UTC) From: Francis Laniel To: Michal Wilczynski , Miguel Ojeda , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Benno Lossin , Gary Guo Cc: Francis Laniel , Boqun Feng , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , linux-pwm@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] rust: pwm: use pin_init::zeroed() to initialize pwm_ops Date: Fri, 29 May 2026 18:38:20 +0300 Message-ID: <20260529153821.126823-1-laniel_francis@privacyrequired.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace unsafe block containing core::mem::zeroed by calling pin_init::zeroed(). This is safer, as this function is guarded by trait contrary to core::mem:zeroed(). Also, we can call this because all fields in pwm_ops, i.e. function pointers in Option<> and usize, are Zeroable. Link: https://github.com/Rust-for-Linux/linux/issues/1189 Signed-off-by: Francis Laniel Acked-by: Michal Wilczynski Reviewed-by: Alexandre Courbot Suggested-by: Benno Lossin --- rust/kernel/pwm.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs index 6c9d667009ef..3427b7d93a03 100644 --- a/rust/kernel/pwm.rs +++ b/rust/kernel/pwm.rs @@ -494,9 +494,7 @@ pub(crate) fn as_raw(&self) -> *const bindings::pwm_ops= { /// This is used to bridge Rust trait implementations to the C `struct pwm= _ops` /// expected by the kernel. pub const fn create_pwm_ops() -> PwmOpsVTable { - // SAFETY: `core::mem::zeroed()` is unsafe. For `pwm_ops`, all fields = are - // `Option` or data, so a zeroed pattern (None/0) = is valid initially. - let mut ops: bindings::pwm_ops =3D unsafe { core::mem::zeroed() }; + let mut ops: bindings::pwm_ops =3D pin_init::zeroed(); =20 ops.request =3D Some(Adapter::::request_callback); ops.capture =3D Some(Adapter::::capture_callback); --=20 2.47.3