[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250519.215821.1932215801961121518.fujita.tomonori@gmail.com>
Date: Mon, 19 May 2025 21:58:21 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: lossin@...nel.org
Cc: fujita.tomonori@...il.com, ansuelsmth@...il.com, andrew+netdev@...n.ch,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, hkallweit1@...il.com, linux@...linux.org.uk,
florian.fainelli@...adcom.com, bcm-kernel-feedback-list@...adcom.com,
kabel@...nel.org, andrei.botila@....nxp.com, tmgross@...ch.edu,
ojeda@...nel.org, alex.gaynor@...il.com, boqun.feng@...il.com,
gary@...yguo.net, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
a.hindborg@...nel.org, aliceryhl@...gle.com, dakr@...nel.org,
sd@...asysnail.net, michael@...sekall.de, daniel@...rotopia.org,
netdev@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [net-next PATCH v10 7/7] rust: net::phy sync with
match_phy_device C changes
On Mon, 19 May 2025 14:51:55 +0200
"Benno Lossin" <lossin@...nel.org> wrote:
> On Mon May 19, 2025 at 2:44 PM CEST, FUJITA Tomonori wrote:
>> On Mon, 19 May 2025 14:32:44 +0200
>> "Benno Lossin" <lossin@...nel.org> wrote:
>>>>>> The other use case, as mentioned above, is when using the generic helper
>>>>>> function inside match_phy_device() callback. For example, the 4th
>>>>>> patch in this patchset adds genphy_match_phy_device():
>>>>>>
>>>>>> int genphy_match_phy_device(struct phy_device *phydev,
>>>>>> const struct phy_driver *phydrv)
>>>>>>
>>>>>> We could add a wrapper for this function as phy::Device's method like
>>>>>>
>>>>>> impl Device {
>>>>>> ...
>>>>>> pub fn genphy_match_phy_device(&self, drv: &phy::DriverVTable) -> i32
>>>>>
>>>>> Not sure why this returns an `i32`, but we probably could have such a
>>>>
>>>> Maybe a bool would be more appropriate here because the C's comment
>>>> says:
>>>>
>>>> Return: 1 if the PHY device matches the driver, 0 otherwise.
>>>>
>>>>> function as well (though I wouldn't use the vtable for that).
>>>>
>>>> What would you use instead?
>>>
>>> The concept that I sketched above:
>>>
>>> impl Device {
>>> fn genphy_match_phy_device<T: Driver>(&self) -> bool {
>>> self.phy_id() == T::PHY_DEVICE_ID.id
>>> }
>>> }
>>
>> I think there might be a misunderstanding.
>>
>> Rust's genphy_match_phy_device() is supposed to be a wrapper for C's
>> genphy_match_phy_device():
>>
>> https://lore.kernel.org/rust-for-linux/20250517201353.5137-5-ansuelsmth@gmail.com/
>
> Oh yeah you're right. But using `DriverVTable` for that doesn't sound
> nice...
Agreed. We initially assumed that DriverVTable would be internal to
driver registration and not something driver developers would use
directly. Now that this has changed, it might be a good idea to rename
it.
Powered by blists - more mailing lists