mt753x DSA switch support - bug?

From: "Russell King (Oracle)" <linux@armlinux.org.uk>
Date: 2021-11-21 17:27:20

Hi,

While updating drivers that use phylink, I came across this code in
the mt7530 driver in mt753x_phylink_validate():

        if (state->interface != PHY_INTERFACE_MODE_TRGMII ||
            !phy_interface_mode_is_8023z(state->interface)) {
                phylink_set(mask, 10baseT_Half);
                phylink_set(mask, 10baseT_Full);
                phylink_set(mask, 100baseT_Half);
                phylink_set(mask, 100baseT_Full);
                phylink_set(mask, Autoneg);
        }

which looks wrong to me. The if() condition is always true, so all
these modes are always set in the mask.

If state->interface is PHY_INTERFACE_MODE_TRGMII, then the first
part of the condition is false. phy_interface_mode_is_8023z() is
also false, so !phy_interface_mode_is_8023z() will be true. The
logical-or results in the if() condition being true.

If state->interface is PHY_INTERFACE_MODE_1000BASEX, then the first
part of the condition is true, and due to the logical-or not needing
to be further evaluated, results in the if() condition being true.

If state->interface is PHY_INTERFACE_MODE_RGMII, then the first part
of the condition is true, and this is exactly the same as the second
case above.

I think that "||" should be "&&", since I believe you intend these
modes not to be available in TRGMII nor 802.3z modes. Please confirm.
Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help