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

Andrew Lunn
2024-07-26T11:34:12Z

On Thu, Jul 25, 2024 at 11:53:54AM +0200, Paolo Abeni wrote:
> On 7/25/24 08:50, Lucas De Marchi wrote:
> > if you are saying that the build system should automatically convert
> > this:
> >
> > config USB_LAN78XX
> > tristate "Microchip LAN78XX Based USB Ethernet Adapters"
> > select MII
> > select PHYLIB
> > select MICROCHIP_PHY
> > select FIXED_PHY
> > select CRC32
> >
> > into (for my config):
> >
> > MODULE_WEAKDEP("mii");
> > MODULE_WEAKDEP("microchip");
> >
> > then humn... why is CONFIG_MICREL (being added in this patch) not there?
> > It seems even if we automatically derive that information it wouldn't
> > fix the problem Jose is trying to solve.
>
> I hoped that the 'weak dependency' towards mii and microchip could be
> inferred greping for 'request_module()' in the relevant code, but apparently
> it's not the case.

Nope. The module is not explicitly loaded by this driver. The PHY core
will look at ID registers in the PHY to determine what it is, and then
load a module which says it drives that ID.

There are also pin compatible PHYs, so it is possible a different
version of the LAN78xx USB dongle could need a different PHY
driver. So you might need multiple of these week dependencies.

And there are many boards using for example the FEC, with many
different PHYs in use, since Freescale was never really a PHY vendor,
its not really paired with a Freescale PHY.

As i said, whacker a mole.

So you cannot use this to determine what PHY driver goes into the
initramfs.

What this does appear to do is differentiate between 'pre' which will
load the kernel module before it is requested. Since there is no 'pre'
for this, it seems pointless whacking this mole.

What to me make more sense it to look at all the existing 'pre'
drivers and determine if they can be converted to use this macro.

Andrew