Re: [PATCH v2 06/12] rust: io: register: implement Copy and Clone for RegisterArrayLoc
From: Gary Guo
Date: Mon Nov 09 2026 - 06:59:21 EST
On Sat Nov 7, 2026 at 9:48 AM GMT, Alexandre Courbot wrote:
> Register array locations are small values that are cheap to copy, but
> obtaining one can fail. Making them implement `Copy` lets the same
> location be checked once and used for several accesses.
>
> Cc: Danilo Krummrich <dakr@xxxxxxxxxx>
> Cc: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Cc: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> Cc: Gary Guo <gary@xxxxxxxxxxx>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
With the `#[inline]` nits fixed:
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> rust/kernel/io/register.rs | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/rust/kernel/io/register.rs b/rust/kernel/io/register.rs
> index b6513fa0f412..9e31e68d02cd 100644
> --- a/rust/kernel/io/register.rs
> +++ b/rust/kernel/io/register.rs
> @@ -194,6 +194,14 @@ pub fn try_new(idx: usize) -> Option<Self> {
> }
> }
>
> +impl<T: RegisterArray> Clone for RegisterArrayLoc<T> {
> + fn clone(&self) -> Self {
> + *self
> + }
> +}
> +
> +impl<T: RegisterArray> Copy for RegisterArrayLoc<T> {}
> +
> impl<Base: ?Sized, T> IoLoc<Base, T> for RegisterArrayLoc<T>
> where
> T: RegisterArray<Base = Base>,