[PATCH v2 3/4] rust: drm: gem: Add ObjectFile type alias
Danilo Krummrich
dakr at kernel.org
Sat May 17 11:37:12 UTC 2025
On Fri, May 16, 2025 at 01:09:18PM -0400, Lyude Paul wrote:
> Just to reduce the clutter with the File<…> types in gem.rs.
>
> Signed-off-by: Lyude Paul <lyude at redhat.com>
> ---
> rust/kernel/drm/gem/mod.rs | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index c17b36948bae3..2b81298d29765 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -17,6 +17,13 @@
> /// A type alias for the Object type in use by a [`drm::Driver`].
> pub type DriverObject<T> = <<T as BaseDriverObject>::Driver as drm::Driver>::Object;
>
> +/// A type alias for retrieving a [`Driver`]s [`DriverFile`] implementation from its
> +/// [`DriverObject`] implementation.
> +///
> +/// [`Driver`]: drm::Driver
> +/// [`DriverFile`]: drm::file::DriverFile
> +pub type ObjectFile<T> = drm::File<<<T as BaseDriverObject>::Driver as drm::Driver>::File>;
Shouldn't we call this just DriverFile? The fact that you derive the Driver type
from the Object type isn't relevant for the File type, i.e. it's not specific to
the Object, but to the Driver.
Also, why does this need to be pub? Shouldn't it be crate private instead? Or
does it make sense to use this in drivers? If so, please use it in nova-drm for
reference.
More information about the dri-devel
mailing list