linux-next: manual merge of the rust tree with the driver-core tree

Stephen Rothwell
2025-01-13T04:12:38Z

[-- Attachment #1: Type: text/plain, Size: 3571 bytes --]

Hi all,

Today's linux-next merge of the rust tree got a conflict in:

rust/kernel/miscdevice.rs

between commits:

0d8a7c7bf47a ("rust: miscdevice: access file in fops")
5bcc8bfe841b ("rust: miscdevice: add fops->show_fdinfo() hook")
bf2aa7df2687 ("miscdevice: rust: use build_error! macro instead of function")

from the driver-core tree and commits:

27c7518e7f1c ("rust: finish using custom FFI integer types")
1bae8729e50a ("rust: map `long` to `isize` and `char` to `u8`")
15f2f9313a39 ("rust: use the `build_error!` macro, not the hidden function")
4401565fe92b ("rust: add `build_error!` to the prelude")

from the rust tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

--
Cheers,
Stephen Rothwell

diff --cc rust/kernel/miscdevice.rs
index dfb363630c70,9e1b9c0fae9d..000000000000
--- 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,
}