diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-11-09 10:39:52 +0000 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-11-09 10:39:52 +0000 |
commit | e459ca0aec9a38f71e35c83d3dcb3cadb5033334 (patch) | |
tree | d66e23adf3d366d07d1d77f7f3fc3356808fa795 /rust/kernel/miscdevice.rs | |
parent | 56686ac80b859c2049cc372f7837470aa71c98cf (diff) | |
parent | 9365f0de4303f82ed4c2db1c39d3de824b249d80 (diff) |
Merge commit '9365f0de4303f82ed4c2db1c39d3de824b249d80' into HEAD
Merge v6.12-rc6 via char-misc-next to get some fixes needed for next few
patches in IIO.
Diffstat (limited to 'rust/kernel/miscdevice.rs')
-rw-r--r-- | rust/kernel/miscdevice.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs index 50885fb511bf..7e2a79b3ae26 100644 --- a/rust/kernel/miscdevice.rs +++ b/rust/kernel/miscdevice.rs @@ -165,6 +165,7 @@ const fn create_vtable<T: MiscDevice>() -> &'static bindings::file_operations { } else { None }, + // SAFETY: All zeros is a valid value for `bindings::file_operations`. ..unsafe { MaybeUninit::zeroed().assume_init() } }; } @@ -172,6 +173,10 @@ const fn create_vtable<T: MiscDevice>() -> &'static bindings::file_operations { &VtableHelper::<T>::VTABLE } +/// # Safety +/// +/// `file` and `inode` must be the file and inode for a file that is undergoing initialization. +/// The file must be associated with a `MiscDeviceRegistration<T>`. unsafe extern "C" fn fops_open<T: MiscDevice>( inode: *mut bindings::inode, file: *mut bindings::file, @@ -193,6 +198,10 @@ unsafe extern "C" fn fops_open<T: MiscDevice>( 0 } +/// # Safety +/// +/// `file` and `inode` must be the file and inode for a file that is being released. The file must +/// be associated with a `MiscDeviceRegistration<T>`. unsafe extern "C" fn fops_release<T: MiscDevice>( _inode: *mut bindings::inode, file: *mut bindings::file, @@ -207,6 +216,9 @@ unsafe extern "C" fn fops_release<T: MiscDevice>( 0 } +/// # Safety +/// +/// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`. unsafe extern "C" fn fops_ioctl<T: MiscDevice>( file: *mut bindings::file, cmd: c_uint, @@ -223,6 +235,9 @@ unsafe extern "C" fn fops_ioctl<T: MiscDevice>( } } +/// # Safety +/// +/// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`. #[cfg(CONFIG_COMPAT)] unsafe extern "C" fn fops_compat_ioctl<T: MiscDevice>( file: *mut bindings::file, |