rust: i2c: replace `kernel::c_str!` with C-Strings
Tamir Duberstein
reviewercover rust: i2c: replace `kernel::c_str!` with C-Strings
C-String literals were added in Rust 1.77. Replace instances of kernel::c_str! with C-String literals where possible.
---
Tamir Duberstein (2):
rust: i2c: replace kernel::c_str! with C-Strings
samples: rust: i2c: replace kernel::c_str! with C-Strings
rust/kernel/i2c.rs | 8 ++++---- samples/rust/rust_driver_i2c.rs | 7 +++---- samples/rust/rust_i2c_client.rs | 7 +++---- 3 files changed, 10 insertions(+), 12 deletions(-)
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-i2c-fce258eb7e5d
Best regards,
Signature · 1 line
Tamir Duberstein <[email protected]>
Tamir Duberstein
reviewerPATCH 1/2 rust: i2c: replace `kernel::c_str!` with C-Strings
From: Tamir Duberstein <[email protected]>
C-String literals were added in Rust 1.77. Replace instances of kernel::c_str! with C-String literals where possible.
--- rust/kernel/i2c.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
rust/kernel/i2c.rs +4 -4
@@ -253,7 +253,7 @@ macro_rules! module_i2c_driver {/// # Example /// ///``` -/// # use kernel::{acpi, bindings, c_str, device::Core, i2c, of}; +/// # use kernel::{acpi, bindings, device::Core, i2c, of}; /// /// struct MyDriver; ///
@@ -262,7 +262,7 @@ macro_rules! module_i2c_driver {/// MODULE_ACPI_TABLE, /// <MyDriver as i2c::Driver>::IdInfo, /// [ -/// (acpi::DeviceId::new(c_str!("LNUXBEEF")), ()) +/// (acpi::DeviceId::new(c"LNUXBEEF"), ()) /// ] /// ); ///
@@ -271,7 +271,7 @@ macro_rules! module_i2c_driver {/// MODULE_I2C_TABLE, /// <MyDriver as i2c::Driver>::IdInfo, /// [ -/// (i2c::DeviceId::new(c_str!("rust_driver_i2c")), ()) +/// (i2c::DeviceId::new(c"rust_driver_i2c"), ()) /// ] /// ); ///
@@ -280,7 +280,7 @@ macro_rules! module_i2c_driver {/// MODULE_OF_TABLE, /// <MyDriver as i2c::Driver>::IdInfo, /// [ -/// (of::DeviceId::new(c_str!("test,device")), ()) +/// (of::DeviceId::new(c"test,device"), ()) /// ] /// ); ///
Signature · 1 line
2.52.0
Tamir Duberstein
reviewerPATCH 2/2 samples: rust: i2c: replace `kernel::c_str!` with C-Strings
In reply to Tamir DubersteinFrom: Tamir Duberstein <[email protected]>
C-String literals were added in Rust 1.77. Replace instances of kernel::c_str! with C-String literals where possible.
--- samples/rust/rust_driver_i2c.rs | 7 +++---- samples/rust/rust_i2c_client.rs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-)
samples/rust/rust_driver_i2c.rs +3 -4
@@ -4,7 +4,6 @@use kernel::{ acpi, - c_str, device::Core , i2c, of,
@@ -17,21 +16,21 @@ ACPI_TABLE, MODULE_ACPI_TABLE, <SampleDriver as i2c::Driver>::IdInfo, - [(acpi::DeviceId ::new (c_str! ("LNUXBEEF" )),0 )] + [(acpi::DeviceId ::new (c"LNUXBEEF" ),0 )] } kernel::i2c_device_table! {I2C_TABLE ,MODULE_I2C_TABLE , <SampleDriver as i2c::Driver >::IdInfo , - [(i2c::DeviceId ::new (c_str! ("rust_driver_i2c" )),0 )] + [(i2c::DeviceId ::new (c"rust_driver_i2c" ),0 )] } kernel::of_device_table! {OF_TABLE ,MODULE_OF_TABLE , <SampleDriver as i2c::Driver >::IdInfo , - [(of::DeviceId ::new (c_str! ("test,rust_driver_i2c" )),0 )] + [(of::DeviceId ::new (c"test,rust_driver_i2c" ),0 )] }impl i2c::Driver for SampleDriver {
samples/rust/rust_i2c_client.rs +3 -4
@@ -69,7 +69,6 @@use kernel::{ acpi, - c_str, device, devres::Devres , i2c,
@@ -90,20 +89,20 @@ struct SampleDriver { OF_TABLE, MODULE_OF_TABLE, <SampleDriver as platform::Driver>::IdInfo, - [(of::DeviceId ::new (c_str! ("test,rust-device" )), ())] + [(of::DeviceId ::new (c"test,rust-device" ), ())] ); kernel::acpi_device_table!(ACPI_TABLE ,MODULE_ACPI_TABLE , <SampleDriver as platform::Driver >::IdInfo , - [(acpi::DeviceId ::new (c_str! ("LNUXBEEF" )), ())] + [(acpi::DeviceId ::new (c"LNUXBEEF" ), ())] );const SAMPLE_I2C_CLIENT_ADDR :u16 =0x30 ;const SAMPLE_I2C_ADAPTER_INDEX :i32 =0 ;const BOARD_INFO : i2c::I2cBoardInfo = - i2c::I2cBoardInfo ::new (c_str! ("rust_driver_i2c" ),SAMPLE_I2C_CLIENT_ADDR ); + i2c::I2cBoardInfo ::new (c"rust_driver_i2c" ,SAMPLE_I2C_CLIENT_ADDR );impl platform::Driver for SampleDriver {type IdInfo = ();
Signature · 1 line
2.52.0
Quoted 17 lines · Tamir Duberstein
C-String literals were added in Rust 1.77. Replace instances of
kernel::c_str!with C-String literals where possible.Signed-off-by Tamir Duberstein <[email protected]>---
Tamir Duberstein (2):
rust: i2c: replacekernel::c_str!with C-Strings
samples: rust: i2c: replacekernel::c_str!with C-Stringsrust/kernel/i2c.rs | 8 ++++---- samples/rust/rust_driver_i2c.rs | 7 +++---- samples/rust/rust_i2c_client.rs | 7 +++---- 3 files changed, 10 insertions(+), 12 deletions(-)
Quoted 8 lines
---
base-commit:8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-i2c-fce258eb7e5dBest regards,
Signature · 1 line
Tamir Duberstein <[email protected]>
Quoted 13 lines · Tamir Duberstein
C-String literals were added in Rust 1.77. Replace instances of
kernel::c_str!with C-String literals where possible.Signed-off-by Tamir Duberstein <[email protected]>---
Tamir Duberstein (2):
rust: i2c: replacekernel::c_str!with C-Strings
samples: rust: i2c: replacekernel::c_str!with C-Stringsrust/kernel/i2c.rs | 8 ++++---- samples/rust/rust_driver_i2c.rs | 7 +++---- samples/rust/rust_i2c_client.rs | 7 +++---- 3 files changed, 10 insertions(+), 12 deletions(-)
Quoted 8 lines
---
base-commit:8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-i2c-fce258eb7e5dBest regards,
--
Tamir Duberstein <[email protected]>
Since I don’t yet have a public kernel tree, I’d appreciate it if someone could pick this up through their tree.
Thanks
Igor
Quoted 5 lines · Igor Korotin
Acked-by Igor Korotin<[email protected]>Since I don’t yet have a public kernel tree, I’d appreciate it if someone could pick this up through their tree.
I can do that.
Cheers,
Miguel
Miguel Ojeda
AppliedQuoted 5 lines · Tamir Duberstein
C-String literals were added in Rust 1.77. Replace instances of
kernel::c_str!with C-String literals where possible.Signed-off-by Tamir Duberstein <[email protected]>
Applied to rust-next -- thanks everyone!
Cheers,
Miguel