Messages in this thread | | | Date | Sat, 24 Jun 2023 22:15:43 +0200 | From | Andrew Lunn <> | Subject | Re: [PATCH net-next v2 07/10] net: phy: add support for C45-over-C22 transfers |
| |
> int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) > { > - int val; > + struct mii_bus *bus = phydev->mdio.bus; > + int phy_addr = phydev->mdio.addr; > + bool check_rc = true; > + int ret;
Although __phy_read_mmd() is exported as a GPL symbol, it is not in fact used outside of this file. I think we can easily change it signature.
> + switch (phydev->access_mode) {
Have access_mode passed in as a parameter. It then becomes a generic low level helper.
The function which is really exported and expected to by used by PHY drivers is:
int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum) { int ret;
phy_lock_mdio_bus(phydev); ret = __phy_read_mmd(phydev, devad, regnum); phy_unlock_mdio_bus(phydev);
return ret; } EXPORT_SYMBOL(phy_read_mmd);
This can easily pass phydev->access_mode as a parameter.
> +static int phy_probe_mmd_read(struct mii_bus *bus, int prtad, int devad, > + u16 regnum, bool c45_over_c22) > +{
What i don't like is this bool c45_over_c22. Why have both the enum for the three access modes, and this bool. Pass an access mode.
> + int ret; > + > + if (!c45_over_c22) > + return mdiobus_c45_read(bus, prtad, devad, regnum); > + > + mutex_lock(&bus->mdio_lock); > + > + ret = __phy_mmd_indirect(bus, prtad, devad, regnum); > + if (ret) > + goto out; > + > + ret = __mdiobus_read(bus, prtad, MII_MMD_DATA);
And then this just uses the generic low level __phy_read_mmd().
Andrew
| |