Re: [PATCH v1] rust: pwm: use pin_init::zeroed() to initialize pwm_ops

From: Miguel Ojeda

Date: Fri May 29 2026 - 13:42:16 EST


On Fri, May 29, 2026 at 5:48 PM Francis Laniel
<laniel_francis@xxxxxxxxxxxxxxxxxxx> wrote:
>
> 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().

It is definitely safer, but it is actually fully safe, i.e. it is a
safe `const fn` after all, which is great. I would say removing
`unsafe` code is the justification, even if of course the function is
able to be safe thanks to implementing the trait only for certain
types. (Also missing `:`).

I would suggest reusing Benno's commit message from the series he
links in the issue instead, e.g.

https://lore.kernel.org/all/20250814093046.2071971-8-lossin@xxxxxxxxxx/

> Link: https://github.com/Rust-for-Linux/linux/issues/1189

Please use Suggested-by like the issue mentions :)

Suggested-by: Benno Lossin <lossin@xxxxxxxxxx>

Thanks!

Cheers,
Miguel