Re: [PATCH net-next v2] net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy

From: Russell King (Oracle)
Date: Fri Dec 02 2022 - 08:34:44 EST


On Fri, Dec 02, 2022 at 02:27:43PM +0100, Andrew Lunn wrote:
> > +static bool mdio_is_locked(struct phy_device *phydev)
> > +{
> > + return mutex_is_locked(&phydev->mdio.bus->mdio_lock);
> > +}
> > +
> > +#define ASSERT_MDIO(phydev) \
> > + WARN_ONCE(!mdio_is_locked(phydev), \
> > + "MDIO: assertion failed at %s (%d)\n", __FILE__, __LINE__)
> > +
>
> Hi Frank
>
> You are not the only one who gets locking wrong. This could be used in
> other drivers. Please add it to include/linux/phy.h,

That placement doesn't make much sense.

As I already said, we have lockdep checks in drivers/net/phy/mdio_bus.c,
and if we want to increase their effectiveness, then that's the place
that it should be done.

I don't see any point in using __FILE__ and __LINE__ in the above
macro either. Firstly, WARN_ONCE() already includes the file and line,
and secondly, the backtrace is more useful than the file and line where
the assertion occurs especially if it's placed in mdio_bus.c

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!