Skip to content

Commit 32d61c5

Browse files
tamirdojeda
authored andcommitted
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>
1 parent eeaad2f commit 32d61c5

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

samples/rust/rust_driver_i2c.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
use kernel::{
66
acpi,
7-
c_str,
87
device::Core,
98
i2c,
109
of,
@@ -17,21 +16,21 @@ kernel::acpi_device_table! {
1716
ACPI_TABLE,
1817
MODULE_ACPI_TABLE,
1918
<SampleDriver as i2c::Driver>::IdInfo,
20-
[(acpi::DeviceId::new(c_str!("LNUXBEEF")), 0)]
19+
[(acpi::DeviceId::new(c"LNUXBEEF"), 0)]
2120
}
2221

2322
kernel::i2c_device_table! {
2423
I2C_TABLE,
2524
MODULE_I2C_TABLE,
2625
<SampleDriver as i2c::Driver>::IdInfo,
27-
[(i2c::DeviceId::new(c_str!("rust_driver_i2c")), 0)]
26+
[(i2c::DeviceId::new(c"rust_driver_i2c"), 0)]
2827
}
2928

3029
kernel::of_device_table! {
3130
OF_TABLE,
3231
MODULE_OF_TABLE,
3332
<SampleDriver as i2c::Driver>::IdInfo,
34-
[(of::DeviceId::new(c_str!("test,rust_driver_i2c")), 0)]
33+
[(of::DeviceId::new(c"test,rust_driver_i2c"), 0)]
3534
}
3635

3736
impl i2c::Driver for SampleDriver {

samples/rust/rust_i2c_client.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
7070
use kernel::{
7171
acpi,
72-
c_str,
7372
device,
7473
devres::Devres,
7574
i2c,
@@ -90,20 +89,20 @@ kernel::of_device_table!(
9089
OF_TABLE,
9190
MODULE_OF_TABLE,
9291
<SampleDriver as platform::Driver>::IdInfo,
93-
[(of::DeviceId::new(c_str!("test,rust-device")), ())]
92+
[(of::DeviceId::new(c"test,rust-device"), ())]
9493
);
9594

9695
kernel::acpi_device_table!(
9796
ACPI_TABLE,
9897
MODULE_ACPI_TABLE,
9998
<SampleDriver as platform::Driver>::IdInfo,
100-
[(acpi::DeviceId::new(c_str!("LNUXBEEF")), ())]
99+
[(acpi::DeviceId::new(c"LNUXBEEF"), ())]
101100
);
102101

103102
const SAMPLE_I2C_CLIENT_ADDR: u16 = 0x30;
104103
const SAMPLE_I2C_ADAPTER_INDEX: i32 = 0;
105104
const BOARD_INFO: i2c::I2cBoardInfo =
106-
i2c::I2cBoardInfo::new(c_str!("rust_driver_i2c"), SAMPLE_I2C_CLIENT_ADDR);
105+
i2c::I2cBoardInfo::new(c"rust_driver_i2c", SAMPLE_I2C_CLIENT_ADDR);
107106

108107
impl platform::Driver for SampleDriver {
109108
type IdInfo = ();

0 commit comments

Comments
 (0)