aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2015-02-17 00:23:51 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-17 13:37:39 -0500
commit19334920eaf7df3f69950b040ede6c7598425a5b (patch)
tree42c0b8a3df8bb7393c7e467f73feed8d6f7e722b /net
parent7afb8886a05be68e376655539a064ec672de8a8e (diff)
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: b31f65fb4383 ("net: dsa: slave: Fix autoneg for phys on switch MDIO bus") Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups") Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/dsa/slave.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index d104ae15836f..f23deadf42a0 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -521,10 +521,13 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
521 struct device_node *phy_dn, *port_dn; 521 struct device_node *phy_dn, *port_dn;
522 bool phy_is_fixed = false; 522 bool phy_is_fixed = false;
523 u32 phy_flags = 0; 523 u32 phy_flags = 0;
524 int ret; 524 int mode, ret;
525 525
526 port_dn = cd->port_dn[p->port]; 526 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;
528 531
529 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); 532 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
530 if (of_phy_is_fixed_link(port_dn)) { 533 if (of_phy_is_fixed_link(port_dn)) {
@@ -559,6 +562,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
559 if (!p->phy) 562 if (!p->phy)
560 return -ENODEV; 563 return -ENODEV;
561 564
565 /* Use already configured phy mode */
566 p->phy_interface = p->phy->interface;
562 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 567 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
563 p->phy_interface); 568 p->phy_interface);
564 } else { 569 } else {