Skip to content

Commit 1933492

Browse files
groeckdavem330
authored andcommitted
net: dsa: Set valid phy interface type
If the phy interface mode is not found in devicetree, or if devicetree is not configured, of_get_phy_mode returns -ENODEV. The current code sets the phy interface mode to the return value from of_get_phy_mode without checking if it is valid. This invalid phy interface mode is passed as parameter to of_phy_connect or to phy_connect_direct. This sets the phy interface mode to the invalid value, which in turn causes problems for any code using phydev->interface. Fixes: b31f65f ("net: dsa: slave: Fix autoneg for phys on switch MDIO bus") Fixes: 0d8bcdd ("net: dsa: allow for more complex PHY setups") Cc: Florian Fainelli <[email protected]> Cc: Andrew Lunn <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Acked-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7afb888 commit 1933492

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

net/dsa/slave.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,13 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
521521
struct device_node *phy_dn, *port_dn;
522522
bool phy_is_fixed = false;
523523
u32 phy_flags = 0;
524-
int ret;
524+
int mode, ret;
525525

526526
port_dn = cd->port_dn[p->port];
527-
p->phy_interface = of_get_phy_mode(port_dn);
527+
mode = of_get_phy_mode(port_dn);
528+
if (mode < 0)
529+
mode = PHY_INTERFACE_MODE_NA;
530+
p->phy_interface = mode;
528531

529532
phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
530533
if (of_phy_is_fixed_link(port_dn)) {
@@ -559,6 +562,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
559562
if (!p->phy)
560563
return -ENODEV;
561564

565+
/* Use already configured phy mode */
566+
p->phy_interface = p->phy->interface;
562567
phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
563568
p->phy_interface);
564569
} else {

0 commit comments

Comments
 (0)