From nobody Sun Dec 14 06:16:54 2025 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 57179264628; Sat, 18 Oct 2025 19:16:40 +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=1760815000; cv=none; b=f9xClykAd9iAdnJ9tFozFhNF6Ly11vXJgRVf3AstMyjvQ8zoEIV932oDD0JjdJB1y4VQdhOsCH+5yp5WD75C3kXAptj72zStklfzitgz3izJxgZDukRy/ViiWGdXuz98iRfHx2ScRNZzisvfiThJ/YkqP+HpMW9wYK8eWgkyN4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815000; c=relaxed/simple; bh=C/oRk6L2M1VkY7xKBMS5ZMJ8LE5yFtLvwMHX6+hqOxA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C7y+h40WP7OpRbmWd5Fkp8om8dmw8Fk8meAsAJBlI3ctkiIbuoH32ZjoZ/eMztE6nt6cTzv9osJTRpsCmJxHcJXxeNLT3l2MQAKKIqnVOD6IzFHDx2f/h+L96mV/f7D/rxr5eFt0gcKhlCZFcAjkd33z9LiUQbwrFzvHp030dp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ffmzT0BQ; 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="ffmzT0BQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E148FC113D0; Sat, 18 Oct 2025 19:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760814999; bh=C/oRk6L2M1VkY7xKBMS5ZMJ8LE5yFtLvwMHX6+hqOxA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ffmzT0BQLpFASxz1wAbiwkDhaUXcLcXDaBDPawZYky792LHnQQkEcZLYzQ77G04xJ 9u1U/rmI6GfszQeOISTm9zMEbvNdsu5I1NNMbsEG/0W629DU4VzY+Dob+mDb4pyG1J aXC00UBVOYciS0PQWHtgXLA/5a+juNvAgXkAbMOZPhjcAalDSgyibn0WAjVZYqZRBj enTyjTLLfgTbTW4x0tzSB9mOx+QrzSn9LnrsVVsxl63q9CIyj0n40TmxaTc1UF/r8g HXt4sjJG2P9rN8mJu5nch20yeVrYaZP5b5Hy9GHSRzf7uywM0z5C3WEL+QMdfoq4fl Qp3c0CHNGvruw== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:22 -0400 Subject: [RESEND PATCH v18 01/16] samples: rust: platform: remove trailing commas 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: <20251018-cstr-core-v18-1-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=1642; i=tamird@gmail.com; h=from:subject:message-id; bh=5IzviSKzcg5QXxBA9uZe2s664KTsV8Tne2rtRwo/bww=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QGFOQ9P1ygqKYue8QBUD63+vl5I5OZhEnEQypfM8/m49Pku6mJjUNDELTnaH5fNEKD7axzy9NwF E+2LbMtqURAg= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein This prepares for a later commit in which we introduce a custom formatting macro; that macro doesn't handle trailing commas so just remove them. Acked-by: Danilo Krummrich Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- samples/rust/rust_driver_platform.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_drive= r_platform.rs index 6473baf4f120..8a82e251820f 100644 --- a/samples/rust/rust_driver_platform.rs +++ b/samples/rust/rust_driver_platform.rs @@ -146,7 +146,7 @@ fn properties_parse(dev: &device::Device) -> Result { =20 let name =3D c_str!("test,u32-optional-prop"); let prop =3D fwnode.property_read::(name).or(0x12); - dev_info!(dev, "'{name}'=3D'{prop:#x}' (default =3D 0x12)\n",); + 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. @@ -161,7 +161,7 @@ fn properties_parse(dev: &device::Device) -> Result { 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",); + dev_info!(dev, "'{name}' length is {len}\n"); =20 let name =3D c_str!("test,i16-array"); let prop: KVec =3D fwnode.property_read_array_vec(name, 4)?.r= equired_by(dev)?; --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 8FF0C264628; Sat, 18 Oct 2025 19:16:45 +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=1760815005; cv=none; b=HtcTp1LOuSUipD7aVw0U3y4BzjP8LfVlKMr3nlsOAhZzY/VDtw1o5+YFkUfLcx1rvahddZLQ+WbMKW93ZZFdMv86Ne5Lcc3pkdsKajho5YFAtoC+M1lsMOr+M7bT3CYcexUtiSB4AgJ+7xXTM2f+WvXlUFSK/ZYjndWiFvp4TcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815005; c=relaxed/simple; bh=FXpiJO4Szqw/E4PskiE/Nb1PmghCqw89WwTByz9xO7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PFy51hEYByyUUX+E1E7GkP7mOazTE41OGK84ijpa3fREE6CXW2fwJnH2VGOADDCAVZ+wgE1R239fffceARVhFTqGtWinFxO9oV91SZCK9RVOpVprW2sxdr3Nd9P8fiiHivSEVpCUziJDFf8MYPrTH+KvfYGIt/K5BifyN96mYmA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A/dpn0uV; 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="A/dpn0uV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A377C4CEF9; Sat, 18 Oct 2025 19:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815005; bh=FXpiJO4Szqw/E4PskiE/Nb1PmghCqw89WwTByz9xO7w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A/dpn0uVxITbU6P2OKgIIpSWGQ3PRIKee8oc/CVpAkmcP7+KGmUsIUreLpHX+sF3w hdCw0qGG1bIPjEAUFiOBCgVQ9CwJwj++BpYZJSwz/xt76JJ3jU+LWRV+TbSEFd7dE6 D587PewuJAn6SWONEy97LP9kayvQGcsMPMjS9b37cvQcju5SP7dZGlYZnejWc2/cRJ mEBazmyzSu6oMBSb/FtWH1lpz3905ulF+CqNsUjKXFawpndVXBH1p8htdSzNA4sqfo K8kao+zOe+3SBcwuYls4kcrKYWlkUZOIznEFkuoNVIuda/xnqZfGAn7JhKNAdVcK7P 4LQZWaDTcgp2w== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:23 -0400 Subject: [RESEND PATCH v18 02/16] rust_binder: remove trailing comma 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: <20251018-cstr-core-v18-2-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=981; i=tamird@gmail.com; h=from:subject:message-id; bh=6FtTg88GY2fWPari0/xVYIFZl0LtyM/QigeE2PMN1js=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QBzpNh+4gws9u4pKOIjLa44Nt+SlBTBcXIDZ9dAT5dByUahiamCRo1CqKlvXc21TQxnXcZ/H5IM oOjoaFrgTsg0= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein This prepares for a later commit in which we introduce a custom formatting macro; that macro doesn't handle trailing commas so just remove this one. Reviewed-by: Alice Ryhl Signed-off-by: Tamir Duberstein --- drivers/android/binder/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/pro= cess.rs index f13a747e784c..d8111c990f21 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -596,7 +596,7 @@ pub(crate) fn debug_print(&self, m: &SeqFile, ctx: &Con= text, print_all: bool) -> " ref {}: desc {} {}node {debug_id} s {strong} w {wea= k}", r.debug_id, r.handle, - if dead { "dead " } else { "" }, + if dead { "dead " } else { "" } ); } } --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 BEB39258EE9; Sat, 18 Oct 2025 19:16:50 +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=1760815011; cv=none; b=i/x4VDDAtevEUtVQ1b6TPFu/9JltPz5obga30k2g1AsSqGMMN13o22dwZwklG4R5O8oa8Ake4v6LnUkNK8khQZGzfnu4WzsCNhV6uXLGLcm+nCvgd+P8uNSdctJ7Ly7zHix6EmDYbcmcJ9UrDnh16pMa4LoNruAJK5HHR5sxSKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815011; c=relaxed/simple; bh=xy9KhFtMrJL0pHddpVZl1kgvFuS3w9PeKpCdtFzbvlc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YU+0TigW+Ltk6PaKV7yeeOIJ44sHGEX5J6nZeoDdMA47Y1DEaWwOfuPIis/KcA5k0dMZCslBPndkPl36vIHQ///XMu3kaseE/ymGIE3+YXfPAqr04ZK06hqWAxdp49PBdc8JEugTVV76qdT5N3Hsq9lBSpXxd4uXWcYFG6V+fxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MAF8qiyv; 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="MAF8qiyv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 671B4C116D0; Sat, 18 Oct 2025 19:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815010; bh=xy9KhFtMrJL0pHddpVZl1kgvFuS3w9PeKpCdtFzbvlc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MAF8qiyvOOp7PaCVz62rkatdSUnjmtTaDht+rVIZp2nz5f0I1J/X8j6DGXD3JhuS3 8AAk/nSnc4GsqBPr47HRzNSbV/BIlNHuPhf9MmU88ZXNsLQ8nBHmlm9s1cTA6Kf8uI UxCy6hNAl1N7Mu2VVSXPr+xi8630AbPCNWZxlhgk/2gAtjdLdLVFoTRalGCapra/5J ueb6fgodvNKonlI49tTjO/yeODdb3hiu0IDFRWnn5wgjrgkqlTYgBOLBOaaCbkkHe5 AADCB3HZgyuBOXnLstEgqamC+2A9z2BpqUom57Jqu2GKYzk98rap0R31ouFburJ1WS RCEZ+5jvUzQVg== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:24 -0400 Subject: [RESEND PATCH v18 03/16] rust_binder: use `kernel::fmt` 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: <20251018-cstr-core-v18-3-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=1195; i=tamird@gmail.com; h=from:subject:message-id; bh=872/2/9eITdb9tB+ajd4McXNzNIKi7XLnXFm8ifjokI=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QENfku/AC1lpGBbf8FzC/fbLAnFquJtwb8rlTAkzyEbW5sDKgV8/QSES2q+QdvmRTiEG8sP7vEu nLaNzwzcjngo= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit eafedbc7c050 ("rust_binder: add Rust Binder driver"). Reviewed-by: Alice Ryhl Signed-off-by: Tamir Duberstein --- drivers/android/binder/error.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/error.rs b/drivers/android/binder/error= .rs index 9921827267d0..b24497cfa292 100644 --- a/drivers/android/binder/error.rs +++ b/drivers/android/binder/error.rs @@ -2,6 +2,7 @@ =20 // Copyright (C) 2025 Google LLC. =20 +use kernel::fmt; use kernel::prelude::*; =20 use crate::defs::*; @@ -76,8 +77,8 @@ fn from(_: kernel::alloc::AllocError) -> Self { } } =20 -impl core::fmt::Debug for BinderError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl fmt::Debug for BinderError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.reply { BR_FAILED_REPLY =3D> match self.source.as_ref() { Some(source) =3D> f --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 03614258EE9; Sat, 18 Oct 2025 19:16:55 +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=1760815016; cv=none; b=J0CmjeNOcJRdmBZZzvfffXhSur0CDXmF+YU0Lin5Nw7rHHEK9rL0JUZjP0MKgrJ2I5pvuQvEAS0EqgquDvCfNiJbJLCljfG0EBC5tMvb6yD743fM73do7MBBDgTK7Om/b4PnkyKeiPC9LLDVxIjbpA3r6r7l5YH/+SpleF7gvDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815016; c=relaxed/simple; bh=9LhvWou7G5dVbTmjrsdy5e0TkJCQPliP776plHYC17E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CYYjro0VH7y/3TfH9U6CPepkR5UL5H6VUXci9OsvyorOJhl10ygJygtQF3kGgNFocw3hvHkLJpnf3sOQvDow3qckeP+6wS7NiIla1Cklj//kVnLxzo4WoT9QgTmKC7z6/CooZIr8/qN/df6aRYVxJJXPMjD1b7eqknamq1fpDfA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EVpHCgCg; 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="EVpHCgCg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BEDEC4CEF8; Sat, 18 Oct 2025 19:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815015; bh=9LhvWou7G5dVbTmjrsdy5e0TkJCQPliP776plHYC17E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EVpHCgCglUuSzWWBOy6UM2ApQN/yiszXbiLJPH1PfAqCfAQU9WxzoSDSdSC2WD//S ttDP5vD8u+Y3tAHzLkaFkoQxfwc2ybunv9EB+U4XLNR6SHUcAH7k85vaBGqdNn2/xk jGVuZxJ97D5SbZua0nXLKpxpSWcN3Q8l0mlHFOSs6Cwdc+tKXEa4mjyZHHqMle5cRq eGNMqFQGp7mOwsOdOxbhGxdy1nkAW6b4VyxGTQtSo4+erkrrblkg1fdd8iOOqIb3AL UuvDApgK2frAl2zRXIa7Swn6Bzhn3YBrpk5QcuIVN6vC7wvCLsb0R+JXlhOTRtKBcK mAWcYbdKzf/Lg== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:25 -0400 Subject: [RESEND PATCH v18 04/16] rust_binder: use `core::ffi::CStr` method names 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: <20251018-cstr-core-v18-4-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=1838; i=tamird@gmail.com; h=from:subject:message-id; bh=CzY30Cbw7NH9BCqW+7Dm4yyfJiEmTcSRj3QBxiZsJWU=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QGKnwLKVQOVzkv6XWwoUcKi5zayaleBer7N1SbPSdgP4G1dPmmKelZJcZlDvRAxk+fUPfLSjD7W vdhR6W6wsugw= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by avoiding methods that only exist on the latter. This backslid in commit eafedbc7c050 ("rust_binder: add Rust Binder driver"). Reviewed-by: Alice Ryhl Signed-off-by: Tamir Duberstein --- drivers/android/binder/stats.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/stats.rs b/drivers/android/binder/stats= .rs index a83ec111d2cb..10c43679d5c3 100644 --- a/drivers/android/binder/stats.rs +++ b/drivers/android/binder/stats.rs @@ -72,7 +72,7 @@ pub(super) fn command_string(i: usize) -> &'static str { // SAFETY: Accessing `binder_command_strings` is always safe. let c_str_ptr =3D unsafe { binder_command_strings[i] }; // SAFETY: The `binder_command_strings` array only contains nul-te= rminated strings. - let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes(); + let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes(); // SAFETY: The `binder_command_strings` array only contains string= s with ascii-chars. unsafe { from_utf8_unchecked(bytes) } } @@ -81,7 +81,7 @@ pub(super) fn return_string(i: usize) -> &'static str { // SAFETY: Accessing `binder_return_strings` is always safe. let c_str_ptr =3D unsafe { binder_return_strings[i] }; // SAFETY: The `binder_command_strings` array only contains nul-te= rminated strings. - let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes(); + let bytes =3D unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes(); // SAFETY: The `binder_command_strings` array only contains string= s with ascii-chars. unsafe { from_utf8_unchecked(bytes) } } --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 E9CE0286D4E; Sat, 18 Oct 2025 19:17:00 +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=1760815021; cv=none; b=LFJ944f4CIwthrsi1/b4XlbErMioFQqTzPXqWeiXBgmfLczxPMoymmuj3vNXqvELuqh9NhDvjjCclxtcastbZLctPzUGz8zS8FNBIG9GV6dHVufUg/Vg7DWNKj0ArI6D4CRxCDfbh8dgFpJjwfVCPVILyyzK8A9SNpGlaAaqSQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815021; c=relaxed/simple; bh=zq8ZZSTx0wtDZS7p9V2Exh4y8hukG/w63T6kuwqnzpg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QggkD7TprsiO6+x3lQ4hVq3m6k3FlNik9ff1r7o9YE2GLY15um1EmJHe9QaKW/q14LZ0y5qkqfA/4354kyOgtSV2mdLklpSXyfrherJEllHuG7bxQRxpsl1vsBWKMltTVDgEE8qpZm+e/ykX1Ok9dud9wHq4aeVwNigcwiBCqnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sF/dDnzQ; 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="sF/dDnzQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56A0C4CEF9; Sat, 18 Oct 2025 19:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815020; bh=zq8ZZSTx0wtDZS7p9V2Exh4y8hukG/w63T6kuwqnzpg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sF/dDnzQ1AW/O0adrL/uV/vdvHsxlZ8JyvLE8P88l9AyFnkwySyXL5v7kXg/Ei1bG EEUiBtaVPCxpg8ZWDDMWc8MxlTb+OjuUwEW3kiYwwCfY77CmFI3ou4cfwBoECfNZH8 poMWJK4bzO47uK7d71Ch0GzkvU6AaMCqxRFS9F6K7yGoUUze+nuCZbiZGUORZciLy5 iL9gemKlRo3MaYhBaxBbCsYJuvVqqnosnVYkiKwo+/hjTyuPaTZDnmtGPVdOg9hp5o +/UzrDgTg2Wa6IbzvOxtHwwXYCpyg1JRrxmPDoyiMdtkt36aFXwCqzko3ckRx52Pc1 h3lX2850d+b7A== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:26 -0400 Subject: [RESEND PATCH v18 05/16] rnull: use `kernel::fmt` 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: <20251018-cstr-core-v18-5-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=1568; i=tamird@gmail.com; h=from:subject:message-id; bh=/cgHz1cX/7pqPCiwokdGYY23t2YMKDX7WgaCRbImZEk=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QJ/PmevHPhp8DzRHsrzWbU8v0C6eSwUNwuXLLqBbMrJ4kdfHBVHJwHSm0CqHi8vBvyTw3Nam4DI U+boko+GNOg4= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit d969d504bc13 ("rnull: enable configuration via `configfs`") and commit 34585dc649fb ("rnull: add soft-irq completion support"). Acked-by: Andreas Hindborg Signed-off-by: Tamir Duberstein --- drivers/block/rnull/configfs.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/block/rnull/configfs.rs b/drivers/block/rnull/configfs= .rs index 8498e9bae6fd..6713a6d92391 100644 --- a/drivers/block/rnull/configfs.rs +++ b/drivers/block/rnull/configfs.rs @@ -1,12 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 =20 use super::{NullBlkDevice, THIS_MODULE}; -use core::fmt::{Display, Write}; use kernel::{ block::mq::gen_disk::{GenDisk, GenDiskBuilder}, c_str, configfs::{self, AttributeOperations}, - configfs_attrs, new_mutex, + configfs_attrs, + fmt::{self, Write as _}, + new_mutex, page::PAGE_SIZE, prelude::*, str::{kstrtobool_bytes, CString}, @@ -99,8 +100,8 @@ fn try_from(value: u8) -> Result { } } =20 -impl Display for IRQMode { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl fmt::Display for IRQMode { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::None =3D> f.write_str("0")?, Self::Soft =3D> f.write_str("1")?, --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 1DB2A286426; Sat, 18 Oct 2025 19:17:06 +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=1760815026; cv=none; b=j/zZR/DyOTsUN6PRRIIzDsYe82M62bQZn83TZHkhA8NlB5lNboMyCjNkVXlPGbqxW03YiGYl6IxDUM1vsKJPHYojYhY2Dd1+0s7nmvmYRB37u7W2FYohSR/bOd7EIWz4rFY60kUHRBGubey0W0UQeQxaoxnMjCe4BDlxQA4fjqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815026; c=relaxed/simple; bh=+J7ZDXd3uQ/1GkoKOuS9uOo+Km8UCQlhgVmpqkVteu8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FYJndrbVvH7YukfiQfIGgI4/UOvVj8y/cl/aLulTwai2kz3fZoYEpbL3PFxgAf43bitZPeJI8PgdS3yhFiD2SD+OnzjoDsW1yo3LZV/Vm8AFOJyg8PSISFauDjA2GHmq21AYkHchdprZYICUG1nw2xDcQLa/aQNtAeDR1tNCdYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rdb4ZBFB; 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="Rdb4ZBFB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09E1FC4CEF8; Sat, 18 Oct 2025 19:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815026; bh=+J7ZDXd3uQ/1GkoKOuS9uOo+Km8UCQlhgVmpqkVteu8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Rdb4ZBFBOqUXjkBE8zOpeiiZXAN2GbWcU77iJLXrkor1jDoVY0DpJ3KRvs1y99bxX m4l/bK3blzMAqX+TTf61d7a/EZ+dWnOinqnoPgUN4kjbat85OnpfoBXoV/xiddY43C f8HXWVntKBwDoSVtpJW1p3P8yVsgYTb/7ZysIXJLfHQGudMrzOZa032uNT48FuE1XQ w/Orq/L4fi6KWLKUtls1fNYPag/xlr9aQa2bWRXPU6LAYZYAyethsIZTGKcvpBVPJe NjzMZ8UyLV946cRTpwxHgzMzhyhGkJMabHfr+T9fEDtU8d/3k1ohQDNNGipTcFpVVB 7aIt1/VGve0hw== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:27 -0400 Subject: [RESEND PATCH v18 06/16] rust: alloc: use `kernel::fmt` 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: <20251018-cstr-core-v18-6-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=2039; i=tamird@gmail.com; h=from:subject:message-id; bh=VZx3xyzuE8sdJWwvMWeYLSbsWBC7U7VUNVHO5x1zs/Y=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QJHdEeRE7pQl/p0QRGuCzQ7Ms+9Tlb7y4U2r1vQjNSe9inKMkJqdvw5D0RsFqU1WEd1pada5oWK 2xrUccsoLWAs= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit 9def0d0a2a1c ("rust: alloc: add Vec::push_within_capacity"). Reviewed-by: Alice Ryhl Acked-by: Danilo Krummrich Signed-off-by: Tamir Duberstein --- rust/kernel/alloc/kvec/errors.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rust/kernel/alloc/kvec/errors.rs b/rust/kernel/alloc/kvec/erro= rs.rs index 21a920a4b09b..e7de5049ee47 100644 --- a/rust/kernel/alloc/kvec/errors.rs +++ b/rust/kernel/alloc/kvec/errors.rs @@ -2,14 +2,14 @@ =20 //! Errors for the [`Vec`] type. =20 -use kernel::fmt::{self, Debug, Formatter}; +use kernel::fmt; use kernel::prelude::*; =20 /// Error type for [`Vec::push_within_capacity`]. pub struct PushError(pub T); =20 -impl Debug for PushError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Debug for PushError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Not enough capacity") } } @@ -25,8 +25,8 @@ fn from(_: PushError) -> Error { /// Error type for [`Vec::remove`]. pub struct RemoveError; =20 -impl Debug for RemoveError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Debug for RemoveError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Index out of bounds") } } @@ -45,8 +45,8 @@ pub enum InsertError { OutOfCapacity(T), } =20 -impl Debug for InsertError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl fmt::Debug for InsertError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { InsertError::IndexOutOfBounds(_) =3D> write!(f, "Index out of = bounds"), InsertError::OutOfCapacity(_) =3D> write!(f, "Not enough capac= ity"), --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 0A96B28B415; Sat, 18 Oct 2025 19:17:11 +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=1760815032; cv=none; b=KIjrOWwZhRuMmXbSJOnmji1lqGucHOEVUjjq/tKUuCBlcVFJ6/0CaiMXHxqtFdTMHTj2sGcRqudt2vZCP5v4obhMYH8StU7jB4mQkos5RLDSmmoSsUWNKg/nZWUsBV2WPmKLqMMCfrc7d89Vh0JG8MsJws3blSchv7H73jEM3WI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815032; c=relaxed/simple; bh=fJabrPUxe/0BzRSdGSTnGlGPwAz5wbczhVYqBvgrLLI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H18K8nE1lrr+1EXjVemd7HGVnCw01AwRqHjlWtaiYHISDMR14H1Bw6lhITcwGY/WL3KVWBkA+NNvy/9N7yT0ZYKE2pIJkFBHR208MmUiPAMxr6LTEWUy3ullALyBSJNYwHexwBXIY4poEHbEIcL2GdRSCWJvzf4OqzfGJn55Ips= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QCD74lRh; 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="QCD74lRh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B232C4CEF9; Sat, 18 Oct 2025 19:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815031; bh=fJabrPUxe/0BzRSdGSTnGlGPwAz5wbczhVYqBvgrLLI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QCD74lRhyTIsOoeBfH6mAy2YDTiLur6l8EL36/KC/gZ13zjZy3BzCtVt6vx3Rln0J 7h5BEF0mt4RmPrXavxluZepBBRcEh0CH17+h8UiY4gozAXtTM+E0ADJp6avB/lqoP9 Cxo9wbwbA1qxiFGmEySInciL8nXhLuHWYhsTWb2TrlINlbT/B8iPPBFNzpgoyfRyaZ BZyuOiGeQC6KWtrwSaELSyieDlI29Djzgt/7MfOlXRt5G3VC5gzNn5BZZ+El8Bo8ig LtSzxpSs/SnVauFXAC1QJQ56Kq2YZF6MhJ2gswvPgQuyeq3emQPP+DqkJ0hqo3qquQ WZUox8/rzgZUA== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:28 -0400 Subject: [RESEND PATCH v18 07/16] rust: debugfs: use `kernel::fmt` 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: <20251018-cstr-core-v18-7-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein , Matthew Maurer X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=4664; i=tamird@gmail.com; h=from:subject:message-id; bh=2RO1O8x8vlwhifkhfd816jOQiIu5L43+GQ3qhkZvCCc=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QGNJfGku7Uu7NvyKkNEwrEqxvI/AmZxlQE8vnZn/IZ7EV7W/LhqTlclv+M+5nbMh+MNdgCGx6ur t8Sj0GlS3ZgM= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit 40ecc49466c8 ("rust: debugfs: Add support for callback-based files") and commit 5e40b591cb46 ("rust: debugfs: Add support for read-only files"). Acked-by: Danilo Krummrich Reviewed-by: Matthew Maurer Signed-off-by: Tamir Duberstein --- rust/kernel/debugfs.rs | 2 +- rust/kernel/debugfs/callback_adapters.rs | 7 +++---- rust/kernel/debugfs/file_ops.rs | 6 +++--- rust/kernel/debugfs/traits.rs | 10 +++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/rust/kernel/debugfs.rs b/rust/kernel/debugfs.rs index 381c23b3dd83..8c35d032acfe 100644 --- a/rust/kernel/debugfs.rs +++ b/rust/kernel/debugfs.rs @@ -8,12 +8,12 @@ // When DebugFS is disabled, many parameters are dead. Linting for this is= n't helpful. #![cfg_attr(not(CONFIG_DEBUG_FS), allow(unused_variables))] =20 +use crate::fmt; use crate::prelude::*; use crate::str::CStr; #[cfg(CONFIG_DEBUG_FS)] use crate::sync::Arc; use crate::uaccess::UserSliceReader; -use core::fmt; use core::marker::PhantomData; use core::marker::PhantomPinned; #[cfg(CONFIG_DEBUG_FS)] diff --git a/rust/kernel/debugfs/callback_adapters.rs b/rust/kernel/debugfs= /callback_adapters.rs index 6c024230f676..a260d8dee051 100644 --- a/rust/kernel/debugfs/callback_adapters.rs +++ b/rust/kernel/debugfs/callback_adapters.rs @@ -5,10 +5,9 @@ //! than a trait implementation. If provided, it will override the trait i= mplementation. =20 use super::{Reader, Writer}; +use crate::fmt; use crate::prelude::*; use crate::uaccess::UserSliceReader; -use core::fmt; -use core::fmt::Formatter; use core::marker::PhantomData; use core::ops::Deref; =20 @@ -76,9 +75,9 @@ fn deref(&self) -> &D { =20 impl Writer for FormatAdapter where - F: Fn(&D, &mut Formatter<'_>) -> fmt::Result + 'static, + F: Fn(&D, &mut fmt::Formatter<'_>) -> fmt::Result + 'static, { - fn write(&self, fmt: &mut Formatter<'_>) -> fmt::Result { + fn write(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { // SAFETY: FormatAdapter<_, F> can only be constructed if F is inh= abited let f: &F =3D unsafe { materialize_zst() }; f(&self.inner, fmt) diff --git a/rust/kernel/debugfs/file_ops.rs b/rust/kernel/debugfs/file_ops= .rs index 50fead17b6f3..9ad5e3fa6f69 100644 --- a/rust/kernel/debugfs/file_ops.rs +++ b/rust/kernel/debugfs/file_ops.rs @@ -3,11 +3,11 @@ =20 use super::{Reader, Writer}; use crate::debugfs::callback_adapters::Adapter; +use crate::fmt; use crate::prelude::*; use crate::seq_file::SeqFile; use crate::seq_print; use crate::uaccess::UserSlice; -use core::fmt::{Display, Formatter, Result}; use core::marker::PhantomData; =20 #[cfg(CONFIG_DEBUG_FS)] @@ -65,8 +65,8 @@ fn deref(&self) -> &Self::Target { =20 struct WriterAdapter(T); =20 -impl<'a, T: Writer> Display for WriterAdapter<&'a T> { - fn fmt(&self, f: &mut Formatter<'_>) -> Result { +impl<'a, T: Writer> fmt::Display for WriterAdapter<&'a T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.write(f) } } diff --git a/rust/kernel/debugfs/traits.rs b/rust/kernel/debugfs/traits.rs index ab009eb254b3..ad33bfbc7669 100644 --- a/rust/kernel/debugfs/traits.rs +++ b/rust/kernel/debugfs/traits.rs @@ -3,10 +3,10 @@ =20 //! Traits for rendering or updating values exported to DebugFS. =20 +use crate::fmt; use crate::prelude::*; use crate::sync::Mutex; use crate::uaccess::UserSliceReader; -use core::fmt::{self, Debug, Formatter}; use core::str::FromStr; use core::sync::atomic::{ AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicU16, Ato= micU32, AtomicU64, @@ -24,17 +24,17 @@ /// explicitly instead. pub trait Writer { /// Formats the value using the given formatter. - fn write(&self, f: &mut Formatter<'_>) -> fmt::Result; + fn write(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result; } =20 impl Writer for Mutex { - fn write(&self, f: &mut Formatter<'_>) -> fmt::Result { + fn write(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.lock().write(f) } } =20 -impl Writer for T { - fn write(&self, f: &mut Formatter<'_>) -> fmt::Result { +impl Writer for T { + fn write(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "{self:?}") } } --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 A5CED28B415; Sat, 18 Oct 2025 19:17:16 +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=1760815036; cv=none; b=CI0o+JF6WiLCUNOHx07/St9J2qw4c4GwyRRUAFoxpTXR68InwaYa1hL4nfDQ4CgJM2BZZbV6hnGBkII5YN/mq36pxZ7uyK04eyglB9yt33w+2sTYPtzGYfkJ7hLFcY18mk6fJbCqZfyYfmAIKSxjyFuV2MFHJtMQb57DR58cx7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815036; c=relaxed/simple; bh=Kbs9eVBrMyk0Vg+PzDAsDBPnMNBZDT6p+rpvbPHMIs4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S/XbFYj3cMtXSBEhK50PXffUKcHCaiEahgnEWwyerFXF5gMh+qq1Xmb8rT177AAv7JmP9rZkbRhjFy6/N9OXVspQeELoQzrswCH8fxKcsdmY3ZXvhYmJDh3eEEypeYMji7LhgNKN74+Di2h8eVTMBxwBVH4PQrQXH4Qgk/fVwz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jhexiqCf; 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="jhexiqCf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88F08C116C6; Sat, 18 Oct 2025 19:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815036; bh=Kbs9eVBrMyk0Vg+PzDAsDBPnMNBZDT6p+rpvbPHMIs4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jhexiqCfiNnu0bSYOGU7/zn4vX3VUFAPhkP8lVI+NYbKuzEyNSsT7pX88vzQwpGU2 Ij7gAVl38ptskWcskLUyLnGaVYlBNmwv0aYJhXu8damL7l4Mmg0ZTQ6+pMtmx9EeG4 2sOvltTJ6yqRgypqF6Q6R22+0WB1LW1RHpmtdSRuDdPrXpbbQlqRJCHZexKbprUzlp WfX/Am9qRIDqPyJlOdTIOt0waqlViRHLU6lNCgrZ2S2yeeC+fr1+HOjcDgiypQtwQ4 Ufa5XTbIi4XBtxJR2/ZJ32uOR76gH9KIsxbEdFKe9LcgHD9opECrcFADZc6eeCwZHx 9aSQwipOJSnEQ== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:29 -0400 Subject: [RESEND PATCH v18 08/16] rust: pci: use `kernel::fmt` 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: <20251018-cstr-core-v18-8-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=918; i=tamird@gmail.com; h=from:subject:message-id; bh=03bsWp5q/RvNg/sXSrzNos1bBBR49+qyJdq4+m4Ha6w=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QBiN/R7V4YGEuv6x8EGMhr6U9PzSWvK3OImoFdOB1S7IKj5qopcU21E5tvt1EAgDjnh2qLe3CYO Z+PEfRnE/7gE= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit ed78a01887e2 ("rust: pci: provide access to PCI Class and Class-related items"). Acked-by: Danilo Krummrich Signed-off-by: Tamir Duberstein --- rust/kernel/pci/id.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/kernel/pci/id.rs b/rust/kernel/pci/id.rs index 7f2a7f57507f..5f5d59ff49fc 100644 --- a/rust/kernel/pci/id.rs +++ b/rust/kernel/pci/id.rs @@ -4,8 +4,7 @@ //! //! This module contains PCI class codes, Vendor IDs, and supporting types. =20 -use crate::{bindings, error::code::EINVAL, error::Error, prelude::*}; -use core::fmt; +use crate::{bindings, error::code::EINVAL, error::Error, fmt, prelude::*}; =20 /// PCI device class codes. /// --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 3643D28B415; Sat, 18 Oct 2025 19:17:21 +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=1760815042; cv=none; b=Le/7GLQyCywbFpTSwTISAlePkZK5BpDahkwrQZBKOy2Q3F/sj6XJOJwyoKVzXjeJUJFNgpocpfsZaH26lC9PjgLRTtEKRl2s8cnq7jIVEsoxUXCNYz5+ep70tORRHoch09BqgKUmyFxfaPXnddwNjQEMEdg6eHQ57TKlM1ZxOaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815042; c=relaxed/simple; bh=xsFNIUUmzla0WMlusejuVXTppBOrwZiYvcam3knzJco=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vzw0NYmJYS10LFyvuq3M1T/YfZVd/0EN+vM2K+ju2994coNEJZHjzcrGfa1/QKKlfvHqOHV0XlXsR+92EwJyJBVsKGL1gFlyZSPny/d4MdGI6KWaRIr2pex+7mfzfSvCc0Q5MmG1sMQWEwnhIkNbG3kuhDuOeLfcTYBgM9Cs2Ig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IxrPftDo; 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="IxrPftDo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C454CC4CEF8; Sat, 18 Oct 2025 19:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815041; bh=xsFNIUUmzla0WMlusejuVXTppBOrwZiYvcam3knzJco=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IxrPftDoU4+MMu/+OID4PuXX3LHeEmg9QAIFM1wrlI/YQ0cW7RtpRppmvo7U999mb uYHqSPNQ1HvlfKtgm6zrcwyfprLt4n2+B2ABJvQ9iea47gvbS9FvUc0yE3r1tlpzja ZJJkwE5DQ6n89PLFa9V3zIM1z9EbnZVyC3e0RH7Qoe/PiftupHl6rtz/g/KwN3g49M 7VL5oyHs8cTot8EwWykIeiwW+IizJybqKDeM/WQl9AallDW2T0Qi1ODHZbQCdUrGeg JlcmPBdil3JE5gTaQNkvh9GIC3ptIi51M4GMHV6RAudEN4o899xVf9YX13ocm14x7C i1Ds/Rtwxvnlw== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:30 -0400 Subject: [RESEND PATCH v18 09/16] rust: remove spurious `use core::fmt::Debug` 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: <20251018-cstr-core-v18-9-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=668; i=tamird@gmail.com; h=from:subject:message-id; bh=uLnXUd5iHMMEJTAMJKY0bsxZkX3e5rGAkuIO16n9SP8=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QJ420FEA1xU82RY5LJF3sSFoGPpWwDG/CyQn+H+eASJYtK6ZdeBenXT7zDwgEhA3R2uuEjBZtbx qsFbiKdSl3wc= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein We want folks to use `kernel::fmt` but this is only used for `derive` so can be removed entirely. This backslid in commit ea60cea07d8c ("rust: add `Alignment` type"). Reviewed-by: Alice Ryhl Signed-off-by: Tamir Duberstein --- rust/kernel/ptr.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/kernel/ptr.rs b/rust/kernel/ptr.rs index 2e5e2a090480..e3893ed04049 100644 --- a/rust/kernel/ptr.rs +++ b/rust/kernel/ptr.rs @@ -2,7 +2,6 @@ =20 //! Types and functions to work with pointers and addresses. =20 -use core::fmt::Debug; use core::mem::align_of; use core::num::NonZero; =20 --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 3AF7A280325; Sat, 18 Oct 2025 19:17:27 +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=1760815047; cv=none; b=ALttmaa40gPEQJ2EJ6dvDMRpMOrwP464ZBhSS4EMu5L6IAXOIWIBdxHrOoC+0zj9hvsygks7f2xZW+KnsK6jmYRHdxtGpeKeaznrznAzjAP13QdHuTbxEm3ehwsMmLd6MynkjxWcdSUD0xE5hFiMC85wlHdwjo1Q3GHquYwYggo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815047; c=relaxed/simple; bh=pXxOJ/NLtDaH83zqjND6FIXR4v5/73dcrcdTYNg4j1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AgWg0EVC4patOnUUgNMxWEEWq+MzKdliCOfUOzrIK/EVz2OVpvCbGJDRYu7UeKcQUhacOep5Z0hCFjN0m4JnC9plQ7Lef73IKcP5pGLXvtwRaZMompyXs+j4KorMMVn8t4LFdJIoWJsMQugiXbh77/GSlFjNdrF4y7G9udQiVmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qKx+V4mv; 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="qKx+V4mv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1540BC113D0; Sat, 18 Oct 2025 19:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815047; bh=pXxOJ/NLtDaH83zqjND6FIXR4v5/73dcrcdTYNg4j1U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qKx+V4mv9A2FXm2lcL0ZwJREuJkNpo5CrrE5zYCtt8J59hof8FvxjFiBPiISRXkb8 qMcRcDAq2hn7fn8dkS9czsTsfSh45A8jdDA4hpUBuntJ3i3Jstul/b5hsQry3+NfGf nizE6lz3lUlmxgH8WeAnfQc73fqqZbWdW1Nkats2rSAwGMLZg6/QoTDM+IJJ3SLBJY ZnLty0z+wRwO11TIFOC0J+pKnTpGZlw9o2MLX02Rjjuiq7uEcE6JqrXK2pGJpQDyET jIuMJYTexD5od0WpD2vEnnzVNRRnwdPImG/Gp8LGq2Vkt/Cm0wrf/JilJblg6q0BLw iqZAkiAJFP1SQ== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:31 -0400 Subject: [RESEND PATCH v18 10/16] rust: opp: use `CStr::as_char_ptr` 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: <20251018-cstr-core-v18-10-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=1431; i=tamird@gmail.com; h=from:subject:message-id; bh=W0kd+lIKrES9E6f3i/NvYS4ZToF7HAzoNGFG8gcpmao=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QEaKoEKQMRH8v0Qk2meRSTqql6NHJPYZKph+ocMbSdhqrmQbq3JnhhyFgPsXl5Vy80wy+DRjezA 6ZmzYy/GqBgI= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Replace the use of `as_ptr` which works through `::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref`. Signed-off-by: Tamir Duberstein --- rust/kernel/opp.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs index 2c763fa9276d..9d6c58178a6f 100644 --- a/rust/kernel/opp.rs +++ b/rust/kernel/opp.rs @@ -13,7 +13,7 @@ cpumask::{Cpumask, CpumaskVar}, device::Device, error::{code::*, from_err_ptr, from_result, to_result, Result, VTABLE_= DEFAULT_ERROR}, - ffi::c_ulong, + ffi::{c_char, c_ulong}, prelude::*, str::CString, sync::aref::{ARef, AlwaysRefCounted}, @@ -88,12 +88,12 @@ fn drop(&mut self) { use macros::vtable; =20 /// Creates a null-terminated slice of pointers to [`Cstring`]s. -fn to_c_str_array(names: &[CString]) -> Result> { +fn to_c_str_array(names: &[CString]) -> Result> { // Allocated a null-terminated vector of pointers. let mut list =3D KVec::with_capacity(names.len() + 1, GFP_KERNEL)?; =20 for name in names.iter() { - list.push(name.as_ptr().cast(), GFP_KERNEL)?; + list.push(name.as_char_ptr(), GFP_KERNEL)?; } =20 list.push(ptr::null(), GFP_KERNEL)?; --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 AB87D280CE5; Sat, 18 Oct 2025 19:17:32 +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=1760815052; cv=none; b=ls1IaVhiOAN9XY6ZGsMvwiijgXfl445CI5lUOGzESGOKG2yzynVOyotVchZa79mZbpDp2kNcglpB9vKYvYXsnq/JI0A0ardWPe1pVZ7EP7iNFD7IbeZrFFW27UWqJG/8WU6EHpuXrJWITgJVq4CNuz7LnzjJlKjVk16YMqTewS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815052; c=relaxed/simple; bh=9juD2re7DWE7O8nJl0lrYDN5UrR09N9/s9yGrWP5DGM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=J+vjBP+7ec4FWlHBvRt2N7NwPHGBqJwut4aA5oZG03pMtWzqNyYHv3ki5tNLYzfCjAcwfGmZ9POgrcgcODTXWACol82hO/ONGsOBl5auM0TmYvAlJXw0sKYVRGXZB9yYQORdaeBAF0/3ndDA1IkzrE3dwLUrVtGtosQxkItwTl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C0fdIGiX; 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="C0fdIGiX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 579C5C16AAE; Sat, 18 Oct 2025 19:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815052; bh=9juD2re7DWE7O8nJl0lrYDN5UrR09N9/s9yGrWP5DGM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C0fdIGiXnl6qIebTUwvFtbcdka1UB0QhIJqAtbfttoSdLgL9kiMoku2+sDGUCNSGd sBkqKEY8XgQApQ9L4TqGvWsTLRHGByG8ZgCZMcmMa63MBuZwYuv3cNw+WuwEYELWzB d44278S08gcsJnhADbPK868vAN+WbeDvfqEzAYxnXGYI5KaiIeOwoN3L0SgRVRmkfx X7H3Sk2YlCpU1WE1jen0VkGoPvvbHQ29NuWn5I9izcWMDPB9h38QzE9+UY8X0SHNTc ND5byOs3qIZEaYXGqCbYghVlrUsPmm6LEGWClQCYlvL5CWl5fNe+iimuEelLbUIUFg iMMLIdf3UrCug== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:32 -0400 Subject: [RESEND PATCH v18 11/16] rust: opp: fix broken rustdoc link 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: <20251018-cstr-core-v18-11-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814988; l=760; i=tamird@gmail.com; h=from:subject:message-id; bh=tThvb3NWkM3msr/ABoCM1JnbhTAqdV/nFrTXflsMRkU=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QPqF/mm9xNU7+TBmT1XlcmtJzse6LYSkUbnpcCK4weGSJVuR/nhZk/QSMwFd0BfjfApI5KXNqgQ 3X4sYkgg0KAc= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Correct the spelling of "CString" to make the link work. Signed-off-by: Tamir Duberstein --- rust/kernel/opp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs index 9d6c58178a6f..523a333553bd 100644 --- a/rust/kernel/opp.rs +++ b/rust/kernel/opp.rs @@ -87,7 +87,7 @@ fn drop(&mut self) { =20 use macros::vtable; =20 -/// Creates a null-terminated slice of pointers to [`Cstring`]s. +/// Creates a null-terminated slice of pointers to [`CString`]s. fn to_c_str_array(names: &[CString]) -> Result> { // Allocated a null-terminated vector of pointers. let mut list =3D KVec::with_capacity(names.len() + 1, GFP_KERNEL)?; --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 DD1552DA758; Sat, 18 Oct 2025 19:17:37 +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=1760815058; cv=none; b=NdeYRGTesPJNSfviIT+tQ4X7XiDJ86r0lCUnY8QEsDWsNBy9UYG/RLb+IjApEVIWgaAbaZFDAyhGct3smutNWLpItd/p5G2VopLFBAk0nixXPQAk25R/iTne0YCovGf6cxbu53Du7UqttdVthFzL8pzy3ajmuqvGVKgESrdPTX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815058; c=relaxed/simple; bh=t3MeAiRnGdoesAhwXOBk5BryendJK05svLbfpjh+K4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S2vqXD/e0RufgN27feQ+b0R56hJkIf8Q3exwSrmsjlmGw1zDYS5LdMUhpP4kgz8RZyMpt5iCw1Be/LDShZrzgpx9/DGL9XYTu45iHvTtioUsfNISao1uhGNuXnYpg/U3M6MrJP9WGhB4kcGGGmT1KpNsvB+fzC/LMlzrfOR841s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zml/XwiH; 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="Zml/XwiH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77C6DC4CEF8; Sat, 18 Oct 2025 19:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815057; bh=t3MeAiRnGdoesAhwXOBk5BryendJK05svLbfpjh+K4s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Zml/XwiHfAwgAYGqQhQmjibupmeFVe6AL7G8yrtIuhgOGPBajlIixZDSvtj/n0cDk 2Z9BgLJttZxcWNnImfvAzllTCHLttg8qJu4b4dFmHIEcRX8xXKeBmCML2/EZNY7rE4 p4Ir/tpGxrPSTwfdst6VSVYv7LU0RGpp38aNgAgoePrOM5uUx6Vc46fHJ16izzuSeq bGDflThcMknvRW0bV/o8iclVods5ULufhvLGmTeJ94Pyu6YD1WIYBz2vDiPASQSh4S G/8WCo/ke3Nu5XltcaPNa36wdcUfG6WWtvNa9Ar7hgizm8vpndWzYi07A2+zrkVDMw TUQSBlMs1rCLQ== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:33 -0400 Subject: [RESEND PATCH v18 12/16] rust: configfs: use `CStr::as_char_ptr` 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: <20251018-cstr-core-v18-12-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814989; l=931; i=tamird@gmail.com; h=from:subject:message-id; bh=D3+7P/SS4fL5Q9I/e/hnwaICnLJa3uX2WlUDB305PhA=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QJNTPLMMNL1Y0QjjEhUqhLLisj+FekJgSfqKzOMBilFTfJSI1pvk3DV52ieZT/JQS43drzCi0jB W4MEhimPTDwU= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Replace the use of `as_ptr` which works through `::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref`. Signed-off-by: Tamir Duberstein Acked-by: Andreas Hindborg --- rust/kernel/configfs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/configfs.rs b/rust/kernel/configfs.rs index 10f1547ca9f1..466fb7f40762 100644 --- a/rust/kernel/configfs.rs +++ b/rust/kernel/configfs.rs @@ -157,7 +157,7 @@ pub fn new( unsafe { bindings::config_group_init_type_name( &mut (*place.get()).su_group, - name.as_ptr(), + name.as_char_ptr(), item_type.as_ptr(), ) }; --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 D3480283151; Sat, 18 Oct 2025 19:17:42 +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=1760815063; cv=none; b=PXgCh/bidFU97WcpcGJTAWRgpEiMhznHloAWpXoQ5vFib9D0VU/Comz5h30wKEmFG233oWYngEpDPHEDDpG4HVHTdO2SdsEtN4jmb/jg9xZrt+Z5h59XQrn3r90dQeKM7OgGQ2vpsWlnlnkUZIupYfJ3ViU/jTXHbriZCEHUmYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815063; c=relaxed/simple; bh=mvzw2mOgVK1rTE6DegAxCmeiKe+4WCD0q+Vgj2JT9WU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RTj0Kiru8YsXUcCVNe7e03GOZQ4tCnnd8oG5WocQZoGP+fKeXCEBWr0iLoFSLgpE1vaHaZutn94BZe663NfQ8Igc7NDbz5pHXITrAP/1pQDBqrwyDmExAWY9ryBRpN6U1GDwXEbvKbLMhcnvfpII6qDQCrxPU4tXSC+1HrdzsbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iBGrgfs4; 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="iBGrgfs4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A33A0C116B1; Sat, 18 Oct 2025 19:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815062; bh=mvzw2mOgVK1rTE6DegAxCmeiKe+4WCD0q+Vgj2JT9WU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iBGrgfs4GuEuh6D6ykM1vled445YaakCr43raArOpb6AMPxUylZ/sY8YIZ8/ZWuKx l2ujB11ocOSuHi8Iw4VnX3qeaoOVrhagPImm5Lnfb7Tq+pOkuJFNaJ318v10IXizu3 gFgA57LXOC6oLXyskeEAD44u8+iqC8pMYIreQCOq41gcSezsBGWxPvRb2m4BBFHtAZ DrFShpK4zZA7APeFat9mdn5pix3wb3FPQF8Ti+1G18sGFW1gpTs7/sbYNa/25049G8 MovMdmjKZSzVOTL4HyaPU8WIwFlNFtVnm71iSvxuYShp3rZDWus+xnxLboFSUcFpQf IMD4WIfZLwxMg== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:34 -0400 Subject: [RESEND PATCH v18 13/16] rust: regulator: use `CStr::as_char_ptr` 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: <20251018-cstr-core-v18-13-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814989; l=2203; i=tamird@gmail.com; h=from:subject:message-id; bh=TVneWa6JveF7OyfYzj6Kyk7+7jG+eRccWAa0D/umdvA=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QB66XSchXpQP0ql6hf2wFqSMWIu/xghHrf/J2fVOOToGeEX1prtd6Qtlv/bZtBsRRBGIVNZMvr8 dES/KD1MjIgk= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Replace the use of `as_ptr` which works through `::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref`. Signed-off-by: Tamir Duberstein Acked-by: Mark Brown Reviewed-by: Daniel Almeida --- rust/kernel/regulator.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rust/kernel/regulator.rs b/rust/kernel/regulator.rs index b55a201e5029..65a4eb096cae 100644 --- a/rust/kernel/regulator.rs +++ b/rust/kernel/regulator.rs @@ -84,7 +84,7 @@ pub struct Error { pub fn devm_enable(dev: &Device, name: &CStr) -> Result { // SAFETY: `dev` is a valid and bound device, while `name` is a valid C // string. - to_result(unsafe { bindings::devm_regulator_get_enable(dev.as_raw(), n= ame.as_ptr()) }) + to_result(unsafe { bindings::devm_regulator_get_enable(dev.as_raw(), n= ame.as_char_ptr()) }) } =20 /// Same as [`devm_enable`], but calls `devm_regulator_get_enable_optional` @@ -102,7 +102,9 @@ pub fn devm_enable(dev: &Device, name: &CStr) ->= Result { pub fn devm_enable_optional(dev: &Device, name: &CStr) -> Result { // SAFETY: `dev` is a valid and bound device, while `name` is a valid C // string. - to_result(unsafe { bindings::devm_regulator_get_enable_optional(dev.as= _raw(), name.as_ptr()) }) + to_result(unsafe { + bindings::devm_regulator_get_enable_optional(dev.as_raw(), name.as= _char_ptr()) + }) } =20 /// A `struct regulator` abstraction. @@ -268,7 +270,8 @@ pub fn get_voltage(&self) -> Result { fn get_internal(dev: &Device, name: &CStr) -> Result> { // SAFETY: It is safe to call `regulator_get()`, on a device point= er // received from the C code. - let inner =3D from_err_ptr(unsafe { bindings::regulator_get(dev.as= _raw(), name.as_ptr()) })?; + let inner =3D + from_err_ptr(unsafe { bindings::regulator_get(dev.as_raw(), na= me.as_char_ptr()) })?; =20 // SAFETY: We can safely trust `inner` to be a pointer to a valid // regulator if `ERR_PTR` was not returned. --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 02D2A284884; Sat, 18 Oct 2025 19:17:47 +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=1760815068; cv=none; b=YGGOI1oR5NdTitnm/vFN1HV7FudeRn9OCzqBRnYJineV1ZowT+fxyRqIZNVXdxlGk6tFi89UbQs6ejkNkdlQ74ItVm3hHfAjPSKLv67DU/SD00ZxQy74TpJu7UeS0zkOhMOlpshjeVdjf+nxMO+ijEB1MJ4uFg49YYr0EAgDhfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815068; c=relaxed/simple; bh=UigUpDae7bCzJmoyUBvH5qt/ZKzsRjZYhItn19w2ZiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BMPMyCmuHz2TL/VWnLD0+Z7DIZke9tCzLjLwXaWDGkQIHOdt2kCV8HNfem91S+rlPQQwmlDCAc7muZdRB98FVYL+o7qIoitgjLyqLEbZvOXFacepr/VZDlIMNrjfce+j/pSKXHQWhFePFojHsDdgKjROPArfJe3Y1RdH9swN3Sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XS+orUE9; 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="XS+orUE9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F062BC4CEF9; Sat, 18 Oct 2025 19:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815067; bh=UigUpDae7bCzJmoyUBvH5qt/ZKzsRjZYhItn19w2ZiI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XS+orUE9AmIQ2HaqmE2G3vq3frjgMehq+haQM5FX/Acsda2hgDMdNSdPz9zBef14G 1D63E32p4aQChKzKO+pdcdR9PGNdUR+vbHv5wlS/EaitbIVkcdIDLQBXW33G6EMYXI DeBsiyyi6x0zXmKQGTGi5FxjqoYnzeh5GxNeV5EnTpefEYYshuKoKQNWHyIZDW6Qr5 1rL/4sbombffpnpwdYlrronDaSHsbkOmhaUzoeHueLJ1FTYpzEz3ncF+erHnCijm2A mNrA5JLt6JPVwD7RlUxqoNMrEwvO+pkPm4+n5n04bgEOW4OdYad4tmUpTm2vj1D64e TD+QH25UsVehQ== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:35 -0400 Subject: [RESEND PATCH v18 14/16] rust: clk: use `CStr::as_char_ptr` 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: <20251018-cstr-core-v18-14-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814989; l=1464; i=tamird@gmail.com; h=from:subject:message-id; bh=2sqGOf6EN1S70aLREr+Nb8Kc38by1bfC55CIEq6FiwU=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QJHANS11xWoKkU1Sy8KeYExT9HQoen+e3fIql8N/iJzrg0B2tS1kwYmRv1ouxGM36+hSk1YJeEW N/AbzFZuzqAk= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Replace the use of `as_ptr` which works through `::deref()` in preparation for replacing `kernel::str::CStr` with `core::ffi::CStr` as the latter does not implement `Deref`. Signed-off-by: Tamir Duberstein --- rust/kernel/clk.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/clk.rs b/rust/kernel/clk.rs index 1e6c8c42fb3a..c1cfaeaa36a2 100644 --- a/rust/kernel/clk.rs +++ b/rust/kernel/clk.rs @@ -136,7 +136,7 @@ impl Clk { /// /// [`clk_get`]: https://docs.kernel.org/core-api/kernel-api.html#= c.clk_get pub fn get(dev: &Device, name: Option<&CStr>) -> Result { - let con_id =3D name.map_or(ptr::null(), |n| n.as_ptr()); + let con_id =3D name.map_or(ptr::null(), |n| n.as_char_ptr()); =20 // SAFETY: It is safe to call [`clk_get`] for a valid device p= ointer. // @@ -304,7 +304,7 @@ impl OptionalClk { /// [`clk_get_optional`]: /// https://docs.kernel.org/core-api/kernel-api.html#c.clk_get_opt= ional pub fn get(dev: &Device, name: Option<&CStr>) -> Result { - let con_id =3D name.map_or(ptr::null(), |n| n.as_ptr()); + let con_id =3D name.map_or(ptr::null(), |n| n.as_char_ptr()); =20 // SAFETY: It is safe to call [`clk_get_optional`] for a valid= device pointer. // --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 D6EF931355F; Sat, 18 Oct 2025 19:17:53 +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=1760815074; cv=none; b=FePTbHLhALwGfRyPFn9oJW9ncuBymWR0xIlBWscu29pEhUtp0uRg5Nl7rFyY3ZSMva3BurvMOqtjiRRoHyT3OIlEtV+n7S11gxER08Gs2DDln9iBTFStHUBmpCAV/knZ64jDsG1YC5a4aXpxmPV+bcLshyB44QICmInh3N1PZt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815074; c=relaxed/simple; bh=2oBxkZ01nQycND03d5zoCfYP59PTO7QR6ek/VpiCijo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dpjSHdGFApReMyF3zd+BPuzsL9SKuE8+DCghbiWpFHxSMxrtxGyWwzVIt4YkJRiB9VnlLNpUQzjZ2llQfeCpr3CDAPxBA8/KbGUnygc/cIFXTiqpvSo1HG5+6YZpU3nL4LYOdzzGgr8xeaeOD25WqvWgI4CF/YVqVvUQkiTEyzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UjGdfAMk; 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="UjGdfAMk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23495C116C6; Sat, 18 Oct 2025 19:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815073; bh=2oBxkZ01nQycND03d5zoCfYP59PTO7QR6ek/VpiCijo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UjGdfAMktZNUm/Wb0NXyVZ+M5mGuWMGlKwg14d5GAQhcT7an+MYJAGICHtxewbBwl f+t9y1Y5oEAgJf1Kjb/8elnn3yCUJNL/B3W/JobxE5F3ez+NZdOND5S6dtFXXr4ldl B+WZCtTQ0QOMGV60N5hlHPcd8wLuluCgEJm9KONBs/8/dEi+nqX+5qqB0v54TIdnHy zTQzRzY7mqywou1wsiCQ03xeDazw2hmPOziUAOd5c+tDVFcnwQ0AbsBOHH/NBChr9r PgCCl0lDHitM0Ley5UENiLkrcb/59t4NZphnAhUxmeOZaa6XmHYGG2/q4wrpHrXL5s sPFsnBPJiZ6DA== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:36 -0400 Subject: [RESEND PATCH v18 15/16] rust: support formatting of foreign types 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: <20251018-cstr-core-v18-15-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814989; l=11126; i=tamird@gmail.com; h=from:subject:message-id; bh=XoNqu1FJXHinWrPbDuOrRyOrTcTOllTMnI71laZHyoo=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QOMOEvu0mgDBonMRgPSUXX6rEL1IIykRIIIq0dJ7Lt4G16bPuTHrjyY8JrQ2NNfD9w3Zkbn5Oyu Tg32ICq9rewU= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein Introduce a `fmt!` macro which wraps all arguments in `kernel::fmt::Adapter` and a `kernel::fmt::Display` trait. This enables formatting of foreign types (like `core::ffi::CStr`) that do not implement `core::fmt::Display` due to concerns around lossy conversions which do not apply in the kernel. Suggested-by: Alice Ryhl Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/t= opic/Custom.20formatting/with/516476467 Acked-by: Greg Kroah-Hartman Reviewed-by: Alice Ryhl Acked-by: Danilo Krummrich Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- rust/kernel/fmt.rs | 87 +++++++++++++++++++++++++++++++++++++++++++++- rust/kernel/prelude.rs | 3 +- rust/macros/fmt.rs | 94 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ rust/macros/lib.rs | 19 ++++++++++ rust/macros/quote.rs | 7 ++++ 5 files changed, 207 insertions(+), 3 deletions(-) diff --git a/rust/kernel/fmt.rs b/rust/kernel/fmt.rs index 0306e8388968..84d634201d90 100644 --- a/rust/kernel/fmt.rs +++ b/rust/kernel/fmt.rs @@ -4,4 +4,89 @@ //! //! This module is intended to be used in place of `core::fmt` in kernel c= ode. =20 -pub use core::fmt::{Arguments, Debug, Display, Error, Formatter, Result, W= rite}; +pub use core::fmt::{Arguments, Debug, Error, Formatter, Result, Write}; + +/// Internal adapter used to route allow implementations of formatting tra= its for foreign types. +/// +/// It is inserted automatically by the [`fmt!`] macro and is not meant to= be used directly. +/// +/// [`fmt!`]: crate::prelude::fmt! +#[doc(hidden)] +pub struct Adapter(pub T); + +macro_rules! impl_fmt_adapter_forward { + ($($trait:ident),* $(,)?) =3D> { + $( + impl $trait for Adapter { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + let Self(t) =3D self; + $trait::fmt(t, f) + } + } + )* + }; +} + +use core::fmt::{Binary, LowerExp, LowerHex, Octal, Pointer, UpperExp, Uppe= rHex}; +impl_fmt_adapter_forward!(Debug, LowerHex, UpperHex, Octal, Binary, Pointe= r, LowerExp, UpperExp); + +/// A copy of [`core::fmt::Display`] that allows us to implement it for fo= reign types. +/// +/// Types should implement this trait rather than [`core::fmt::Display`]. = Together with the +/// [`Adapter`] type and [`fmt!`] macro, it allows for formatting foreign = types (e.g. types from +/// core) which do not implement [`core::fmt::Display`] directly. +/// +/// [`fmt!`]: crate::prelude::fmt! +pub trait Display { + /// Same as [`core::fmt::Display::fmt`]. + fn fmt(&self, f: &mut Formatter<'_>) -> Result; +} + +impl Display for &T { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + Display::fmt(*self, f) + } +} + +impl core::fmt::Display for Adapter<&T> { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + let Self(t) =3D self; + Display::fmt(t, f) + } +} + +macro_rules! impl_display_forward { + ($( + $( { $($generics:tt)* } )? $ty:ty $( { where $($where:tt)* } )? + ),* $(,)?) =3D> { + $( + impl$($($generics)*)? Display for $ty $(where $($where)*)? { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + core::fmt::Display::fmt(self, f) + } + } + )* + }; +} + +impl_display_forward!( + bool, + char, + core::panic::PanicInfo<'_>, + Arguments<'_>, + i128, + i16, + i32, + i64, + i8, + isize, + str, + u128, + u16, + u32, + u64, + u8, + usize, + {} crate::sync::Arc {where crate::sync::Arc: core::fm= t::Display}, + {} crate::sync::UniqueArc {where crate::sync::UniqueArc<= T>: core::fmt::Display}, +); diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 198d09a31449..26424ad7e989 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -25,7 +25,7 @@ pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec= , Vec}; =20 #[doc(no_inline)] -pub use macros::{export, kunit_tests, module, vtable}; +pub use macros::{export, fmt, kunit_tests, module, vtable}; =20 pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, In= it, PinInit, Zeroable}; =20 @@ -36,7 +36,6 @@ pub use super::dbg; pub use super::{dev_alert, dev_crit, dev_dbg, dev_emerg, dev_err, dev_info= , dev_notice, dev_warn}; pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr= _notice, pr_warn}; -pub use core::format_args as fmt; =20 pub use super::{try_init, try_pin_init}; =20 diff --git a/rust/macros/fmt.rs b/rust/macros/fmt.rs new file mode 100644 index 000000000000..2f4b9f6e2211 --- /dev/null +++ b/rust/macros/fmt.rs @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: GPL-2.0 + +use proc_macro::{Ident, TokenStream, TokenTree}; +use std::collections::BTreeSet; + +/// Please see [`crate::fmt`] for documentation. +pub(crate) fn fmt(input: TokenStream) -> TokenStream { + let mut input =3D input.into_iter(); + + let first_opt =3D input.next(); + let first_owned_str; + let mut names =3D BTreeSet::new(); + let first_span =3D { + let Some((mut first_str, first_span)) =3D (match first_opt.as_ref(= ) { + Some(TokenTree::Literal(first_lit)) =3D> { + first_owned_str =3D first_lit.to_string(); + Some(first_owned_str.as_str()).and_then(|first| { + let first =3D first.strip_prefix('"')?; + let first =3D first.strip_suffix('"')?; + Some((first, first_lit.span())) + }) + } + _ =3D> None, + }) else { + return first_opt.into_iter().chain(input).collect(); + }; + + // Parse `identifier`s from the format string. + // + // See https://doc.rust-lang.org/std/fmt/index.html#syntax. + while let Some((_, rest)) =3D first_str.split_once('{') { + first_str =3D rest; + if let Some(rest) =3D first_str.strip_prefix('{') { + first_str =3D rest; + continue; + } + if let Some((name, rest)) =3D first_str.split_once('}') { + first_str =3D rest; + let name =3D name.split_once(':').map_or(name, |(name, _)|= name); + if !name.is_empty() && !name.chars().all(|c| c.is_ascii_di= git()) { + names.insert(name); + } + } + } + first_span + }; + + let adapter =3D quote_spanned!(first_span =3D> ::kernel::fmt::Adapter); + + let mut args =3D TokenStream::from_iter(first_opt); + { + let mut flush =3D |args: &mut TokenStream, current: &mut TokenStre= am| { + let current =3D std::mem::take(current); + if !current.is_empty() { + let (lhs, rhs) =3D (|| { + let mut current =3D current.into_iter(); + let mut acc =3D TokenStream::new(); + while let Some(tt) =3D current.next() { + // Split on `=3D` only once to handle cases like `= a =3D b =3D c`. + if matches!(&tt, TokenTree::Punct(p) if p.as_char(= ) =3D=3D '=3D') { + names.remove(acc.to_string().as_str()); + // Include the `=3D` itself to keep the handli= ng below uniform. + acc.extend([tt]); + return (Some(acc), current.collect::()); + } + acc.extend([tt]); + } + (None, acc) + })(); + args.extend(quote_spanned!(first_span =3D> #lhs #adapter(&= #rhs))); + } + }; + + let mut current =3D TokenStream::new(); + for tt in input { + match &tt { + TokenTree::Punct(p) if p.as_char() =3D=3D ',' =3D> { + flush(&mut args, &mut current); + &mut args + } + _ =3D> &mut current, + } + .extend([tt]); + } + flush(&mut args, &mut current); + } + + for name in names { + let name =3D Ident::new(name, first_span); + args.extend(quote_spanned!(first_span =3D> , #name =3D #adapter(&#= name))); + } + + quote_spanned!(first_span =3D> ::core::format_args!(#args)) +} diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs index fa847cf3a9b5..793f712dbf7c 100644 --- a/rust/macros/lib.rs +++ b/rust/macros/lib.rs @@ -15,6 +15,7 @@ mod quote; mod concat_idents; mod export; +mod fmt; mod helpers; mod kunit; mod module; @@ -201,6 +202,24 @@ pub fn export(attr: TokenStream, ts: TokenStream) -> T= okenStream { export::export(attr, ts) } =20 +/// Like [`core::format_args!`], but automatically wraps arguments in [`ke= rnel::fmt::Adapter`]. +/// +/// This macro allows generating `fmt::Arguments` while ensuring that each= argument is wrapped with +/// `::kernel::fmt::Adapter`, which customizes formatting behavior for ker= nel logging. +/// +/// Named arguments used in the format string (e.g. `{foo}`) are detected = and resolved from local +/// bindings. All positional and named arguments are automatically wrapped. +/// +/// This macro is an implementation detail of other kernel logging macros = like [`pr_info!`] and +/// should not typically be used directly. +/// +/// [`kernel::fmt::Adapter`]: ../kernel/fmt/struct.Adapter.html +/// [`pr_info!`]: ../kernel/macro.pr_info.html +#[proc_macro] +pub fn fmt(input: TokenStream) -> TokenStream { + fmt::fmt(input) +} + /// Concatenate two identifiers. /// /// This is useful in macros that need to declare or reference items with = names diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs index acc140c18653..ddfc21577539 100644 --- a/rust/macros/quote.rs +++ b/rust/macros/quote.rs @@ -48,6 +48,7 @@ macro_rules! quote_spanned { ($span:expr =3D> $($tt:tt)*) =3D> {{ let mut tokens =3D ::proc_macro::TokenStream::new(); { + #[allow(unused_variables)] let span =3D $span; quote_spanned!(@proc tokens span $($tt)*); } @@ -146,6 +147,12 @@ macro_rules! quote_spanned { )]); quote_spanned!(@proc $v $span $($tt)*); }; + (@proc $v:ident $span:ident & $($tt:tt)*) =3D> { + $v.extend([::proc_macro::TokenTree::Punct( + ::proc_macro::Punct::new('&', ::proc_macro::Spacing::Alone), + )]); + quote_spanned!(@proc $v $span $($tt)*); + }; (@proc $v:ident $span:ident _ $($tt:tt)*) =3D> { $v.extend([::proc_macro::TokenTree::Ident( ::proc_macro::Ident::new("_", $span), --=20 2.51.1 From nobody Sun Dec 14 06:16:54 2025 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 51F48315D49; Sat, 18 Oct 2025 19:17:59 +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=1760815079; cv=none; b=IB09mPqH8C5R5c9WtE2aBjRM4T48K2+THSMrXnu3Nae+K1PUhhwKCMUnwtp/BIkxfNnwVjGN4B0+bjfd7Lz+OU7mSHtQ+J00VYH8J9j6bAgDWuw6zZMuPcn0lEMM5T7fDEsRrFXnPr8T73EhVwbIP9cn67H9ToCmHV58ELkNNdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760815079; c=relaxed/simple; bh=QPSAaavyVHWDFYRh1GM5iE3JWMz0G2/6OdtXnqDLxsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=knUGM1Y8LKum4zMDLNZSk5DBACk7xUSPOcZNTak2UjKo8+THkx74MJsGtar5e3/lRO0xqvD+RZ/rjCThFHdjLoyAJgY9LeKrga4sSilHcoI1eVccmQmQIn1HbvkKeq2nhV/9/DU4djrTatwmA0rLI4gm8AraJEI6OxhCy05xFQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GENTAPqD; 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="GENTAPqD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A32E0C4CEF8; Sat, 18 Oct 2025 19:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760815078; bh=QPSAaavyVHWDFYRh1GM5iE3JWMz0G2/6OdtXnqDLxsA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GENTAPqD3m2Jehr7c9/oT5Ohw1c4vozzK3qwzw5JlHNrlzqGCN0Jba5XeL1nSPCoQ GCZmk9TFlTnuH9BTcvk5YWmXJwGo5ulp59mtHGh4QSU6v4SObZqV/f06DQM1008vQP R0siqEXgjEuxa7ZEjjyyCtO8iqlq4kDIGd7oSIqpqFH8sed6iGsV513qIoF+Vqip/4 CtPDHlSIkB6ZA/kF+wsOSBtS0dX7kGCFLmvXvUT3BKMbZ18ZsDf+IPq04MO85Ix+Lc B/yZEPyT7gle2Z+Twm3++FC7Fs2NTIsiWNeirqfDlj5aTgtW64qFC4d0nF73skDdaV iSOZHko25AZbg== From: Tamir Duberstein Date: Sat, 18 Oct 2025 15:16:37 -0400 Subject: [RESEND PATCH v18 16/16] rust: replace `CStr` with `core::ffi::CStr` 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: <20251018-cstr-core-v18-16-9378a54385f8@gmail.com> References: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> In-Reply-To: <20251018-cstr-core-v18-0-9378a54385f8@gmail.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , =?utf-8?q?Arve_Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Jens Axboe , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Bjorn Helgaas , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Viresh Kumar , Nishanth Menon , Stephen Boyd , Breno Leitao , Liam Girdwood , Mark Brown , Michael Turquette , David Airlie , Simona Vetter , Luis Chamberlain , Russ Weight , Alexander Viro , Jan Kara , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, linux-clk@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, llvm@lists.linux.dev, Tamir Duberstein X-Mailer: b4 0.15-dev X-Developer-Signature: v=1; a=openssh-sha256; t=1760814989; l=27330; i=tamird@gmail.com; h=from:subject:message-id; bh=qPkamsCyCcEHLNgp7pAZjM3ZUO+Nffzs9svoyyYa8Ow=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgtYz36g7iDMSkY5K7Ab51ksGX7hJgs MRt+XVZTrIzMVIAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QHVMZw5viZA5Bzyv04hhjyxQNMA4jmXUYRzS/eKam8pBM9DXe99JwASZH5Ah2yTxl1QY6azRMPe BRboqZvE0twQ= X-Developer-Key: i=tamird@gmail.com; a=openssh; fpr=SHA256:264rPmnnrb+ERkS7DDS3tuwqcJss/zevJRzoylqMsbc From: Tamir Duberstein `kernel::ffi::CStr` was introduced in commit d126d2380131 ("rust: str: add `CStr` type") in November 2022 as an upstreaming of earlier work that was done in May 2021[0]. That earlier work, having predated the inclusion of `CStr` in `core`, largely duplicated the implementation of `std::ffi::CStr`. `std::ffi::CStr` was moved to `core::ffi::CStr` in Rust 1.64 in September 2022. Hence replace `kernel::str::CStr` with `core::ffi::CStr` to reduce our custom code footprint, and retain needed custom functionality through an extension trait. Add `CStr` to `ffi` and the kernel prelude. Link: https://github.com/Rust-for-Linux/linux/commit/faa3cbcca03d0dec8f8e43= f1d8d5c0860d98a23f [0] Acked-by: Greg Kroah-Hartman Reviewed-by: Alice Ryhl Acked-by: Danilo Krummrich Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- drivers/android/binder/stats.rs | 2 +- rust/ffi.rs | 2 + rust/kernel/debugfs/entry.rs | 2 +- rust/kernel/device.rs | 1 + rust/kernel/drm/ioctl.rs | 4 +- rust/kernel/error.rs | 2 + rust/kernel/firmware.rs | 9 +- rust/kernel/prelude.rs | 4 +- rust/kernel/seq_file.rs | 2 +- rust/kernel/str.rs | 395 +++++++++---------------------------= ---- rust/kernel/sync/condvar.rs | 2 +- rust/kernel/sync/lock.rs | 2 +- rust/kernel/sync/lock/global.rs | 2 +- 13 files changed, 114 insertions(+), 315 deletions(-) diff --git a/drivers/android/binder/stats.rs b/drivers/android/binder/stats= .rs index 10c43679d5c3..037002651941 100644 --- a/drivers/android/binder/stats.rs +++ b/drivers/android/binder/stats.rs @@ -61,7 +61,7 @@ pub(crate) fn debug_print(&self, prefix: &str, m: &SeqFil= e) { =20 mod strings { use core::str::from_utf8_unchecked; - use kernel::str::CStr; + use kernel::str::{CStr, CStrExt as _}; =20 extern "C" { static binder_command_strings: [*const u8; super::BC_COUNT]; diff --git a/rust/ffi.rs b/rust/ffi.rs index d60aad792af4..f961e9728f59 100644 --- a/rust/ffi.rs +++ b/rust/ffi.rs @@ -46,3 +46,5 @@ macro_rules! alias { } =20 pub use core::ffi::c_void; + +pub use core::ffi::CStr; diff --git a/rust/kernel/debugfs/entry.rs b/rust/kernel/debugfs/entry.rs index f99402cd3ba0..706cb7f73d6c 100644 --- a/rust/kernel/debugfs/entry.rs +++ b/rust/kernel/debugfs/entry.rs @@ -3,7 +3,7 @@ =20 use crate::debugfs::file_ops::FileOps; use crate::ffi::c_void; -use crate::str::CStr; +use crate::str::{CStr, CStrExt as _}; use crate::sync::Arc; use core::marker::PhantomData; =20 diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index 1321e6f0b53c..0b13aa60b685 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -13,6 +13,7 @@ =20 #[cfg(CONFIG_PRINTK)] use crate::c_str; +use crate::str::CStrExt as _; =20 pub mod property; =20 diff --git a/rust/kernel/drm/ioctl.rs b/rust/kernel/drm/ioctl.rs index 69efbdb4c85a..cf328101dde4 100644 --- a/rust/kernel/drm/ioctl.rs +++ b/rust/kernel/drm/ioctl.rs @@ -156,7 +156,9 @@ macro_rules! declare_drm_ioctls { Some($cmd) }, flags: $flags, - name: $crate::c_str!(::core::stringify!($cmd)).as_char= _ptr(), + name: $crate::str::as_char_ptr_in_const_context( + $crate::c_str!(::core::stringify!($cmd)), + ), } ),*]; ioctls diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 1c0e0e241daa..258b12afdcba 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -182,6 +182,8 @@ pub fn name(&self) -> Option<&'static CStr> { if ptr.is_null() { None } else { + use crate::str::CStrExt as _; + // SAFETY: The string returned by `errname` is static and `NUL= `-terminated. Some(unsafe { CStr::from_char_ptr(ptr) }) } diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs index 94e6bb88b903..376e7e77453f 100644 --- a/rust/kernel/firmware.rs +++ b/rust/kernel/firmware.rs @@ -4,7 +4,14 @@ //! //! C header: [`include/linux/firmware.h`](srctree/include/linux/firmware.= h) =20 -use crate::{bindings, device::Device, error::Error, error::Result, ffi, st= r::CStr}; +use crate::{ + bindings, + device::Device, + error::Error, + error::Result, + ffi, + str::{CStr, CStrExt as _}, +}; use core::ptr::NonNull; =20 /// # Invariants diff --git a/rust/kernel/prelude.rs b/rust/kernel/prelude.rs index 26424ad7e989..33fa8404c5c6 100644 --- a/rust/kernel/prelude.rs +++ b/rust/kernel/prelude.rs @@ -19,7 +19,7 @@ =20 pub use ::ffi::{ c_char, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, = c_ulong, c_ulonglong, - c_ushort, c_void, + c_ushort, c_void, CStr, }; =20 pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec= , Vec}; @@ -43,7 +43,7 @@ =20 pub use super::error::{code::*, Error, Result}; =20 -pub use super::{str::CStr, ThisModule}; +pub use super::{str::CStrExt as _, ThisModule}; =20 pub use super::init::InPlaceInit; =20 diff --git a/rust/kernel/seq_file.rs b/rust/kernel/seq_file.rs index 59fbfc2473f8..855e533813a6 100644 --- a/rust/kernel/seq_file.rs +++ b/rust/kernel/seq_file.rs @@ -4,7 +4,7 @@ //! //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.= h) =20 -use crate::{bindings, c_str, fmt, types::NotThreadSafe, types::Opaque}; +use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe,= types::Opaque}; =20 /// A utility for generating the contents of a seq file. #[repr(transparent)] diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 5c74e5f77601..da539e1f29d4 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -10,9 +10,11 @@ }; use core::{ marker::PhantomData, - ops::{self, Deref, DerefMut, Index}, + ops::{Deref, DerefMut, Index}, }; =20 +pub use crate::prelude::CStr; + /// Byte string without UTF-8 validity guarantee. #[repr(transparent)] pub struct BStr([u8]); @@ -186,58 +188,17 @@ macro_rules! b_str { // - error[E0379]: functions in trait impls cannot be declared const #[inline] pub const fn as_char_ptr_in_const_context(c_str: &CStr) -> *const c_char { - c_str.0.as_ptr() + c_str.as_ptr().cast() } =20 -/// Possible errors when using conversion functions in [`CStr`]. -#[derive(Debug, Clone, Copy)] -pub enum CStrConvertError { - /// Supplied bytes contain an interior `NUL`. - InteriorNul, - - /// Supplied bytes are not terminated by `NUL`. - NotNulTerminated, -} +mod private { + pub trait Sealed {} =20 -impl From for Error { - #[inline] - fn from(_: CStrConvertError) -> Error { - EINVAL - } + impl Sealed for super::CStr {} } =20 -/// A string that is guaranteed to have exactly one `NUL` byte, which is a= t the -/// end. -/// -/// Used for interoperability with kernel APIs that take C strings. -#[repr(transparent)] -pub struct CStr([u8]); - -impl CStr { - /// Returns the length of this string excluding `NUL`. - #[inline] - pub const fn len(&self) -> usize { - self.len_with_nul() - 1 - } - - /// Returns the length of this string with `NUL`. - #[inline] - pub const fn len_with_nul(&self) -> usize { - if self.0.is_empty() { - // SAFETY: This is one of the invariant of `CStr`. - // We add a `unreachable_unchecked` here to hint the optimizer= that - // the value returned from this function is non-zero. - unsafe { core::hint::unreachable_unchecked() }; - } - self.0.len() - } - - /// Returns `true` if the string only includes `NUL`. - #[inline] - pub const fn is_empty(&self) -> bool { - self.len() =3D=3D 0 - } - +/// Extensions to [`CStr`]. +pub trait CStrExt: private::Sealed { /// Wraps a raw C string pointer. /// /// # Safety @@ -245,54 +206,9 @@ pub const fn is_empty(&self) -> bool { /// `ptr` must be a valid pointer to a `NUL`-terminated C string, and = it must /// last at least `'a`. When `CStr` is alive, the memory pointed by `p= tr` /// must not be mutated. - #[inline] - pub unsafe fn from_char_ptr<'a>(ptr: *const c_char) -> &'a Self { - // SAFETY: The safety precondition guarantees `ptr` is a valid poi= nter - // to a `NUL`-terminated C string. - let len =3D unsafe { bindings::strlen(ptr) } + 1; - // SAFETY: Lifetime guaranteed by the safety precondition. - let bytes =3D unsafe { core::slice::from_raw_parts(ptr.cast(), len= ) }; - // SAFETY: As `len` is returned by `strlen`, `bytes` does not cont= ain interior `NUL`. - // As we have added 1 to `len`, the last byte is known to be `NUL`. - unsafe { Self::from_bytes_with_nul_unchecked(bytes) } - } - - /// Creates a [`CStr`] from a `[u8]`. - /// - /// The provided slice must be `NUL`-terminated, does not contain any - /// interior `NUL` bytes. - pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, CStrCo= nvertError> { - if bytes.is_empty() { - return Err(CStrConvertError::NotNulTerminated); - } - if bytes[bytes.len() - 1] !=3D 0 { - return Err(CStrConvertError::NotNulTerminated); - } - let mut i =3D 0; - // `i + 1 < bytes.len()` allows LLVM to optimize away bounds check= ing, - // while it couldn't optimize away bounds checks for `i < bytes.le= n() - 1`. - while i + 1 < bytes.len() { - if bytes[i] =3D=3D 0 { - return Err(CStrConvertError::InteriorNul); - } - i +=3D 1; - } - // SAFETY: We just checked that all properties hold. - Ok(unsafe { Self::from_bytes_with_nul_unchecked(bytes) }) - } - - /// Creates a [`CStr`] from a `[u8]` without performing any additional - /// checks. - /// - /// # Safety - /// - /// `bytes` *must* end with a `NUL` byte, and should only have a single - /// `NUL` byte (or the string will be truncated). - #[inline] - pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CS= tr { - // SAFETY: Properties of `bytes` guaranteed by the safety precondi= tion. - unsafe { core::mem::transmute(bytes) } - } + // This function exists to paper over the fact that `CStr::from_ptr` t= akes a `*const + // core::ffi::c_char` rather than a `*const crate::ffi::c_char`. + unsafe fn from_char_ptr<'a>(ptr: *const c_char) -> &'a Self; =20 /// Creates a mutable [`CStr`] from a `[u8]` without performing any /// additional checks. @@ -301,99 +217,16 @@ pub const fn from_bytes_with_nul(bytes: &[u8]) -> Res= ult<&Self, CStrConvertError /// /// `bytes` *must* end with a `NUL` byte, and should only have a single /// `NUL` byte (or the string will be truncated). - #[inline] - pub unsafe fn from_bytes_with_nul_unchecked_mut(bytes: &mut [u8]) -> &= mut CStr { - // SAFETY: Properties of `bytes` guaranteed by the safety precondi= tion. - unsafe { &mut *(core::ptr::from_mut(bytes) as *mut CStr) } - } + unsafe fn from_bytes_with_nul_unchecked_mut(bytes: &mut [u8]) -> &mut = Self; =20 /// Returns a C pointer to the string. - /// - /// Using this function in a const context is deprecated in favor of - /// [`as_char_ptr_in_const_context`] in preparation for replacing `CSt= r` with `core::ffi::CStr` - /// which does not have this method. - #[inline] - pub const fn as_char_ptr(&self) -> *const c_char { - as_char_ptr_in_const_context(self) - } - - /// Convert the string to a byte slice without the trailing `NUL` byte. - #[inline] - pub fn to_bytes(&self) -> &[u8] { - &self.0[..self.len()] - } - - /// Convert the string to a byte slice without the trailing `NUL` byte. - /// - /// This function is deprecated in favor of [`Self::to_bytes`] in prep= aration for replacing - /// `CStr` with `core::ffi::CStr` which does not have this method. - #[inline] - pub fn as_bytes(&self) -> &[u8] { - self.to_bytes() - } - - /// Convert the string to a byte slice containing the trailing `NUL` b= yte. - #[inline] - pub const fn to_bytes_with_nul(&self) -> &[u8] { - &self.0 - } - - /// Convert the string to a byte slice containing the trailing `NUL` b= yte. - /// - /// This function is deprecated in favor of [`Self::to_bytes_with_nul`= ] in preparation for - /// replacing `CStr` with `core::ffi::CStr` which does not have this m= ethod. - #[inline] - pub const fn as_bytes_with_nul(&self) -> &[u8] { - self.to_bytes_with_nul() - } - - /// Yields a [`&str`] slice if the [`CStr`] contains valid UTF-8. - /// - /// If the contents of the [`CStr`] are valid UTF-8 data, this - /// function will return the corresponding [`&str`] slice. Otherwise, - /// it will return an error with details of where UTF-8 validation fai= led. - /// - /// # Examples - /// - /// ``` - /// # use kernel::str::CStr; - /// let cstr =3D CStr::from_bytes_with_nul(b"foo\0")?; - /// assert_eq!(cstr.to_str(), Ok("foo")); - /// # Ok::<(), kernel::error::Error>(()) - /// ``` - #[inline] - pub fn to_str(&self) -> Result<&str, core::str::Utf8Error> { - core::str::from_utf8(self.as_bytes()) - } - - /// Unsafely convert this [`CStr`] into a [`&str`], without checking f= or - /// valid UTF-8. - /// - /// # Safety - /// - /// The contents must be valid UTF-8. - /// - /// # Examples - /// - /// ``` - /// # use kernel::c_str; - /// # use kernel::str::CStr; - /// let bar =3D c_str!("=E3=83=84"); - /// // SAFETY: String literals are guaranteed to be valid UTF-8 - /// // by the Rust compiler. - /// assert_eq!(unsafe { bar.as_str_unchecked() }, "=E3=83=84"); - /// ``` - #[inline] - pub unsafe fn as_str_unchecked(&self) -> &str { - // SAFETY: TODO. - unsafe { core::str::from_utf8_unchecked(self.as_bytes()) } - } + // This function exists to paper over the fact that `CStr::as_ptr` ret= urns a `*const + // core::ffi::c_char` rather than a `*const crate::ffi::c_char`. + fn as_char_ptr(&self) -> *const c_char; =20 /// Convert this [`CStr`] into a [`CString`] by allocating memory and /// copying over the string data. - pub fn to_cstring(&self) -> Result { - CString::try_from(self) - } + fn to_cstring(&self) -> Result; =20 /// Converts this [`CStr`] to its ASCII lower case equivalent in-place. /// @@ -404,11 +237,7 @@ pub fn to_cstring(&self) -> Result { /// [`to_ascii_lowercase()`]. /// /// [`to_ascii_lowercase()`]: #method.to_ascii_lowercase - pub fn make_ascii_lowercase(&mut self) { - // INVARIANT: This doesn't introduce or remove NUL bytes in the C - // string. - self.0.make_ascii_lowercase(); - } + fn make_ascii_lowercase(&mut self); =20 /// Converts this [`CStr`] to its ASCII upper case equivalent in-place. /// @@ -419,11 +248,7 @@ pub fn make_ascii_lowercase(&mut self) { /// [`to_ascii_uppercase()`]. /// /// [`to_ascii_uppercase()`]: #method.to_ascii_uppercase - pub fn make_ascii_uppercase(&mut self) { - // INVARIANT: This doesn't introduce or remove NUL bytes in the C - // string. - self.0.make_ascii_uppercase(); - } + fn make_ascii_uppercase(&mut self); =20 /// Returns a copy of this [`CString`] where each character is mapped = to its /// ASCII lower case equivalent. @@ -434,13 +259,7 @@ pub fn make_ascii_uppercase(&mut self) { /// To lowercase the value in-place, use [`make_ascii_lowercase`]. /// /// [`make_ascii_lowercase`]: str::make_ascii_lowercase - pub fn to_ascii_lowercase(&self) -> Result { - let mut s =3D self.to_cstring()?; - - s.make_ascii_lowercase(); - - Ok(s) - } + fn to_ascii_lowercase(&self) -> Result; =20 /// Returns a copy of this [`CString`] where each character is mapped = to its /// ASCII upper case equivalent. @@ -451,13 +270,7 @@ pub fn to_ascii_lowercase(&self) -> Result { /// To uppercase the value in-place, use [`make_ascii_uppercase`]. /// /// [`make_ascii_uppercase`]: str::make_ascii_uppercase - pub fn to_ascii_uppercase(&self) -> Result { - let mut s =3D self.to_cstring()?; - - s.make_ascii_uppercase(); - - Ok(s) - } + fn to_ascii_uppercase(&self) -> Result; } =20 impl fmt::Display for CStr { @@ -490,98 +303,75 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Res= ult { } } =20 -impl fmt::Debug for CStr { - /// Formats printable ASCII characters with a double quote on either e= nd, escaping the rest. - /// - /// ``` - /// # use kernel::c_str; - /// # use kernel::prelude::fmt; - /// # use kernel::str::CStr; - /// # use kernel::str::CString; - /// let penguin =3D c_str!("=F0=9F=90=A7"); - /// let s =3D CString::try_from_fmt(fmt!("{penguin:?}"))?; - /// assert_eq!(s.as_bytes_with_nul(), "\"\\xf0\\x9f\\x90\\xa7\"\0".as_= bytes()); - /// - /// // Embedded double quotes are escaped. - /// let ascii =3D c_str!("so \"cool\""); - /// let s =3D CString::try_from_fmt(fmt!("{ascii:?}"))?; - /// assert_eq!(s.as_bytes_with_nul(), "\"so \\\"cool\\\"\"\0".as_bytes= ()); - /// # Ok::<(), kernel::error::Error>(()) - /// ``` - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("\"")?; - for &c in self.as_bytes() { - match c { - // Printable characters. - b'\"' =3D> f.write_str("\\\"")?, - 0x20..=3D0x7e =3D> f.write_char(c as char)?, - _ =3D> write!(f, "\\x{c:02x}")?, - } - } - f.write_str("\"") - } +/// Converts a mutable C string to a mutable byte slice. +/// +/// # Safety +/// +/// The caller must ensure that the slice ends in a NUL byte and contains = no other NUL bytes before +/// the borrow ends and the underlying [`CStr`] is used. +unsafe fn to_bytes_mut(s: &mut CStr) -> &mut [u8] { + // SAFETY: the cast from `&CStr` to `&[u8]` is safe since `CStr` has t= he same layout as `&[u8]` + // (this is technically not guaranteed, but we rely on it here). The p= ointer dereference is + // safe since it comes from a mutable reference which is guaranteed to= be valid for writes. + unsafe { &mut *(core::ptr::from_mut(s) as *mut [u8]) } } =20 -impl AsRef for CStr { +impl CStrExt for CStr { #[inline] - fn as_ref(&self) -> &BStr { - BStr::from_bytes(self.as_bytes()) + unsafe fn from_char_ptr<'a>(ptr: *const c_char) -> &'a Self { + // SAFETY: The safety preconditions are the same as for `CStr::fro= m_ptr`. + unsafe { CStr::from_ptr(ptr.cast()) } } -} =20 -impl Deref for CStr { - type Target =3D BStr; + #[inline] + unsafe fn from_bytes_with_nul_unchecked_mut(bytes: &mut [u8]) -> &mut = Self { + // SAFETY: the cast from `&[u8]` to `&CStr` is safe since the prop= erties of `bytes` are + // guaranteed by the safety precondition and `CStr` has the same l= ayout as `&[u8]` (this is + // technically not guaranteed, but we rely on it here). The pointe= r dereference is safe + // since it comes from a mutable reference which is guaranteed to = be valid for writes. + unsafe { &mut *(core::ptr::from_mut(bytes) as *mut CStr) } + } =20 #[inline] - fn deref(&self) -> &Self::Target { - self.as_ref() + fn as_char_ptr(&self) -> *const c_char { + self.as_ptr().cast() + } + + fn to_cstring(&self) -> Result { + CString::try_from(self) } -} =20 -impl Index> for CStr { - type Output =3D CStr; + fn make_ascii_lowercase(&mut self) { + // SAFETY: This doesn't introduce or remove NUL bytes in the C str= ing. + unsafe { to_bytes_mut(self) }.make_ascii_lowercase(); + } =20 - #[inline] - fn index(&self, index: ops::RangeFrom) -> &Self::Output { - // Delegate bounds checking to slice. - // Assign to _ to mute clippy's unnecessary operation warning. - let _ =3D &self.as_bytes()[index.start..]; - // SAFETY: We just checked the bounds. - unsafe { Self::from_bytes_with_nul_unchecked(&self.0[index.start..= ]) } + fn make_ascii_uppercase(&mut self) { + // SAFETY: This doesn't introduce or remove NUL bytes in the C str= ing. + unsafe { to_bytes_mut(self) }.make_ascii_uppercase(); } -} =20 -impl Index for CStr { - type Output =3D CStr; + fn to_ascii_lowercase(&self) -> Result { + let mut s =3D self.to_cstring()?; =20 - #[inline] - fn index(&self, _index: ops::RangeFull) -> &Self::Output { - self + s.make_ascii_lowercase(); + + Ok(s) } -} =20 -mod private { - use core::ops; + fn to_ascii_uppercase(&self) -> Result { + let mut s =3D self.to_cstring()?; =20 - // Marker trait for index types that can be forward to `BStr`. - pub trait CStrIndex {} + s.make_ascii_uppercase(); =20 - impl CStrIndex for usize {} - impl CStrIndex for ops::Range {} - impl CStrIndex for ops::RangeInclusive {} - impl CStrIndex for ops::RangeToInclusive {} + Ok(s) + } } =20 -impl Index for CStr -where - Idx: private::CStrIndex, - BStr: Index, -{ - type Output =3D >::Output; - +impl AsRef for CStr { #[inline] - fn index(&self, index: Idx) -> &Self::Output { - &self.as_ref()[index] + fn as_ref(&self) -> &BStr { + BStr::from_bytes(self.to_bytes()) } } =20 @@ -612,6 +402,13 @@ macro_rules! c_str { mod tests { use super::*; =20 + impl From for Error { + #[inline] + fn from(_: core::ffi::FromBytesWithNulError) -> Error { + EINVAL + } + } + macro_rules! format { ($($f:tt)*) =3D> ({ CString::try_from_fmt(fmt!($($f)*))?.to_str()? @@ -634,40 +431,28 @@ macro_rules! format { =20 #[test] fn test_cstr_to_str() -> Result { - let good_bytes =3D b"\xf0\x9f\xa6\x80\0"; - let checked_cstr =3D CStr::from_bytes_with_nul(good_bytes)?; - let checked_str =3D checked_cstr.to_str()?; + let cstr =3D c"\xf0\x9f\xa6\x80"; + let checked_str =3D cstr.to_str()?; assert_eq!(checked_str, "=F0=9F=A6=80"); Ok(()) } =20 #[test] fn test_cstr_to_str_invalid_utf8() -> Result { - let bad_bytes =3D b"\xc3\x28\0"; - let checked_cstr =3D CStr::from_bytes_with_nul(bad_bytes)?; - assert!(checked_cstr.to_str().is_err()); - Ok(()) - } - - #[test] - fn test_cstr_as_str_unchecked() -> Result { - let good_bytes =3D b"\xf0\x9f\x90\xA7\0"; - let checked_cstr =3D CStr::from_bytes_with_nul(good_bytes)?; - // SAFETY: The contents come from a string literal which contains = valid UTF-8. - let unchecked_str =3D unsafe { checked_cstr.as_str_unchecked() }; - assert_eq!(unchecked_str, "=F0=9F=90=A7"); + let cstr =3D c"\xc3\x28"; + assert!(cstr.to_str().is_err()); Ok(()) } =20 #[test] fn test_cstr_display() -> Result { - let hello_world =3D CStr::from_bytes_with_nul(b"hello, world!\0")?; + let hello_world =3D c"hello, world!"; assert_eq!(format!("{hello_world}"), "hello, world!"); - let non_printables =3D CStr::from_bytes_with_nul(b"\x01\x09\x0a\0"= )?; + let non_printables =3D c"\x01\x09\x0a"; assert_eq!(format!("{non_printables}"), "\\x01\\x09\\x0a"); - let non_ascii =3D CStr::from_bytes_with_nul(b"d\xe9j\xe0 vu\0")?; + let non_ascii =3D c"d\xe9j\xe0 vu"; assert_eq!(format!("{non_ascii}"), "d\\xe9j\\xe0 vu"); - let good_bytes =3D CStr::from_bytes_with_nul(b"\xf0\x9f\xa6\x80\0"= )?; + let good_bytes =3D c"\xf0\x9f\xa6\x80"; assert_eq!(format!("{good_bytes}"), "\\xf0\\x9f\\xa6\\x80"); Ok(()) } @@ -686,13 +471,13 @@ fn test_cstr_display_all_bytes() -> Result { =20 #[test] fn test_cstr_debug() -> Result { - let hello_world =3D CStr::from_bytes_with_nul(b"hello, world!\0")?; + let hello_world =3D c"hello, world!"; assert_eq!(format!("{hello_world:?}"), "\"hello, world!\""); - let non_printables =3D CStr::from_bytes_with_nul(b"\x01\x09\x0a\0"= )?; - assert_eq!(format!("{non_printables:?}"), "\"\\x01\\x09\\x0a\""); - let non_ascii =3D CStr::from_bytes_with_nul(b"d\xe9j\xe0 vu\0")?; + let non_printables =3D c"\x01\x09\x0a"; + assert_eq!(format!("{non_printables:?}"), "\"\\x01\\t\\n\""); + let non_ascii =3D c"d\xe9j\xe0 vu"; assert_eq!(format!("{non_ascii:?}"), "\"d\\xe9j\\xe0 vu\""); - let good_bytes =3D CStr::from_bytes_with_nul(b"\xf0\x9f\xa6\x80\0"= )?; + let good_bytes =3D c"\xf0\x9f\xa6\x80"; assert_eq!(format!("{good_bytes:?}"), "\"\\xf0\\x9f\\xa6\\x80\""); Ok(()) } diff --git a/rust/kernel/sync/condvar.rs b/rust/kernel/sync/condvar.rs index c6ec64295c9f..a24e25a690ee 100644 --- a/rust/kernel/sync/condvar.rs +++ b/rust/kernel/sync/condvar.rs @@ -8,7 +8,7 @@ use super::{lock::Backend, lock::Guard, LockClassKey}; use crate::{ ffi::{c_int, c_long}, - str::CStr, + str::{CStr, CStrExt as _}, task::{ MAX_SCHEDULE_TIMEOUT, TASK_FREEZABLE, TASK_INTERRUPTIBLE, TASK_NOR= MAL, TASK_UNINTERRUPTIBLE, }, diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs index 27202beef90c..5d7991e6d373 100644 --- a/rust/kernel/sync/lock.rs +++ b/rust/kernel/sync/lock.rs @@ -7,7 +7,7 @@ =20 use super::LockClassKey; use crate::{ - str::CStr, + str::{CStr, CStrExt as _}, types::{NotThreadSafe, Opaque, ScopeGuard}, }; use core::{cell::UnsafeCell, marker::PhantomPinned, pin::Pin}; diff --git a/rust/kernel/sync/lock/global.rs b/rust/kernel/sync/lock/global= .rs index d65f94b5caf2..79d0ef7fda86 100644 --- a/rust/kernel/sync/lock/global.rs +++ b/rust/kernel/sync/lock/global.rs @@ -5,7 +5,7 @@ //! Support for defining statics containing locks. =20 use crate::{ - str::CStr, + str::{CStr, CStrExt as _}, sync::lock::{Backend, Guard, Lock}, sync::{LockClassKey, LockedBy}, types::Opaque, --=20 2.51.1