From: Danilo Krummrich <dakr@kernel.org>
To: dakr@kernel.org, aliceryhl@google.com, acourbot@nvidia.com,
daniel.almeida@collabora.com, ojeda@kernel.org, boqun@kernel.org,
gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, tmgross@umich.edu, tamird@kernel.org,
work@onurozkan.dev, brauner@kernel.org, lyude@redhat.com,
j@jananu.net, alvin.sun@linux.dev, deborah.brouwer@collabora.com,
laura.nao@collabora.com, beata.michalska@arm.com
Cc: nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/7] rust: drm: move file_operations from gem to device
Date: Wed, 18 Nov 2026 17:29:44 +0100 [thread overview]
Message-ID: <20261118163203.2483856-4-dakr@kernel.org> (raw)
In-Reply-To: <20261118163203.2483856-1-dakr@kernel.org>
Move the file_operations definition from drm::gem::create_fops() into
UnregisteredDevice in drm::device. This is the file_operations of the
DRM minor device, set through the drm_driver struct. It is not specific
to GEM.
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
rust/kernel/drm/device.rs | 23 ++++++++++++++++++++---
rust/kernel/drm/gem/mod.rs | 20 --------------------
2 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs
index dd1c83fef323..3340fa0dc46b 100644
--- a/rust/kernel/drm/device.rs
+++ b/rust/kernel/drm/device.rs
@@ -195,11 +195,28 @@ const fn compute_features() -> u32 {
driver_features: Self::compute_features(),
ioctls: T::IOCTLS.as_ptr(),
num_ioctls: T::IOCTLS.len() as i32,
- fops: &Self::GEM_FOPS,
+ fops: &Self::FOPS,
};
- const GEM_FOPS: bindings::file_operations =
- drm::gem::create_fops(crate::module::this_module::<T::OwnerModule>().as_ptr());
+ const FOPS: bindings::file_operations = {
+ let mut fops: bindings::file_operations = pin_init::zeroed();
+
+ fops.owner = crate::module::this_module::<T::OwnerModule>().as_ptr();
+ fops.open = Some(bindings::drm_open);
+ fops.release = Some(bindings::drm_release);
+ fops.unlocked_ioctl = Some(bindings::drm_ioctl);
+ #[cfg(CONFIG_COMPAT)]
+ {
+ fops.compat_ioctl = Some(bindings::drm_compat_ioctl);
+ }
+ fops.poll = Some(bindings::drm_poll);
+ fops.read = Some(bindings::drm_read);
+ fops.llseek = Some(bindings::noop_llseek);
+ fops.mmap = Some(bindings::drm_gem_mmap);
+ fops.fop_flags = bindings::FOP_UNSIGNED_OFFSET;
+
+ fops
+ };
/// Create a new `UnregisteredDevice` for a `drm::Driver`.
///
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 94355081edab..260f36817f96 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -388,23 +388,3 @@ impl<T: DriverObject, Ctx: DeviceContext> AllocImpl for Object<T, Ctx> {
dumb_map_offset: None,
};
}
-
-pub(super) const fn create_fops(owner: *mut bindings::module) -> bindings::file_operations {
- let mut fops: bindings::file_operations = pin_init::zeroed();
-
- fops.owner = owner;
- fops.open = Some(bindings::drm_open);
- fops.release = Some(bindings::drm_release);
- fops.unlocked_ioctl = Some(bindings::drm_ioctl);
- #[cfg(CONFIG_COMPAT)]
- {
- fops.compat_ioctl = Some(bindings::drm_compat_ioctl);
- }
- fops.poll = Some(bindings::drm_poll);
- fops.read = Some(bindings::drm_read);
- fops.llseek = Some(bindings::noop_llseek);
- fops.mmap = Some(bindings::drm_gem_mmap);
- fops.fop_flags = bindings::FOP_UNSIGNED_OFFSET;
-
- fops
-}
--
2.56.1
next prev parent reply other threads:[~2026-11-18 16:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 16:29 [PATCH v3 0/7] lifetime-parameterized DRM File private data Danilo Krummrich
2026-11-18 16:29 ` [PATCH v3 1/7] rust: drm: rename Ioctl device context to Userspace Danilo Krummrich
2026-11-18 16:29 ` [PATCH v3 2/7] rust: drm: gem: gate open/close callbacks with RegistrationGuard Danilo Krummrich
2026-11-18 16:29 ` Danilo Krummrich [this message]
2026-11-18 16:29 ` [PATCH v3 4/7] rust: fs: add iminor() helper Danilo Krummrich
2026-11-20 8:55 ` Christian Brauner
2026-11-18 16:29 ` [PATCH v3 5/7] rust: drm: wrap fops open with RegistrationGuard Danilo Krummrich
2026-11-18 16:29 ` [PATCH v3 6/7] rust: drm: return impl PinInit from DriverFile::open() Danilo Krummrich
2026-11-18 16:29 ` [PATCH v3 7/7] rust: drm: make Driver::File lifetime-parameterized Danilo Krummrich
2026-11-19 11:17 ` Alice Ryhl
2026-11-19 11:21 ` Gary Guo
2026-11-19 21:57 ` [PATCH v3 0/7] lifetime-parameterized DRM File private data Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118163203.2483856-4-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=alvin.sun@linux.dev \
--cc=beata.michalska@arm.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=deborah.brouwer@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=j@jananu.net \
--cc=laura.nao@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.