linux-next: manual merge of the rust tree with the driver-core tree
Subsystems (3)
Hi all,
After merging the rust tree, today's linux-next build (x86_64 allmodconfig) failed like this:
error[E0599]: no method named len_with_nul found for reference &'static ffi::CStr in the current scope
--> rust/kernel/i2c.rs:48:16
| 48 | id.len_with_nul() <= Self::I2C_NAME_SIZE, | ^^^^^^^^^^^^ method not found in `&CStr`
error[E0599]: no method named as_bytes_with_nul found for reference &'static ffi::CStr in the current scope
--> rust/kernel/i2c.rs:51:22
| 51 | let src = id.as_bytes_with_nul(); | ^^^^^^^^^^^^^^^^^ | help: there is a method `to_bytes_with_nul` with a similar name | 51 | let src = id.to_bytes_with_nul(); | ~~~~~~~~~~~~~~~~~
error[E0599]: no method named len_with_nul found for reference &'static ffi::CStr in the current scope
--> rust/kernel/i2c.rs:438:19
|
438 | type_.len_with_nul() <= Self::I2C_TYPE_SIZE,
| ^^^^^^^^^^^^ method not found in `&CStr`error[E0599]: no method named as_bytes_with_nul found for reference &'static ffi::CStr in the current scope
--> rust/kernel/i2c.rs:441:25
|
441 | let src = type_.as_bytes_with_nul();
| ^^^^^^^^^^^^^^^^^
|
help: there is a method `to_bytes_with_nul` with a similar name
|
441 | let src = type_.to_bytes_with_nul();
| ~~~~~~~~~~~~~~~~~error: aborting due to 4 previous errors
For more information about this error, try rustc --explain E0599.
Caused by commit
3b83f5d5e78a ("rust: replace CStr with core::ffi::CStr")
interacting with commits
f3cc26a417b7 ("rust: i2c: add manual I2C device creation abstractions") 57c5bd9aee94 ("rust: i2c: add basic I2C device and driver abstractions")
from the driver-core tree.
I have applied the following (hack) merge resolution for today.
From: Stephen Rothwell <[email protected]>
Date: Thu, 20 Nov 2025 17:01:06 +1100
Subject: [PATCH] fix up 2 for "rust: replace CStr with core::ffi::CStr"
interacting with commits
f3cc26a417b7 ("rust: i2c: add manual I2C device creation abstractions") 57c5bd9aee94 ("rust: i2c: add basic I2C device and driver abstractions")
from the driver-core tree.
--- rust/kernel/i2c.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
rust/kernel/i2c.rs +12 -12
@@ -39,16 +39,16 @@pub struct DeviceId (bindings::i2c_device_id );impl DeviceId { -const I2C_NAME_SIZE :usize =20 ; +// const I2C_NAME_SIZE: usize = 20; /// Create a new device id from an I2C 'id' string. #[inline(always)] pub const fn new (id: &'staticCStr ) ->Self { -build_assert! ( - id.len_with_nul () <=Self ::I2C_NAME_SIZE , -"ID exceeds 20 bytes" - ); -let src = id.as_bytes_with_nul (); +// build_assert!( +// id.len_with_nul() <= Self::I2C_NAME_SIZE, +// "ID exceeds 20 bytes" +// ); +let src = id.to_bytes_with_nul ();let mut i2c: bindings::i2c_device_id = pin_init::zeroed ();let mut i =0 ;while i < src.len () {
@@ -430,15 +430,15 @@ unsafe fn dec_ref(obj: NonNull<Self>) {pub struct I2cBoardInfo (bindings::i2c_board_info );impl I2cBoardInfo { -const I2C_TYPE_SIZE :usize =20 ; +// const I2C_TYPE_SIZE: usize = 20; /// Create a new [`I2cBoardInfo`] for a kernel driver. #[inline(always)] pub const fn new (type_: &'staticCStr , addr:u16 ) ->Self { -build_assert! ( - type_.len_with_nul () <=Self ::I2C_TYPE_SIZE , -"Type exceeds 20 bytes" - ); -let src = type_.as_bytes_with_nul (); +// build_assert!( +// type_.len_with_nul() <= Self::I2C_TYPE_SIZE, +// "Type exceeds 20 bytes" +// ); +let src = type_.to_bytes_with_nul ();let mut i2c_board_info: bindings::i2c_board_info = pin_init::zeroed ();let mut i:usize =0 ;while i < src.len () {
Signature · 5 lines
2.51.1 -- Cheers, Stephen Rothwell
Quoted 2 lines · Stephen Rothwell
I have applied the following (hack) merge resolution for today.
Thanks a lot Stephen for taking the time to do that instead of dropping it.
We should be able to do the same as Tamir did in commit 657403637f7d ("rust: acpi: use core::ffi::CStr method names"), i.e. move the build assert below to then be able to use len() instead:
rust/kernel/i2c.rs +4 -10
@@ -43,11 +43,8 @@ impl DeviceId {/// Create a new device id from an I2C 'id' string. #[inline(always)] pub const fn new (id: &'staticCStr ) ->Self { -build_assert! ( - id.len_with_nul () <=Self ::I2C_NAME_SIZE , -"ID exceeds 20 bytes" - ); -let src = id.as_bytes_with_nul (); +let src = id.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_NAME_SIZE ,"ID exceeds 20 bytes" );let mut i2c: bindings::i2c_device_id = pin_init::zeroed ();let mut i =0 ;while i < src.len () {
@@ -433,11 +430,8 @@ impl I2cBoardInfo {/// Create a new [`I2cBoardInfo`] for a kernel driver. #[inline(always)] pub const fn new (type_: &'staticCStr , addr:u16 ) ->Self { -build_assert! ( - type_.len_with_nul () <=Self ::I2C_TYPE_SIZE , -"Type exceeds 20 bytes" - ); -let src = type_.as_bytes_with_nul (); +let src = type_.to_bytes_with_nul (); + build_assert!(src.len() <= Self::I2C_TYPE_SIZE, "Type exceeds
20 bytes");
let mut i2c_board_info: bindings::i2c_board_info = pin_init::zeroed();
let mut i: usize = 0;
while i < src.len() {Igor/Tamir?
Cheers,
Miguel
Quoted 45 lines · Miguel Ojeda
Quoted 2 lines · Stephen Rothwell
I have applied the following (hack) merge resolution for today.
Thanks a lot Stephen for taking the time to do that instead of dropping it.
We should be able to do the same as Tamir did in commit
657403637f7d("rust: acpi: usecore::ffi::CStrmethod names"), i.e. move the build assert below to then be able to uselen()instead:rust/kernel/i2c.rs +4
-10@@ -43,11 +43,8 @@ impl DeviceId {/// Create a new device id from an I2C 'id' string. #[inline(always)] pub const fn new (id: &'staticCStr ) ->Self { -build_assert! ( - id.len_with_nul () <=Self ::I2C_NAME_SIZE , -"ID exceeds 20 bytes" - ); -let src = id.as_bytes_with_nul (); +let src = id.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_NAME_SIZE ,"ID exceeds 20 bytes" );let mut i2c: bindings::i2c_device_id = pin_init::zeroed ();let mut i =0 ;while i < src.len () {@@ -433,11 +430,8 @@ impl I2cBoardInfo {/// Create a new [`I2cBoardInfo`] for a kernel driver. #[inline(always)] pub const fn new (type_: &'staticCStr , addr:u16 ) ->Self { -build_assert! ( - type_.len_with_nul () <=Self ::I2C_TYPE_SIZE , -"Type exceeds 20 bytes" - ); -let src = type_.as_bytes_with_nul (); +let src = type_.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_TYPE_SIZE ,"Type exceeds 20 bytes" );let mut i2c_board_info: bindings::i2c_board_info = pin_init::zeroed ();let mut i:usize =0 ;while i < src.len() {
Quoted 1 line
Igor/Tamir?
Yep, looks correct to me!
Hi all,
Quoted 47 lines · On Thu, 20 Nov 2025 06:27:13 -0500 Tamir Duberstein <[email protected]> wrote:
Quoted 45 lines · Miguel Ojeda
Quoted 2 lines · Stephen Rothwell
I have applied the following (hack) merge resolution for today.
Thanks a lot Stephen for taking the time to do that instead of dropping it.
We should be able to do the same as Tamir did in commit
657403637f7d("rust: acpi: usecore::ffi::CStrmethod names"), i.e. move the build assert below to then be able to uselen()instead:rust/kernel/i2c.rs +4
-10@@ -43,11 +43,8 @@ impl DeviceId {/// Create a new device id from an I2C 'id' string. #[inline(always)] pub const fn new (id: &'staticCStr ) ->Self { -build_assert! ( - id.len_with_nul () <=Self ::I2C_NAME_SIZE , -"ID exceeds 20 bytes" - ); -let src = id.as_bytes_with_nul (); +let src = id.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_NAME_SIZE ,"ID exceeds 20 bytes" );let mut i2c: bindings::i2c_device_id = pin_init::zeroed ();let mut i =0 ;while i < src.len () {@@ -433,11 +430,8 @@ impl I2cBoardInfo {/// Create a new [`I2cBoardInfo`] for a kernel driver. #[inline(always)] pub const fn new (type_: &'staticCStr , addr:u16 ) ->Self { -build_assert! ( - type_.len_with_nul () <=Self ::I2C_TYPE_SIZE , -"Type exceeds 20 bytes" - ); -let src = type_.as_bytes_with_nul (); +let src = type_.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_TYPE_SIZE ,"Type exceeds 20 bytes" );let mut i2c_board_info: bindings::i2c_board_info = pin_init::zeroed ();let mut i:usize =0 ;while i < src.len() {
Quoted 3 lines
Quoted 1 line
Igor/Tamir?
Yep, looks correct to me!
OK, I have used that from today.
Could that fix just be applied to the driver-core tree now? Or does it depend on changes in the rust tree?
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 51 lines · Stephen Rothwell
Hi all,
Quoted 47 lines · On Thu, 20 Nov 2025 06:27:13 -0500 Tamir Duberstein <[email protected]> wrote:
Quoted 45 lines · Miguel Ojeda
Quoted 2 lines · Stephen Rothwell
I have applied the following (hack) merge resolution for today.
Thanks a lot Stephen for taking the time to do that instead of dropping it.
We should be able to do the same as Tamir did in commit
657403637f7d("rust: acpi: usecore::ffi::CStrmethod names"), i.e. move the build assert below to then be able to uselen()instead:rust/kernel/i2c.rs +4
-10@@ -43,11 +43,8 @@ impl DeviceId {/// Create a new device id from an I2C 'id' string. #[inline(always)] pub const fn new (id: &'staticCStr ) ->Self { -build_assert! ( - id.len_with_nul () <=Self ::I2C_NAME_SIZE , -"ID exceeds 20 bytes" - ); -let src = id.as_bytes_with_nul (); +let src = id.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_NAME_SIZE ,"ID exceeds 20 bytes" );let mut i2c: bindings::i2c_device_id = pin_init::zeroed ();let mut i =0 ;while i < src.len () {@@ -433,11 +430,8 @@ impl I2cBoardInfo {/// Create a new [`I2cBoardInfo`] for a kernel driver. #[inline(always)] pub const fn new (type_: &'staticCStr , addr:u16 ) ->Self { -build_assert! ( - type_.len_with_nul () <=Self ::I2C_TYPE_SIZE , -"Type exceeds 20 bytes" - ); -let src = type_.as_bytes_with_nul (); +let src = type_.to_bytes_with_nul (); +build_assert! (src.len () <=Self ::I2C_TYPE_SIZE ,"Type exceeds 20 bytes" );let mut i2c_board_info: bindings::i2c_board_info = pin_init::zeroed ();let mut i:usize =0 ;while i < src.len() {
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Igor/Tamir?
Yep, looks correct to me!
OK, I have used that from today.
Could that fix just be applied to the driver-core tree now? Or does it depend on changes in the rust tree?
I don't see why not. It does not depend on changes in the rust tree. @Danilo Krummrich?
Quoted 3 lines · Tamir Duberstein
I don't see why not. It does not depend on changes in the rust tree. @Danilo Krummrich?
I think Danilo may not be near a computer at the moment -- Greg, I can send you a patch to apply (or we could just leave this as a conflict resolution to be applied by Linus too).
Cheers,
Miguel
Quoted 8 lines · Miguel Ojeda
Quoted 3 lines · Tamir Duberstein
I don't see why not. It does not depend on changes in the rust tree. @Danilo Krummrich?
I think Danilo may not be near a computer at the moment -- Greg, I can send you a patch to apply (or we could just leave this as a conflict resolution to be applied by Linus too).
I'll take a patch, thanks!
Quoted 2 lines · Greg KH
I'll take a patch, thanks!
and
Quoted 2 lines · Danilo Krummrich
Yes, a patch would be great -- thanks for providing the conflict resolution!
Done:
https://lore.kernel.org/rust-for-linux/[email protected]/
I noticed Stephen's resolution can remove an import too.
Cheers,
Miguel
Danilo Krummrich
reviewerQuoted 8 lines · Miguel Ojeda
Quoted 3 lines · Tamir Duberstein
I don't see why not. It does not depend on changes in the rust tree. @Danilo Krummrich?
I think Danilo may not be near a computer at the moment -- Greg, I can send you a patch to apply (or we could just leave this as a conflict resolution to be applied by Linus too).
Yes, a patch would be great -- thanks for providing the conflict resolution!
- Danilo