Re: [PATCH v3 2/3] rust: net::phy represent DeviceId as transparent wrapper over mdio_device_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri Jul 4, 2025 at 12:10 AM EDT, FUJITA Tomonori wrote:
> Refactor the DeviceId struct to be a #[repr(transparent)] wrapper
> around the C struct bindings::mdio_device_id.
>
> This refactoring is a preparation for enabling the PHY abstractions to
> use device_id trait.

Should this say "the `DeviceId` trait" (different case)?

> Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
> ---
>  rust/kernel/net/phy.rs | 53 +++++++++++++++++++++---------------------
>  1 file changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> index 65ac4d59ad77..940972ffadae 100644
> --- a/rust/kernel/net/phy.rs
> +++ b/rust/kernel/net/phy.rs
> [...]
> @@ -734,18 +733,20 @@ pub const fn new_with_driver<T: Driver>() -> Self {
>          T::PHY_DEVICE_ID
>      }
>  
> +    /// Get a `phy_id` as u32.
> +    pub const fn id(&self) -> u32 {
> +        self.0.phy_id
> +    }

For the docs maybe just:

    /// Get the MDIO device's phy ID.

Since `as u32` is slightly redundant (it's in the return type, and that
is how it is stored anyway).

>      /// Get a `mask` as u32.
>      pub const fn mask_as_int(&self) -> u32 {
> -        self.mask.as_int()
> +        self.0.phy_id_mask
>      }

One optional nit then:

Reviewed-by: Trevor Gross <tmgross@xxxxxxxxx>





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux