@@ -14,6 +14,13 @@ use crate::{
1414} ;
1515use core:: { mem, ops:: Deref , ptr:: NonNull } ;
1616
17+ /// A type alias for retrieving a [`Driver`]s [`DriverFile`] implementation from its
18+ /// [`DriverObject`] implementation.
19+ ///
20+ /// [`Driver`]: drm::Driver
21+ /// [`DriverFile`]: drm::file::DriverFile
22+ pub type DriverFile < T > = drm:: File < <<T as DriverObject >:: Driver as drm:: Driver >:: File > ;
23+
1724/// GEM object functions, which must be implemented by drivers.
1825pub trait DriverObject : Sync + Send + Sized {
1926 /// Parent `Driver` for this object.
@@ -23,19 +30,12 @@ pub trait DriverObject: Sync + Send + Sized {
2330 fn new ( dev : & drm:: Device < Self :: Driver > , size : usize ) -> impl PinInit < Self , Error > ;
2431
2532 /// Open a new handle to an existing object, associated with a File.
26- fn open (
27- _obj : & <Self :: Driver as drm:: Driver >:: Object ,
28- _file : & drm:: File < <Self :: Driver as drm:: Driver >:: File > ,
29- ) -> Result {
33+ fn open ( _obj : & <Self :: Driver as drm:: Driver >:: Object , _file : & DriverFile < Self > ) -> Result {
3034 Ok ( ( ) )
3135 }
3236
3337 /// Close a handle to an existing object, associated with a File.
34- fn close (
35- _obj : & <Self :: Driver as drm:: Driver >:: Object ,
36- _file : & drm:: File < <Self :: Driver as drm:: Driver >:: File > ,
37- ) {
38- }
38+ fn close ( _obj : & <Self :: Driver as drm:: Driver >:: Object , _file : & DriverFile < Self > ) { }
3939}
4040
4141/// Trait that represents a GEM object subtype
@@ -79,7 +79,8 @@ extern "C" fn open_callback<T: DriverObject>(
7979 raw_file : * mut bindings:: drm_file ,
8080) -> core:: ffi:: c_int {
8181 // SAFETY: `open_callback` is only ever called with a valid pointer to a `struct drm_file`.
82- let file = unsafe { drm:: File :: < <T :: Driver as drm:: Driver >:: File > :: from_raw ( raw_file) } ;
82+ let file = unsafe { DriverFile :: < T > :: from_raw ( raw_file) } ;
83+
8384 // SAFETY: `open_callback` is specified in the AllocOps structure for `DriverObject<T>`,
8485 // ensuring that `raw_obj` is contained within a `DriverObject<T>`
8586 let obj = unsafe { <<T :: Driver as drm:: Driver >:: Object as IntoGEMObject >:: from_raw ( raw_obj) } ;
@@ -95,7 +96,7 @@ extern "C" fn close_callback<T: DriverObject>(
9596 raw_file : * mut bindings:: drm_file ,
9697) {
9798 // SAFETY: `open_callback` is only ever called with a valid pointer to a `struct drm_file`.
98- let file = unsafe { drm :: File :: < < T :: Driver as drm :: Driver > :: File > :: from_raw ( raw_file) } ;
99+ let file = unsafe { DriverFile :: < T > :: from_raw ( raw_file) } ;
99100
100101 // SAFETY: `close_callback` is specified in the AllocOps structure for `Object<T>`, ensuring
101102 // that `raw_obj` is indeed contained within a `Object<T>`.
0 commit comments