File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ impl<const N: usize> Registration<{ N }> {
112112 // SAFETY: Calling unsafe functions and manipulating `MaybeUninit`
113113 // pointer.
114114 unsafe {
115- bindings:: cdev_init ( cdev, & file_operations:: FileOperationsVtable :: < T > :: VTABLE ) ;
115+ bindings:: cdev_init ( cdev, file_operations:: FileOperationsVtable :: < T > :: build ( ) ) ;
116116 ( * cdev) . owner = this. this_module . 0 ;
117117 let rc = bindings:: cdev_add ( cdev, inner. dev + inner. used as bindings:: dev_t , 1 ) ;
118118 if rc != 0 {
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ unsafe extern "C" fn fsync_callback<T: FileOperations>(
201201pub ( crate ) struct FileOperationsVtable < T > ( marker:: PhantomData < T > ) ;
202202
203203impl < T : FileOperations > FileOperationsVtable < T > {
204- pub ( crate ) const VTABLE : bindings:: file_operations = bindings:: file_operations {
204+ const VTABLE : bindings:: file_operations = bindings:: file_operations {
205205 open : Some ( open_callback :: < T > ) ,
206206 release : Some ( release_callback :: < T > ) ,
207207 read : if T :: TO_USE . read {
@@ -260,6 +260,11 @@ impl<T: FileOperations> FileOperationsVtable<T> {
260260 } ,
261261 write_iter : None ,
262262 } ;
263+
264+ /// Builds an instance of [`struct file_operations`].
265+ pub ( crate ) const fn build ( ) -> & ' static bindings:: file_operations {
266+ & Self :: VTABLE
267+ }
263268}
264269
265270/// Represents which fields of [`struct file_operations`] should be populated with pointers.
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ impl Registration {
6161
6262 this. mdev = Some ( bindings:: miscdevice:: default ( ) ) ;
6363 let dev = this. mdev . as_mut ( ) . unwrap ( ) ;
64- dev. fops = & FileOperationsVtable :: < T > :: VTABLE ;
64+ dev. fops = FileOperationsVtable :: < T > :: build ( ) ;
6565 dev. name = name. as_ptr ( ) as * const c_types:: c_char ;
6666 dev. minor = minor. unwrap_or ( bindings:: MISC_DYNAMIC_MINOR as i32 ) ;
6767 let ret = unsafe { bindings:: misc_register ( dev) } ;
You can’t perform that action at this time.
0 commit comments