Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

samples: 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.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Acked-by: Igor Korotin <igor.korotin.linux@gmail.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://patch.msgid.link/20251222-cstr-i2c-v1-2-df1c258d4615@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Tamir Duberstein and committed by
Miguel Ojeda
32d61c51 eeaad2f0

+6 -8
+3 -4
samples/rust/rust_driver_i2c.rs
··· 4 4 5 5 use kernel::{ 6 6 acpi, 7 - c_str, 8 7 device::Core, 9 8 i2c, 10 9 of, ··· 16 17 ACPI_TABLE, 17 18 MODULE_ACPI_TABLE, 18 19 <SampleDriver as i2c::Driver>::IdInfo, 19 - [(acpi::DeviceId::new(c_str!("LNUXBEEF")), 0)] 20 + [(acpi::DeviceId::new(c"LNUXBEEF"), 0)] 20 21 } 21 22 22 23 kernel::i2c_device_table! { 23 24 I2C_TABLE, 24 25 MODULE_I2C_TABLE, 25 26 <SampleDriver as i2c::Driver>::IdInfo, 26 - [(i2c::DeviceId::new(c_str!("rust_driver_i2c")), 0)] 27 + [(i2c::DeviceId::new(c"rust_driver_i2c"), 0)] 27 28 } 28 29 29 30 kernel::of_device_table! { 30 31 OF_TABLE, 31 32 MODULE_OF_TABLE, 32 33 <SampleDriver as i2c::Driver>::IdInfo, 33 - [(of::DeviceId::new(c_str!("test,rust_driver_i2c")), 0)] 34 + [(of::DeviceId::new(c"test,rust_driver_i2c"), 0)] 34 35 } 35 36 36 37 impl i2c::Driver for SampleDriver {
+3 -4
samples/rust/rust_i2c_client.rs
··· 69 69 70 70 use kernel::{ 71 71 acpi, 72 - c_str, 73 72 device, 74 73 devres::Devres, 75 74 i2c, ··· 89 90 OF_TABLE, 90 91 MODULE_OF_TABLE, 91 92 <SampleDriver as platform::Driver>::IdInfo, 92 - [(of::DeviceId::new(c_str!("test,rust-device")), ())] 93 + [(of::DeviceId::new(c"test,rust-device"), ())] 93 94 ); 94 95 95 96 kernel::acpi_device_table!( 96 97 ACPI_TABLE, 97 98 MODULE_ACPI_TABLE, 98 99 <SampleDriver as platform::Driver>::IdInfo, 99 - [(acpi::DeviceId::new(c_str!("LNUXBEEF")), ())] 100 + [(acpi::DeviceId::new(c"LNUXBEEF"), ())] 100 101 ); 101 102 102 103 const SAMPLE_I2C_CLIENT_ADDR: u16 = 0x30; 103 104 const SAMPLE_I2C_ADAPTER_INDEX: i32 = 0; 104 105 const BOARD_INFO: i2c::I2cBoardInfo = 105 - i2c::I2cBoardInfo::new(c_str!("rust_driver_i2c"), SAMPLE_I2C_CLIENT_ADDR); 106 + i2c::I2cBoardInfo::new(c"rust_driver_i2c", SAMPLE_I2C_CLIENT_ADDR); 106 107 107 108 impl platform::Driver for SampleDriver { 108 109 type IdInfo = ();