[PATCH v2 5/7] rust: miscdevice: set fops.owner from driver module pointer

0 views
Skip to first unread message

Alvin Sun

unread,
May 21, 2026, 3:53:00 AM (4 days ago) May 21
to Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich, Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen, Aaron Tomlin, Greg Kroah-Hartman, Rafael J. Wysocki, David Airlie, Simona Vetter, Daniel Almeida, Arnd Bergmann, Brendan Higgins, David Gow, Rae Moar, Breno Leitao, Jens Axboe, rust-fo...@vger.kernel.org, linux-...@vger.kernel.org, drive...@lists.linux.dev, dri-...@lists.freedesktop.org, nova...@lists.linux.dev, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linux...@vger.kernel.org, Alvin Sun
Set the miscdevice fops owner field from the driver module pointer
via `<T::ThisModule as ModuleMetadata>::THIS_MODULE`, instead of
defaulting to null.

Signed-off-by: Alvin Sun <alvi...@linux.dev>
---
rust/kernel/miscdevice.rs | 2 ++
1 file changed, 2 insertions(+)

diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index 83ce50def5ac9..16837c46bca49 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -30,6 +30,7 @@
ForeignOwnable,
Opaque, //
},
+ ModuleMetadata, //
};
use core::marker::PhantomData;

@@ -430,6 +431,7 @@ impl<T: MiscDevice> MiscdeviceVTable<T> {
} else {
None
},
+ owner: <T::ThisModule as ModuleMetadata>::THIS_MODULE.as_ptr(),
..pin_init::zeroed()
};


--
2.43.0


Reply all
Reply to author
Forward
0 new messages