Skip to contentSkip to conversation

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

DISCUSSION Stephen Rothwell 2 participants 2 messages Jul 18, 2025 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hi all,

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

rust/kernel/device_id.rs

between commit:

8d84b32075fb ("rust: device_id: split out index support into a separate trait")

from the driver-core tree and commit:

5e30550558b1 ("rust: enable clippy::as_underscore lint")

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.

Signature · 33 lines
Cheers,
Stephen Rothwell

diff --cc rust/kernel/device_id.rs
index 8ed2c946144c,3dc72ca8cfc2..000000000000
--- a/rust/kernel/device_id.rs
+++ b/rust/kernel/device_id.rs
@@@ -94,16 -77,14 +94,16 @@@ impl<T: RawDeviceId, U, const N: usize
              // SAFETY: by the safety requirement of `RawDeviceId`, we're guaranteed that `T` is
              // layout-wise compatible with `RawType`.
              raw_ids[i] = unsafe { core::mem::transmute_copy(&ids[i].0) };
 -            // SAFETY: by the safety requirement of `RawDeviceId`, this would be effectively
 -            // `raw_ids[i].driver_data = i;`.
 -            unsafe {
 -                raw_ids[i]
 -                    .as_mut_ptr()
 -                    .byte_add(T::DRIVER_DATA_OFFSET)
 -                    .cast::<usize>()
 -                    .write(i);
 +            if let Some(data_offset) = data_offset {
 +                // SAFETY: by the safety requirement of this function, this would be effectively
 +                // `raw_ids[i].driver_data = i;`.
 +                unsafe {
 +                    raw_ids[i]
 +                        .as_mut_ptr()
-                         .byte_offset(data_offset as _)
++                        .byte_add(data_offset)
 +                        .cast::<usize>()
 +                        .write(i);
 +                }
              }
  
              // SAFETY: this is effectively a move: `infos[i] = ids[i].1`. We make a copy here but
#1 lore raw
Quoted 14 lines · Stephen Rothwell

Hi all,

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

rust/kernel/device_id.rs

between commit:

8d84b32075fb ("rust: device_id: split out index support into a separate trait")

from the driver-core tree and commit:

5e30550558b1 ("rust: enable clippy::as_underscore lint")

Quoted 8 lines

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.

Thanks, the diff looks good!

Quoted 34 lines
Signature · 2 lines
Cheers,
Stephen Rothwell
rust/kernel/device_id.rs +1 -1
diff --cc rust/kernel/device_id.rs
index 8ed2c946144c,3dc72ca8cfc2..000000000000
@@@ -94,16 -77,14 +94,16 @@@ impl<T: RawDeviceId, U, const N: usize
              // SAFETY: by the safety requirement of `RawDeviceId`, we're guaranteed that `T` is
              // layout-wise compatible with `RawType`.
              raw_ids[i] = unsafe { core::mem::transmute_copy(&ids[i].0) };
 -            // SAFETY: by the safety requirement of `RawDeviceId`, this would be effectively
 -            // `raw_ids[i].driver_data = i;`.
 -            unsafe {
 -                raw_ids[i]
 -                    .as_mut_ptr()
 -                    .byte_add(T::DRIVER_DATA_OFFSET)
 -                    .cast::<usize>()
 -                    .write(i);
 +            if let Some(data_offset) = data_offset {
 +                // SAFETY: by the safety requirement of this function, this would be effectively
 +                // `raw_ids[i].driver_data = i;`.
 +                unsafe {
 +                    raw_ids[i]
 +                        .as_mut_ptr()
-                         .byte_offset(data_offset as _)
++                        .byte_add(data_offset)
 +                        .cast::<usize>()
 +                        .write(i);
 +                }
              }
 
              // SAFETY: this is effectively a move: `infos[i] = ids[i].1`. We make a copy here but