Rust for Linux List
 help / color / mirror / Atom feed
From: Michal Wilczynski <m.wilczynski@samsung.com>
To: "Francis Laniel" <laniel_francis@privacyrequired.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	"Benno Lossin" <lossin@kernel.org>, "Gary Guo" <gary@garyguo.net>
Cc: "Alexandre Courbot" <acourbot@nvidia.com>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	linux-pwm@vger.kernel.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] rust: pwm: replace `core::mem::zeroed` with `pin_init::zeroed`
Date: Mon, 27 Jul 2026 13:15:14 +0200	[thread overview]
Message-ID: <d9f17866-cc79-4f6c-9b4b-236128bebe69@samsung.com> (raw)
In-Reply-To: <20260603160910.159307-1-laniel_francis@privacyrequired.com>

Hi Uwe,

On 6/3/26 18:09, Francis Laniel wrote:
> 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.
> 
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Link: https://protect2.fireeye.com/v1/url?k=851847ef-eca32f5d-8519cca0-905a08a8515a-5adce8ef7cc40eb1&q=1&e=6c6d6a32-0f0e-4805-8882-718eae7641a8&u=https%3A%2F%2Fgithub.com%2FRust-for-Linux%2Flinux%2Fissues%2F1189
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> Acked-by: Michal Wilczynski <m.wilczynski@samsung.com>
> Signed-off-by: Francis Laniel <laniel_francis@privacyrequired.com>
> ---
>  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<T: PwmOps>() -> PwmOpsVTable {
> -    // SAFETY: `core::mem::zeroed()` is unsafe. For `pwm_ops`, all fields are
> -    // `Option<extern "C" fn(...)>` or data, so a zeroed pattern (None/0) is valid initially.
> -    let mut ops: bindings::pwm_ops = unsafe { core::mem::zeroed() };
> +    let mut ops: bindings::pwm_ops = pin_init::zeroed();
>  
>      ops.request = Some(Adapter::<T>::request_callback);
>      ops.capture = Some(Adapter::<T>::capture_callback);

I believe this commit is good to go, if you could take it through your
tree it would be great.

Best regards,
-- 
Michal Wilczynski <m.wilczynski@samsung.com>

  reply	other threads:[~2026-07-27 11:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260603160927eucas1p1ae24e871a8ef0771d72fae6462d96318@eucas1p1.samsung.com>
2026-06-03 16:09 ` [PATCH v3] rust: pwm: replace `core::mem::zeroed` with `pin_init::zeroed` Francis Laniel
2026-07-27 11:15   ` Michal Wilczynski [this message]
2026-08-11  5:04   ` Uwe Kleine-König
2026-08-11 20:54     ` Konstantin Ryabitsev
2026-08-11 21:00       ` Miguel Ojeda
2026-08-11 21:17         ` Konstantin Ryabitsev
2026-08-11 22:13           ` Miguel Ojeda
2026-08-11 22:56       ` Uwe Kleine-König
2026-08-11 23:01         ` Konstantin Ryabitsev
2026-08-13 15:01     ` Francis Laniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9f17866-cc79-4f6c-9b4b-236128bebe69@samsung.com \
    --to=m.wilczynski@samsung.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=laniel_francis@privacyrequired.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ukleinek@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox