Commit d25b8e74 authored by Russell King's avatar Russell King Committed by David S. Miller

net: dsa: better error reporting

Add additional error reporting to the generic DSA code, so it's easier
to debug when things go wrong.  This was useful when initially bringing
up 88e6176 on a new board.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4bac50ba
...@@ -326,8 +326,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ...@@ -326,8 +326,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
ret = dsa_slave_create(ds, parent, i, pd->port_names[i]); ret = dsa_slave_create(ds, parent, i, pd->port_names[i]);
if (ret < 0) { if (ret < 0) {
netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s)\n", netdev_err(dst->master_netdev, "[%d]: can't create dsa slave device for port %d(%s): %d\n",
index, i, pd->port_names[i]); index, i, pd->port_names[i], ret);
ret = 0; ret = 0;
} }
} }
......
...@@ -1026,8 +1026,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p, ...@@ -1026,8 +1026,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
struct dsa_switch *ds = p->parent; struct dsa_switch *ds = p->parent;
p->phy = ds->slave_mii_bus->phy_map[addr]; p->phy = ds->slave_mii_bus->phy_map[addr];
if (!p->phy) if (!p->phy) {
netdev_err(slave_dev, "no phy at %d\n", addr);
return -ENODEV; return -ENODEV;
}
/* Use already configured phy mode */ /* Use already configured phy mode */
if (p->phy_interface == PHY_INTERFACE_MODE_NA) if (p->phy_interface == PHY_INTERFACE_MODE_NA)
...@@ -1061,7 +1063,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ...@@ -1061,7 +1063,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
*/ */
ret = of_phy_register_fixed_link(port_dn); ret = of_phy_register_fixed_link(port_dn);
if (ret) { if (ret) {
netdev_err(slave_dev, "failed to register fixed PHY\n"); netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret);
return ret; return ret;
} }
phy_is_fixed = true; phy_is_fixed = true;
...@@ -1072,17 +1074,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ...@@ -1072,17 +1074,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
phy_flags = ds->drv->get_phy_flags(ds, p->port); phy_flags = ds->drv->get_phy_flags(ds, p->port);
if (phy_dn) { if (phy_dn) {
ret = of_mdio_parse_addr(&slave_dev->dev, phy_dn); int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
/* If this PHY address is part of phys_mii_mask, which means /* If this PHY address is part of phys_mii_mask, which means
* that we need to divert reads and writes to/from it, then we * that we need to divert reads and writes to/from it, then we
* want to bind this device using the slave MII bus created by * want to bind this device using the slave MII bus created by
* DSA to make that happen. * DSA to make that happen.
*/ */
if (!phy_is_fixed && ret >= 0 && if (!phy_is_fixed && phy_id >= 0 &&
(ds->phys_mii_mask & (1 << ret))) { (ds->phys_mii_mask & (1 << phy_id))) {
ret = dsa_slave_phy_connect(p, slave_dev, ret); ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
if (ret) if (ret) {
netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
return ret; return ret;
}
} else { } else {
p->phy = of_phy_connect(slave_dev, phy_dn, p->phy = of_phy_connect(slave_dev, phy_dn,
dsa_slave_adjust_link, dsa_slave_adjust_link,
...@@ -1099,8 +1104,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ...@@ -1099,8 +1104,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
*/ */
if (!p->phy) { if (!p->phy) {
ret = dsa_slave_phy_connect(p, slave_dev, p->port); ret = dsa_slave_phy_connect(p, slave_dev, p->port);
if (ret) if (ret) {
netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret);
return ret; return ret;
}
} else { } else {
netdev_info(slave_dev, "attached PHY at address %d [%s]\n", netdev_info(slave_dev, "attached PHY at address %d [%s]\n",
p->phy->addr, p->phy->drv->name); p->phy->addr, p->phy->drv->name);
...@@ -1212,6 +1219,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, ...@@ -1212,6 +1219,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
ret = dsa_slave_phy_setup(p, slave_dev); ret = dsa_slave_phy_setup(p, slave_dev);
if (ret) { if (ret) {
netdev_err(master, "error %d setting up slave phy\n", ret);
free_netdev(slave_dev); free_netdev(slave_dev);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment