* Re: [PATCH v3] rust: pwm: replace `core::mem::zeroed` with `pin_init::zeroed`
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
2026-08-11 5:04 ` Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Michal Wilczynski @ 2026-07-27 11:15 UTC (permalink / raw)
To: Francis Laniel, Miguel Ojeda, Uwe Kleine-König, Benno Lossin,
Gary Guo
Cc: Alexandre Courbot, Boqun Feng, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-pwm, rust-for-linux, linux-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] rust: pwm: replace `core::mem::zeroed` with `pin_init::zeroed`
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
@ 2026-08-11 5:04 ` Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2026-08-11 5:04 UTC (permalink / raw)
To: Francis Laniel
Cc: Michal Wilczynski, Miguel Ojeda, Benno Lossin, Gary Guo,
Alexandre Courbot, Boqun Feng, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
linux-pwm, rust-for-linux, linux-kernel, tools
[-- Attachment #1: Type: text/plain, Size: 2963 bytes --]
Hello,
On Wed, Jun 03, 2026 at 07:09:09PM +0300, 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://github.com/Rust-for-Linux/linux/issues/1189
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> Acked-by: Michal Wilczynski <m.wilczynski@samsung.com>
> Signed-off-by: Francis Laniel <laniel_francis@privacyrequired.com>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
for the 7.3 merge window.
b4 behaved strange on that patch:
$ b4 am -s -l -t -3 20260603160910.159307-1-laniel_francis@privacyrequired.com
Grabbing thread from lore.kernel.org/all/20260603160910.159307-1-laniel_francis@privacyrequired.com/t.mbox.gz
Analyzing 2 messages in the thread
Looking for additional code-review trailers on lore.kernel.org
Analyzing 23 code-review messages
Checking attestation on all messages, may take a moment...
---
✓ [PATCH v3] rust: pwm: replace `core::mem::zeroed` with `pin_init::zeroed`
+ Link: https://patch.msgid.link/20260603160910.159307-1-laniel_francis@privacyrequired.com
+ Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
---
✓ Signed: DKIM/privacyrequired.com
---
Total patches: 1
---
NOTE: some trailers ignored due to from/email mismatches:
! Trailer: Suggested-by: Benno Lossin <lossin@kernel.org>
Msg From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
! Trailer: Acked-by: Michal Wilczynski <m.wilczynski@samsung.com>
Msg From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
! Trailer: Signed-off-by: Francis Laniel <laniel_francis@privacyrequired.com>
Msg From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
! Trailer: Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Msg From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
NOTE: Rerun with -S to apply them anyway
Preparing fake-am for v3: rust: pwm: replace `core::mem::zeroed` with `pin_init::zeroed`
range: 2707b9df955d..81c3f2b030a1
Preared a fake commit range for 3-way merge (2707b9df955d..81c3f2b030a1)
---
Link: https://patch.msgid.link/20260603160910.159307-1-laniel_francis@privacyrequired.com
Base: applies clean to current tree
git checkout -b v3_20260603_laniel_francis_privacyrequired_com HEAD
git am -3 ./v3_20260603_laniel_francis_rust_pwm_replace_core_mem_zeroed_with_pin_init_zeroed.mbx
I didn't research what went wrong there and the trailer made it into the
patch anyhow and adding -S doesn't change the patch. I added the
tools@k.o mailing list to Cc:, maybe someone there wants to debug that.
Best regards and thanks for your contribution,
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread