[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5525a61c-01b7-4032-97ee-4997b19979ad@lunn.ch>
Date: Wed, 31 Jul 2024 14:24:08 +0200
From: Andrew Lunn <andrew@...n.ch>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: netdev@...r.kernel.org, rust-for-linux@...r.kernel.org,
tmgross@...ch.edu, miguel.ojeda.sandonis@...il.com,
benno.lossin@...ton.me
Subject: Re: [PATCH net-next v2 2/6] rust: net::phy support probe callback
On Wed, Jul 31, 2024 at 01:21:32PM +0900, FUJITA Tomonori wrote:
> Support phy_driver probe callback, used to set up device-specific
> structures.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@...il.com>
> ---
> rust/kernel/net/phy.rs | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> index fd40b703d224..99a142348a34 100644
> --- a/rust/kernel/net/phy.rs
> +++ b/rust/kernel/net/phy.rs
> @@ -338,6 +338,20 @@ impl<T: Driver> Adapter<T> {
> })
> }
>
> + /// # Safety
> + ///
> + /// `phydev` must be passed by the corresponding callback in `phy_driver`.
> + unsafe extern "C" fn probe_callback(phydev: *mut bindings::phy_device) -> core::ffi::c_int {
> + from_result(|| {
> + // SAFETY: This callback is called only in contexts
> + // where we can exclusively access to `phy_device`, so the accessors on
> + // `Device` are okay to call.
This one is slightly different to other callbacks. probe is called
without the mutex. Instead, probe is called before the device is
published. So the comment is correct, but given how important Rust
people take these SAFETY comments, maybe it should indicate it is
different to others?
Andrew
Powered by blists - more mailing lists