rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH linux] of: resolves TODO for copy_from_slice
@ 2025-08-10 23:23 ~_xllx_
  2025-08-11  7:13 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: ~_xllx_ @ 2025-08-10 23:23 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Rob Herring, Saravana Kannan
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	rust-for-linux, devicetree

From: elle <elle@weathered-steel.dev>

Replaces the copy loop with `copy_from_slice` which became `const` in
stable Rust with version `1.87.0`.

Authored-by: elle <elle@weathered-steel.dev>
Signed-off-by: elle <elle@weathered-steel.dev>
---
 rust/kernel/of.rs | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/rust/kernel/of.rs b/rust/kernel/of.rs
index b76b35265df2..6a5d27b741c6 100644
--- a/rust/kernel/of.rs
+++ b/rust/kernel/of.rs
@@ -39,12 +39,7 @@ impl DeviceId {
         // SAFETY: FFI type is valid to be zero-initialized.
         let mut of: bindings::of_device_id = unsafe { core::mem::zeroed() };
 
-        // TODO: Use `copy_from_slice` once stabilized for `const`.
-        let mut i = 0;
-        while i < src.len() {
-            of.compatible[i] = src[i];
-            i += 1;
-        }
+        of.compatible.copy_from_slice(src);
 
         Self(of)
     }
-- 
2.49.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-12  9:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-10 23:23 [PATCH linux] of: resolves TODO for copy_from_slice ~_xllx_
2025-08-11  7:13 ` Greg KH
2025-08-11  8:52   ` Elle
2025-08-11  8:02 ` Alice Ryhl
2025-08-11  8:51   ` Elle
2025-08-11 10:41     ` Miguel Ojeda
2025-08-12  9:55 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).