From nobody Sun Feb 8 17:21:57 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58337299A8F; Mon, 22 Dec 2025 12:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766406948; cv=none; b=NNyq44sc1/kHOKRXshSGODJbxpLTVoJeQxhlMxcqsGb7S/cuidhKcSX/2LCFkK4iB8H4v93emStBr5aj/aLiVR8R8o034V9q6Vg9SPp4ZHx6p1HFez+S35PnOCjGwlKmHsjjc7hBOk7cJw6ESqfi6CEjxOQoD5fM+dR/P3+lhbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766406948; c=relaxed/simple; bh=wczg3gxdWuvvrPdCGIwbc3VRTJlOe0wnMFC/o5HTNRk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SUQJmiEII1OdAKK9/UX0lMxcFiS8vsl4bUTwDn6B1jfNJBb5+nVv+4UKPxhyR6FsLSRDGNK8x36MtcHwJO8kHIXWENmQkN4ZSChaW96FMSZaaImzbVfSYNoD3iZc7NJTQPu6hOtogv2zeyp2TTXsnwJKPEXf5TShFS6PQom4ftM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jtumiqxg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jtumiqxg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 407B8C113D0; Mon, 22 Dec 2025 12:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1766406947; bh=wczg3gxdWuvvrPdCGIwbc3VRTJlOe0wnMFC/o5HTNRk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JtumiqxgLd0r6JTZCpsRlxWq5Al63GT1Zw5bmyFekuFx31Xer9T197+fjHD4PoPqu dJFdBFovNWJRoZyIzst7CHHRQeG3yAA0hAT4LihtaaCzxg2l8SiJc8wQ12Ch2iCK7U IMyrYuq2uYVeJLy/+GfevYP6Ad+TNDiQ2rN7oSpzIAha8lF9XozocqA4/TPlgm09Fx OkycMB/n0Mvq3bdxzQMmN6IXoWfyRlVJpw1F/2zbeUfddfchUDXOLFQr1SdnSrajy1 tOCfFm3ksrgBxY2dwl4QaXPdMjp4P39cGXGJGUlc3B5OaSHLLzYUAZYoHo0vaZBmp+ 9/CqJlJdtKgTw== From: Tamir Duberstein Date: Mon, 22 Dec 2025 13:35:29 +0100 Subject: [PATCH 3/7] rust: platform: replace `kernel::c_str!` with C-Strings Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251222-cstr-driver-core-v1-3-1142a177d0fd@gmail.com> References: <20251222-cstr-driver-core-v1-0-1142a177d0fd@gmail.com> In-Reply-To: <20251222-cstr-driver-core-v1-0-1142a177d0fd@gmail.com> To: Greg Kroah-Hartman , Dave Ertman , Ira Weiny , Leon Romanovsky , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , "Rafael J. Wysocki" , Daniel Almeida Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1766406930; l=6208; i=tamird@gmail.com; h=from:subject:message-id; bh=h/sRZfx3QwnPveZU7T8G3CkwT5gXbXtgWKtN6SPI+7U=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QK8iQqIXtLmsMk1B5MtEVatxRm+peIT0xGOFWtdgcBg+uU8IqOOg+Zry5MMgC+C4AnrFEgZ77Ad I97UO0cgQRgE= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein C-String literals were added in Rust 1.77. Replace instances of `kernel::c_str!` with C-String literals where possible. Acked-by: Greg Kroah-Hartman Reviewed-by: Alice Ryhl Reviewed-by: Benno Lossin Acked-by: Danilo Krummrich Signed-off-by: Tamir Duberstein --- rust/kernel/platform.rs | 6 +++--- samples/rust/rust_driver_faux.rs | 4 ++-- samples/rust/rust_driver_platform.rs | 30 ++++++++++++++---------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs index ed889f079cab..abb22a787131 100644 --- a/rust/kernel/platform.rs +++ b/rust/kernel/platform.rs @@ -137,7 +137,7 @@ macro_rules! module_platform_driver { /// # Examples /// ///``` -/// # use kernel::{acpi, bindings, c_str, device::Core, of, platform}; +/// # use kernel::{acpi, bindings, device::Core, of, platform}; /// /// struct MyDriver; /// @@ -146,7 +146,7 @@ macro_rules! module_platform_driver { /// MODULE_OF_TABLE, /// ::IdInfo, /// [ -/// (of::DeviceId::new(c_str!("test,device")), ()) +/// (of::DeviceId::new(c"test,device"), ()) /// ] /// ); /// @@ -155,7 +155,7 @@ macro_rules! module_platform_driver { /// MODULE_ACPI_TABLE, /// ::IdInfo, /// [ -/// (acpi::DeviceId::new(c_str!("LNUXBEEF")), ()) +/// (acpi::DeviceId::new(c"LNUXBEEF"), ()) /// ] /// ); /// diff --git a/samples/rust/rust_driver_faux.rs b/samples/rust/rust_driver_fa= ux.rs index ecc9fd378cbd..23add3160693 100644 --- a/samples/rust/rust_driver_faux.rs +++ b/samples/rust/rust_driver_faux.rs @@ -2,7 +2,7 @@ =20 //! Rust faux device sample. =20 -use kernel::{c_str, faux, prelude::*, Module}; +use kernel::{faux, prelude::*, Module}; =20 module! { type: SampleModule, @@ -20,7 +20,7 @@ impl Module for SampleModule { fn init(_module: &'static ThisModule) -> Result { pr_info!("Initialising Rust Faux Device Sample\n"); =20 - let reg =3D faux::Registration::new(c_str!("rust-faux-sample-devic= e"), None)?; + let reg =3D faux::Registration::new(c"rust-faux-sample-device", No= ne)?; =20 dev_info!(reg.as_ref(), "Hello from faux device!\n"); =20 diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_drive= r_platform.rs index 6bf4f0c9633d..a3044d773176 100644 --- a/samples/rust/rust_driver_platform.rs +++ b/samples/rust/rust_driver_platform.rs @@ -63,7 +63,7 @@ //! =20 use kernel::{ - acpi, c_str, + acpi, device::{ self, property::{FwNodeReferenceArgs, NArgs}, @@ -85,14 +85,14 @@ struct SampleDriver { OF_TABLE, MODULE_OF_TABLE, ::IdInfo, - [(of::DeviceId::new(c_str!("test,rust-device")), Info(42))] + [(of::DeviceId::new(c"test,rust-device"), Info(42))] ); =20 kernel::acpi_device_table!( ACPI_TABLE, MODULE_ACPI_TABLE, ::IdInfo, - [(acpi::DeviceId::new(c_str!("LNUXBEEF")), Info(0))] + [(acpi::DeviceId::new(c"LNUXBEEF"), Info(0))] ); =20 impl platform::Driver for SampleDriver { @@ -124,49 +124,47 @@ impl SampleDriver { fn properties_parse(dev: &device::Device) -> Result { let fwnode =3D dev.fwnode().ok_or(ENOENT)?; =20 - if let Ok(idx) =3D - fwnode.property_match_string(c_str!("compatible"), c_str!("tes= t,rust-device")) - { + if let Ok(idx) =3D fwnode.property_match_string(c"compatible", c"t= est,rust-device") { dev_info!(dev, "matched compatible string idx =3D {}\n", idx); } =20 - let name =3D c_str!("compatible"); + let name =3D c"compatible"; let prop =3D fwnode.property_read::(name).required_by(dev= )?; dev_info!(dev, "'{name}'=3D'{prop:?}'\n"); =20 - let name =3D c_str!("test,bool-prop"); - let prop =3D fwnode.property_read_bool(c_str!("test,bool-prop")); + let name =3D c"test,bool-prop"; + let prop =3D fwnode.property_read_bool(c"test,bool-prop"); dev_info!(dev, "'{name}'=3D'{prop}'\n"); =20 - if fwnode.property_present(c_str!("test,u32-prop")) { + if fwnode.property_present(c"test,u32-prop") { dev_info!(dev, "'test,u32-prop' is present\n"); } =20 - let name =3D c_str!("test,u32-optional-prop"); + let name =3D c"test,u32-optional-prop"; let prop =3D fwnode.property_read::(name).or(0x12); dev_info!(dev, "'{name}'=3D'{prop:#x}' (default =3D 0x12)\n"); =20 // A missing required property will print an error. Discard the er= ror to // prevent properties_parse from failing in that case. - let name =3D c_str!("test,u32-required-prop"); + let name =3D c"test,u32-required-prop"; let _ =3D fwnode.property_read::(name).required_by(dev); =20 - let name =3D c_str!("test,u32-prop"); + let name =3D c"test,u32-prop"; let prop: u32 =3D fwnode.property_read(name).required_by(dev)?; dev_info!(dev, "'{name}'=3D'{prop:#x}'\n"); =20 - let name =3D c_str!("test,i16-array"); + let name =3D c"test,i16-array"; let prop: [i16; 4] =3D fwnode.property_read(name).required_by(dev)= ?; dev_info!(dev, "'{name}'=3D'{prop:?}'\n"); let len =3D fwnode.property_count_elem::(name)?; dev_info!(dev, "'{name}' length is {len}\n"); =20 - let name =3D c_str!("test,i16-array"); + let name =3D c"test,i16-array"; let prop: KVec =3D fwnode.property_read_array_vec(name, 4)?.r= equired_by(dev)?; dev_info!(dev, "'{name}'=3D'{prop:?}' (KVec)\n"); =20 for child in fwnode.children() { - let name =3D c_str!("test,ref-arg"); + let name =3D c"test,ref-arg"; let nargs =3D NArgs::N(2); let prop: FwNodeReferenceArgs =3D child.property_get_reference= _args(name, nargs, 0)?; dev_info!(dev, "'{name}'=3D'{prop:?}'\n"); --=20 2.52.0