rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benno Lossin <benno.lossin@proton.me>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: andrew@lunn.ch, tmgross@umich.edu, rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH v1] rust: net::phy support to C45 registers access
Date: Fri, 31 May 2024 14:04:18 +0000	[thread overview]
Message-ID: <310b155c-9f06-4748-85c4-cd8c87f196c1@proton.me> (raw)
In-Reply-To: <20240531.225857.1252492134294581333.fujita.tomonori@gmail.com>

On 31.05.24 15:58, FUJITA Tomonori wrote:
> Hi,
> 
> On Thu, 30 May 2024 08:05:50 +0000
> Benno Lossin <benno.lossin@proton.me> wrote:
>>> 802.3 C22 defines 16 through 31 as vendor specific. Most of the
>>> #defines appear to come from the S390 driver. We probably should not
>>> add them in the Rust API when there meaning is not clearly
>>> defined. However, a driver should be able to use them, e.g, by
>>> defining their own vendor specific name to a given value.
>>
>> @Fujita, you could fix this by adding a `VendorSpecific(T)` enum variant
>> and add a generic parameter to `C22`. Then the user has the option to
> 
> I'm not sure. You meant something like:
> 
> pub enum C22<T> {
>     Bmcr,
>     Bmsr,
>     VendorSpecific(T),
> }
> 
> ?

Yes.

> Then it's not handy to use the defined registers?
> 
> let ret = phy.read(reg::C22::<u8>::Bmcr)?;
> 
> I prefer:
> 
> let ret = phy.read(reg::C22::Bmcr)?;

Hmm I guess that it probably can't infer a default type. In that case,
you can also try if a struct approach for C22 is better. So:

    pub struct C22(u16); // choose the correct size

    impl C22 {
        pub fn new(reg: u16) -> Self;

        pub const BMCR: Self = Self::new(uapi::MII_BMCR);
        // ...
    }

And then a specific driver can declare its own constants.

---
Cheers,
Benno


  reply	other threads:[~2024-05-31 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27  1:46 [RFC PATCH v1] rust: net::phy support to C45 registers access FUJITA Tomonori
2024-05-27 21:57 ` Andrew Lunn
2024-05-27 23:03   ` FUJITA Tomonori
2024-05-28  0:18     ` Andrew Lunn
2024-05-30  5:52       ` FUJITA Tomonori
2024-05-31 14:12         ` Andrew Lunn
2024-05-30  8:05   ` Benno Lossin
2024-05-31 13:58     ` FUJITA Tomonori
2024-05-31 14:04       ` Benno Lossin [this message]
2024-06-01  4:51         ` FUJITA Tomonori
2024-05-30  8:02 ` Benno Lossin
2024-06-01  4:20   ` FUJITA Tomonori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=310b155c-9f06-4748-85c4-cd8c87f196c1@proton.me \
    --to=benno.lossin@proton.me \
    --cc=andrew@lunn.ch \
    --cc=fujita.tomonori@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).