linux/rust/kernel/debugfs
Danilo Krummrich 9dc6cedcd9 rust: debugfs: drop 'static bound from ScopedDir file creation methods
Drop the T: 'static bound from ScopedDir's file creation methods
(read_binary_file(), read_only_file(), etc.) to support registering
debugfs files backed by types that contain non-'static references, such
as dma::Coherent<'a, T>.

The previous 'static bound existed because ScopedDir::create_file() took
&'static FileOps<T>, and &'static requires T: 'static for well-
formedness. However, this was overly conservative: the file_operations
pointer passed to the C debugfs API just needs to be 'static, not the
entire FileOps<T>.

Store &'static bindings::file_operations in FileOps<T> instead of the
file_operations by value. In each trait impl, take a reference to the
file_operations struct within the const block; since
bindings::file_operations does not mention T, the reference is promoted
to 'static regardless of T's lifetime parameters.

Replace the Deref impl with an explicit fops() method that returns the
stored &'static reference.

Link: https://lore.kernel.org/driver-core/20260830193824.471089-2-dakr@kernel.org
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260830193824.471089-2-dakr@kernel.org
[ Remove unrelated change from Self to T. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-09-04 17:58:43 +02:00
..
callback_adapters.rs rust: debugfs: use "kernel vertical" style for imports 2025-12-22 17:04:07 +01:00
entry.rs rust: debugfs: drop 'static bound from ScopedDir file creation methods 2026-09-04 17:58:43 +02:00
file_ops.rs rust: debugfs: drop 'static bound from ScopedDir file creation methods 2026-09-04 17:58:43 +02:00
traits.rs rust: debugfs: remove unsafe blocks from traits impl for Vec 2026-07-31 11:08:29 +02:00