* [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization
@ 2025-12-01 15:27 Atharv Dubey
2025-12-01 15:31 ` Daniel Almeida
2025-12-02 9:11 ` Alice Ryhl
0 siblings, 2 replies; 4+ messages in thread
From: Atharv Dubey @ 2025-12-01 15:27 UTC (permalink / raw)
To: Airlie
Cc: Simona Vetter, Danilo Krummrich, Alice Ryhl, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Lyude Paul, Shankari Anand, Asahi Lina, Atharv Dubey, dri-devel,
rust-for-linux
Replace the manual `unsafe { core::mem::zeroed() }` initialization of
`bindings::file_operations` with `pin_init::zeroed()`. This removes the
explicit unsafe
Signed-off-by: Atharv Dubey <atharvd440@gmail.com>
---
rust/kernel/drm/gem/mod.rs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 30c853988b94..f9fd98dc102b 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -298,9 +298,7 @@ impl<T: DriverObject> AllocImpl for Object<T> {
}
pub(super) const fn create_fops() -> bindings::file_operations {
- // SAFETY: As by the type invariant, it is safe to initialize `bindings::file_operations`
- // zeroed.
- let mut fops: bindings::file_operations = unsafe { core::mem::zeroed() };
+ let mut fops: bindings::file_operations = pin_init::zeroed();
fops.owner = core::ptr::null_mut();
fops.open = Some(bindings::drm_open);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization
2025-12-01 15:27 [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization Atharv Dubey
@ 2025-12-01 15:31 ` Daniel Almeida
2025-12-01 15:35 ` Miguel Ojeda
2025-12-02 9:11 ` Alice Ryhl
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Almeida @ 2025-12-01 15:31 UTC (permalink / raw)
To: Atharv Dubey
Cc: Airlie, Simona Vetter, Danilo Krummrich, Alice Ryhl, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Lyude Paul,
Shankari Anand, Asahi Lina, dri-devel, rust-for-linux
Hi Atharv,
> On 1 Dec 2025, at 12:27, Atharv Dubey <atharvd440@gmail.com> wrote:
>
> Replace the manual `unsafe { core::mem::zeroed() }` initialization of
> `bindings::file_operations` with `pin_init::zeroed()`. This removes the
> explicit unsafe
>
> Signed-off-by: Atharv Dubey <atharvd440@gmail.com>
> ---
> rust/kernel/drm/gem/mod.rs | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index 30c853988b94..f9fd98dc102b 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -298,9 +298,7 @@ impl<T: DriverObject> AllocImpl for Object<T> {
> }
>
> pub(super) const fn create_fops() -> bindings::file_operations {
> - // SAFETY: As by the type invariant, it is safe to initialize `bindings::file_operations`
> - // zeroed.
> - let mut fops: bindings::file_operations = unsafe { core::mem::zeroed() };
> + let mut fops: bindings::file_operations = pin_init::zeroed();
>
> fops.owner = core::ptr::null_mut();
> fops.open = Some(bindings::drm_open);
> --
> 2.43.0
>
>
I wonder if this should be part of a larger series that implements this change
throughout the tree?
— Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization
2025-12-01 15:31 ` Daniel Almeida
@ 2025-12-01 15:35 ` Miguel Ojeda
0 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2025-12-01 15:35 UTC (permalink / raw)
To: Daniel Almeida
Cc: Atharv Dubey, Airlie, Simona Vetter, Danilo Krummrich, Alice Ryhl,
Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Lyude Paul, Shankari Anand, Asahi Lina, dri-devel,
rust-for-linux
On Mon, Dec 1, 2025 at 4:31 PM Daniel Almeida
<daniel.almeida@collabora.com> wrote:
>
> I wonder if this should be part of a larger series that implements this change
> throughout the tree?
They are independent, so it is easier to land them as such (and may be
clearer that is the case by sending them separately), but having them
in a series (even if landed separately) is also OK.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization
2025-12-01 15:27 [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization Atharv Dubey
2025-12-01 15:31 ` Daniel Almeida
@ 2025-12-02 9:11 ` Alice Ryhl
1 sibling, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2025-12-02 9:11 UTC (permalink / raw)
To: Atharv Dubey
Cc: Airlie, Simona Vetter, Danilo Krummrich, Miguel Ojeda,
Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Lyude Paul, Shankari Anand, Asahi Lina, dri-devel, rust-for-linux
On Mon, Dec 01, 2025 at 08:57:58PM +0530, Atharv Dubey wrote:
> Replace the manual `unsafe { core::mem::zeroed() }` initialization of
> `bindings::file_operations` with `pin_init::zeroed()`. This removes the
> explicit unsafe
>
> Signed-off-by: Atharv Dubey <atharvd440@gmail.com>
Thanks, I'll pick this up for drm-rust-next once the branch reopens in
two weeks.
Alice
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-02 9:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-01 15:27 [PATCH v2] rust: drm: use `pin_init::zeroed()` for file operations initialization Atharv Dubey
2025-12-01 15:31 ` Daniel Almeida
2025-12-01 15:35 ` Miguel Ojeda
2025-12-02 9:11 ` Alice Ryhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).