Re: [net-next PATCH v12 1/6] net: phy: pass PHY driver to .match_phy_device OP

From: Benno Lossin
Date: Sun May 18 2025 - 09:31:44 EST


On Sat May 17, 2025 at 10:13 PM CEST, Christian Marangi wrote:
> Pass PHY driver pointer to .match_phy_device OP in addition to phydev.
> Having access to the PHY driver struct might be useful to check the
> PHY ID of the driver is being matched for in case the PHY ID scanned in
> the phydev is not consistent.
>
> A scenario for this is a PHY that change PHY ID after a firmware is
> loaded, in such case, the PHY ID stored in PHY device struct is not
> valid anymore and PHY will manually scan the ID in the match_phy_device
> function.
>
> Having the PHY driver info is also useful for those PHY driver that
> implement multiple simple .match_phy_device OP to match specific MMD PHY
> ID. With this extra info if the parsing logic is the same, the matching
> function can be generalized by using the phy_id in the PHY driver
> instead of hardcoding.
>
> Rust wrapper callback is updated to align to the new match_phy_device
> arguments.
>
> Suggested-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx>
> Reviewed-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx>
> Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
> ---
> drivers/net/phy/bcm87xx.c | 6 ++++--
> drivers/net/phy/icplus.c | 6 ++++--
> drivers/net/phy/marvell10g.c | 12 ++++++++----
> drivers/net/phy/micrel.c | 6 ++++--
> drivers/net/phy/nxp-c45-tja11xx.c | 12 ++++++++----
> drivers/net/phy/nxp-tja11xx.c | 6 ++++--
> drivers/net/phy/phy_device.c | 2 +-
> drivers/net/phy/realtek/realtek_main.c | 27 +++++++++++++++++---------
> drivers/net/phy/teranetics.c | 3 ++-
> include/linux/phy.h | 3 ++-
> rust/kernel/net/phy.rs | 1 +
> 11 files changed, 56 insertions(+), 28 deletions(-)

I haven't really looked at the C code, just the part that interfaces
with Rust, so:

Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx> # for Rust

---
Cheers,
Benno