[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2024041800-justice-rectify-3715@gregkh>
Date: Thu, 18 Apr 2024 15:07:19 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: netdev@...r.kernel.org, andrew@...n.ch, rust-for-linux@...r.kernel.org,
tmgross@...ch.edu, mcgrof@...nel.org, russ.weight@...ux.dev
Subject: Re: [PATCH net-next v1 3/4] rust: net::phy support Firmware API
On Thu, Apr 18, 2024 at 09:51:08PM +0900, FUJITA Tomonori wrote:
> >> diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
> >> index 421a231421f5..095dc3ccc553 100644
> >> --- a/rust/kernel/net/phy.rs
> >> +++ b/rust/kernel/net/phy.rs
> >> @@ -9,6 +9,51 @@
> >> use crate::{bindings, error::*, prelude::*, str::CStr, types::Opaque};
> >>
> >> use core::marker::PhantomData;
> >> +use core::ptr::{self, NonNull};
> >> +
> >> +/// A pointer to the kernel's `struct firmware`.
> >> +///
> >> +/// # Invariants
> >> +///
> >> +/// The pointer points at a `struct firmware`, and has ownership over the object.
> >> +pub struct Firmware(NonNull<bindings::firmware>);
> >> +
> >> +impl Firmware {
> >> + /// Loads a firmware.
> >> + pub fn new(name: &CStr, dev: &Device) -> Result<Firmware> {
> >> + let phydev = dev.0.get();
> >
> > That's risky, how do you "know" this device really is a phydev?
>
> That's guaranteed. The above `Device` is phy::Device.
How are we supposed to know that from reading this diff? I think you
all need to work on naming things better, as that's going to get _VERY_
confusing very quickly.
thanks,
greg k-h
Powered by blists - more mailing lists