On Fri, Jan 10, 2025 at 11:16 AM Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx> wrote: > > independent cleanup to the tree, I guess. In that case, I would clean > the 3 cases (i.e. adding `!` but not removing `kernel::`). The patch that Alice sent for this looks good. Stephen: I did a quick build test with a merge with `rust-next` using the following resolution (attached). Cheers, Miguel
diff --cc rust/kernel/lib.rs index b11fa08de3c0,6063f4a3d9c0..2d5c3d7d2e21 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@@ -37,12 -32,10 +37,13 @@@ pub use ffi pub mod alloc; #[cfg(CONFIG_BLOCK)] pub mod block; - mod build_assert; + #[doc(hidden)] + pub mod build_assert; pub mod cred; pub mod device; +pub mod device_id; +pub mod devres; +pub mod driver; pub mod error; #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)] pub mod firmware; diff --cc rust/kernel/miscdevice.rs index dfb363630c70,9e1b9c0fae9d..3ba018651bc0 --- a/rust/kernel/miscdevice.rs +++ b/rust/kernel/miscdevice.rs @@@ -10,11 -10,9 +10,12 @@@ use crate::{ bindings, + device::Device, error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR}, + ffi::{c_int, c_long, c_uint, c_ulong}, + fs::File, prelude::*, + seq_file::SeqFile, str::CStr, types::{ForeignOwnable, Opaque}, }; @@@ -151,17 -132,8 +147,17 @@@ pub trait MiscDevice: Sized _cmd: u32, _arg: usize, ) -> Result<isize> { - kernel::build_error!(VTABLE_DEFAULT_ERROR) + build_error!(VTABLE_DEFAULT_ERROR) } + + /// Show info for this fd. + fn show_fdinfo( + _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, + _m: &SeqFile, + _file: &File, + ) { - kernel::build_error!(VTABLE_DEFAULT_ERROR) ++ build_error!(VTABLE_DEFAULT_ERROR) + } } const fn create_vtable<T: MiscDevice>() -> &'static bindings::file_operations { @@@ -274,12 -225,7 +270,12 @@@ unsafe extern "C" fn fops_ioctl<T: Misc // SAFETY: Ioctl calls can borrow the private data of the file. let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) }; - match T::ioctl(device, cmd, arg) { + // SAFETY: + // * The file is valid for the duration of this call. + // * There is no active fdget_pos region on the file on this thread. + let file = unsafe { File::from_raw_file(file) }; + - match T::ioctl(device, file, cmd, arg as usize) { ++ match T::ioctl(device, file, cmd, arg) { Ok(ret) => ret as c_long, Err(err) => err.to_errno() as c_long, } @@@ -299,12 -245,7 +295,12 @@@ unsafe extern "C" fn fops_compat_ioctl< // SAFETY: Ioctl calls can borrow the private data of the file. let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) }; - match T::compat_ioctl(device, cmd, arg) { + // SAFETY: + // * The file is valid for the duration of this call. + // * There is no active fdget_pos region on the file on this thread. + let file = unsafe { File::from_raw_file(file) }; + - match T::compat_ioctl(device, file, cmd, arg as usize) { ++ match T::compat_ioctl(device, file, cmd, arg) { Ok(ret) => ret as c_long, Err(err) => err.to_errno() as c_long, }