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 }> {
112
112
// SAFETY: Calling unsafe functions and manipulating `MaybeUninit`
113
113
// pointer.
114
114
unsafe {
115
- bindings:: cdev_init ( cdev, & file_operations:: FileOperationsVtable :: < T > :: VTABLE ) ;
115
+ bindings:: cdev_init ( cdev, file_operations:: FileOperationsVtable :: < T > :: build ( ) ) ;
116
116
( * cdev) . owner = this. this_module . 0 ;
117
117
let rc = bindings:: cdev_add ( cdev, inner. dev + inner. used as bindings:: dev_t , 1 ) ;
118
118
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>(
201
201
pub ( crate ) struct FileOperationsVtable < T > ( marker:: PhantomData < T > ) ;
202
202
203
203
impl < T : FileOperations > FileOperationsVtable < T > {
204
- pub ( crate ) const VTABLE : bindings:: file_operations = bindings:: file_operations {
204
+ const VTABLE : bindings:: file_operations = bindings:: file_operations {
205
205
open : Some ( open_callback :: < T > ) ,
206
206
release : Some ( release_callback :: < T > ) ,
207
207
read : if T :: TO_USE . read {
@@ -260,6 +260,11 @@ impl<T: FileOperations> FileOperationsVtable<T> {
260
260
} ,
261
261
write_iter : None ,
262
262
} ;
263
+
264
+ /// Builds an instance of [`struct file_operations`].
265
+ pub ( crate ) const fn build ( ) -> & ' static bindings:: file_operations {
266
+ & Self :: VTABLE
267
+ }
263
268
}
264
269
265
270
/// 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 {
61
61
62
62
this. mdev = Some ( bindings:: miscdevice:: default ( ) ) ;
63
63
let dev = this. mdev . as_mut ( ) . unwrap ( ) ;
64
- dev. fops = & FileOperationsVtable :: < T > :: VTABLE ;
64
+ dev. fops = FileOperationsVtable :: < T > :: build ( ) ;
65
65
dev. name = name. as_ptr ( ) as * const c_types:: c_char ;
66
66
dev. minor = minor. unwrap_or ( bindings:: MISC_DYNAMIC_MINOR as i32 ) ;
67
67
let ret = unsafe { bindings:: misc_register ( dev) } ;
You can’t perform that action at this time.
0 commit comments