rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: gregkh@linuxfoundation.org, rust-for-linux@vger.kernel.org,
	tmgross@umich.edu, miguel.ojeda.sandonis@gmail.com,
	benno.lossin@proton.me, wedsonaf@gmail.com
Subject: Re: [RFC PATCH v3 1/3] rust: core abstractions for network PHY drivers
Date: Fri, 29 Sep 2023 14:23:14 +0200	[thread overview]
Message-ID: <4b0759fb-88f8-4470-a8e5-094aa0b0886c@lunn.ch> (raw)
In-Reply-To: <20230929.173856.1751823335892887678.fujita.tomonori@gmail.com>

> >> +/// Represents duplex mode.
> >> +pub enum DuplexMode {
> >> +    /// Full-duplex mode
> >> +    Half,
> >> +    /// Half-duplex mode
> >> +    Full,
> >> +    /// Unknown
> >> +    Unknown,
> >> +}
> > 
> > How are these enums going to be kept in sync with the C code?  This
> > doesn't seem like a good idea and will quickly cause very strange bugs
> > that will be impossible to debug :(
> 
> enum DeviceState is guaranteed to be kept in sync with enum phy_state
> in C. If the C code is changed without updating the Rust code,
> compiling the Rust code fails. This is because a rustified enum is
> generated from C's phy_state enum at compile time.
> 
> enum DuplexMode refers to C's defines in include/uapi/linux/ethtool.h:
> 
> #define DUPLEX_HALF             0x00
> #define DUPLEX_FULL             0x01
> #define DUPLEX_UNKNOWN          0xff
> 
> So we can't use the same trick. But I guess that these DUPLEX_* values
> are unlikely be changed.

I did suggest changing this into an enum. I've not tried it, but i
think it should just work.

      Andrew

  parent reply	other threads:[~2023-09-29 12:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 22:55 [RFC PATCH v3 0/3] Rust abstractions for network PHY drivers FUJITA Tomonori
2023-09-28 22:55 ` [RFC PATCH v3 1/3] rust: core " FUJITA Tomonori
2023-09-29  6:03   ` Greg KH
2023-09-29  8:38     ` FUJITA Tomonori
2023-09-29  9:11       ` Trevor Gross
2023-10-02 14:08         ` Andrew Lunn
2023-10-02 16:24           ` Miguel Ojeda
2023-10-02 19:08             ` Andrew Lunn
2023-10-09 12:25               ` Miguel Ojeda
2023-10-09 15:50                 ` Andrew Lunn
2023-10-09 16:16                   ` Miguel Ojeda
2023-10-09 16:29                     ` Andrew Lunn
2023-10-10 17:31                       ` Miguel Ojeda
2023-10-02 16:37           ` Trevor Gross
2023-09-29 11:39       ` Miguel Ojeda
2023-09-29 12:23       ` Andrew Lunn [this message]
2023-10-01 13:08       ` FUJITA Tomonori
2023-09-29  8:50     ` Trevor Gross
2023-09-29 18:42   ` Miguel Ojeda
2023-10-10 19:19   ` Wedson Almeida Filho
2023-10-10 20:28     ` Andrew Lunn
2023-10-10 21:00       ` Wedson Almeida Filho
2023-10-10 23:34         ` Andrew Lunn
2023-10-11  1:56           ` Wedson Almeida Filho
2023-10-11  5:17             ` FUJITA Tomonori
2023-10-10 22:50     ` Trevor Gross
2023-10-10 22:53       ` Miguel Ojeda
2023-10-10 23:06         ` FUJITA Tomonori
2023-10-10 23:12         ` Trevor Gross
2023-10-11 23:57           ` FUJITA Tomonori
2023-10-12  3:09             ` Trevor Gross
2023-10-12  3:16               ` FUJITA Tomonori
2023-10-12  4:20                 ` Trevor Gross
2023-10-12 15:05                   ` Andrew Lunn
2023-10-11  6:56     ` FUJITA Tomonori
2023-10-11 14:28       ` Wedson Almeida Filho
2023-10-11 14:59         ` FUJITA Tomonori
2023-10-11 23:28         ` FUJITA Tomonori
2023-10-11 17:35       ` Trevor Gross
2023-09-28 22:55 ` [RFC PATCH v3 2/3] MAINTAINERS: add Rust PHY abstractions to the ETHERNET PHY LIBRARY FUJITA Tomonori
2023-09-28 22:55 ` [RFC PATCH v3 3/3] net: phy: add Rust Asix PHY driver 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=4b0759fb-88f8-4470-a8e5-094aa0b0886c@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=benno.lossin@proton.me \
    --cc=fujita.tomonori@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=wedsonaf@gmail.com \
    /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).