Re: [PATCH] net: usb: lan78xx: add weak dependency with micrel phy module

From: Dragan Simic
Date: Sun Jul 28 2024 - 10:11:13 EST


Hello Andrew,

On 2024-07-28 01:29, Andrew Lunn wrote:
Before going into explaining my viewpoint, could someone, please, clarify
which LAN78xx USB-to-Ethernet bridge does this apply to? I already had
a look at a few LAN78xx datasheets, and I'm not sure how the external PHY
becomes exposed over the USB interface, so it needs a driver.

https://elixir.bootlin.com/linux/v6.10/source/drivers/net/usb/lan78xx.c#L2049

This is creating an MDIO bus device. The MDIO bus will be scanned and
PHYs on the bus found. There are then a few calls to phy_find_first()
which will get the PHY.

The code itself looks pretty broken, it is directly accessing PHY
registers, which a MAC driver should not do. That is a layering
violation.

Thanks for the clarification.

Basically, the way I see it, weakdeps are the right solution for the
problem at hand, i.e. for the generation of the initial ramdisk with
all the possible PHY driver modules. However, I don't think that some
automagical generation of the associated MODULE_WEAKDEP() statements
is the way to go. Instead, all those statements should be added by
hand to the lan78xx driver, making sure that each PHY is tested and
validated beforehand.