From: Tamir Duberstein <tamird@kernel.org>
To: "Igor Korotin" <igor.korotin.linux@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Tamir Duberstein <tamird@gmail.com>
Subject: [PATCH 2/2] samples: rust: i2c: replace `kernel::c_str!` with C-Strings
Date: Mon, 22 Dec 2025 13:14:33 +0100 [thread overview]
Message-ID: <20251222-cstr-i2c-v1-2-df1c258d4615@gmail.com> (raw)
In-Reply-To: <20251222-cstr-i2c-v1-0-df1c258d4615@gmail.com>
From: Tamir Duberstein <tamird@gmail.com>
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>
---
samples/rust/rust_driver_i2c.rs | 7 +++----
samples/rust/rust_i2c_client.rs | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/samples/rust/rust_driver_i2c.rs b/samples/rust/rust_driver_i2c.rs
index ecefeca3e22f..6be79f9e9fb5 100644
--- a/samples/rust/rust_driver_i2c.rs
+++ b/samples/rust/rust_driver_i2c.rs
@@ -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 {
diff --git a/samples/rust/rust_i2c_client.rs b/samples/rust/rust_i2c_client.rs
index f67938396dce..8d2c12e535b0 100644
--- a/samples/rust/rust_i2c_client.rs
+++ b/samples/rust/rust_i2c_client.rs
@@ -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 = ();
--
2.52.0
next prev parent reply other threads:[~2025-12-22 12:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 12:14 [PATCH 0/2] " Tamir Duberstein
2025-12-22 12:14 ` [PATCH 1/2] " Tamir Duberstein
2025-12-22 12:14 ` Tamir Duberstein [this message]
2025-12-22 14:37 ` [PATCH 0/2] " Daniel Almeida
2025-12-22 18:17 ` Igor Korotin
2025-12-22 18:45 ` Miguel Ojeda
2026-01-19 8:20 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251222-cstr-i2c-v1-2-df1c258d4615@gmail.com \
--to=tamird@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=igor.korotin.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@gmail.com \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®