diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-10-03 13:09:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-07 05:58:49 -0400 |
commit | d25b8e74291fec2dbf3fe3df7f20289eeaa9d28f (patch) | |
tree | c20a5e5778954ba7cbe12ae2dc24c5fea3f10806 /net/dsa/slave.c | |
parent | 4bac50bace0377138fed2ac3627c1ad470ea1eca (diff) |
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: Russell King <rmk+kernel@arm.linux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/slave.c')
-rw-r--r-- | net/dsa/slave.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 5f65f929902e..4f607bc2a845 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c | |||
@@ -1026,8 +1026,10 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p, | |||
1026 | struct dsa_switch *ds = p->parent; | 1026 | struct dsa_switch *ds = p->parent; |
1027 | 1027 | ||
1028 | p->phy = ds->slave_mii_bus->phy_map[addr]; | 1028 | p->phy = ds->slave_mii_bus->phy_map[addr]; |
1029 | if (!p->phy) | 1029 | if (!p->phy) { |
1030 | netdev_err(slave_dev, "no phy at %d\n", addr); | ||
1030 | return -ENODEV; | 1031 | return -ENODEV; |
1032 | } | ||
1031 | 1033 | ||
1032 | /* Use already configured phy mode */ | 1034 | /* Use already configured phy mode */ |
1033 | if (p->phy_interface == PHY_INTERFACE_MODE_NA) | 1035 | if (p->phy_interface == PHY_INTERFACE_MODE_NA) |
@@ -1061,7 +1063,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1061 | */ | 1063 | */ |
1062 | ret = of_phy_register_fixed_link(port_dn); | 1064 | ret = of_phy_register_fixed_link(port_dn); |
1063 | if (ret) { | 1065 | if (ret) { |
1064 | netdev_err(slave_dev, "failed to register fixed PHY\n"); | 1066 | netdev_err(slave_dev, "failed to register fixed PHY: %d\n", ret); |
1065 | return ret; | 1067 | return ret; |
1066 | } | 1068 | } |
1067 | phy_is_fixed = true; | 1069 | phy_is_fixed = true; |
@@ -1072,17 +1074,20 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1072 | phy_flags = ds->drv->get_phy_flags(ds, p->port); | 1074 | phy_flags = ds->drv->get_phy_flags(ds, p->port); |
1073 | 1075 | ||
1074 | if (phy_dn) { | 1076 | if (phy_dn) { |
1075 | ret = of_mdio_parse_addr(&slave_dev->dev, phy_dn); | 1077 | int phy_id = of_mdio_parse_addr(&slave_dev->dev, phy_dn); |
1078 | |||
1076 | /* If this PHY address is part of phys_mii_mask, which means | 1079 | /* If this PHY address is part of phys_mii_mask, which means |
1077 | * that we need to divert reads and writes to/from it, then we | 1080 | * that we need to divert reads and writes to/from it, then we |
1078 | * want to bind this device using the slave MII bus created by | 1081 | * want to bind this device using the slave MII bus created by |
1079 | * DSA to make that happen. | 1082 | * DSA to make that happen. |
1080 | */ | 1083 | */ |
1081 | if (!phy_is_fixed && ret >= 0 && | 1084 | if (!phy_is_fixed && phy_id >= 0 && |
1082 | (ds->phys_mii_mask & (1 << ret))) { | 1085 | (ds->phys_mii_mask & (1 << phy_id))) { |
1083 | ret = dsa_slave_phy_connect(p, slave_dev, ret); | 1086 | ret = dsa_slave_phy_connect(p, slave_dev, phy_id); |
1084 | if (ret) | 1087 | if (ret) { |
1088 | netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret); | ||
1085 | return ret; | 1089 | return ret; |
1090 | } | ||
1086 | } else { | 1091 | } else { |
1087 | p->phy = of_phy_connect(slave_dev, phy_dn, | 1092 | p->phy = of_phy_connect(slave_dev, phy_dn, |
1088 | dsa_slave_adjust_link, | 1093 | dsa_slave_adjust_link, |
@@ -1099,8 +1104,10 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, | |||
1099 | */ | 1104 | */ |
1100 | if (!p->phy) { | 1105 | if (!p->phy) { |
1101 | ret = dsa_slave_phy_connect(p, slave_dev, p->port); | 1106 | ret = dsa_slave_phy_connect(p, slave_dev, p->port); |
1102 | if (ret) | 1107 | if (ret) { |
1108 | netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); | ||
1103 | return ret; | 1109 | return ret; |
1110 | } | ||
1104 | } else { | 1111 | } else { |
1105 | netdev_info(slave_dev, "attached PHY at address %d [%s]\n", | 1112 | netdev_info(slave_dev, "attached PHY at address %d [%s]\n", |
1106 | p->phy->addr, p->phy->drv->name); | 1113 | p->phy->addr, p->phy->drv->name); |
@@ -1212,6 +1219,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, | |||
1212 | 1219 | ||
1213 | ret = dsa_slave_phy_setup(p, slave_dev); | 1220 | ret = dsa_slave_phy_setup(p, slave_dev); |
1214 | if (ret) { | 1221 | if (ret) { |
1222 | netdev_err(master, "error %d setting up slave phy\n", ret); | ||
1215 | free_netdev(slave_dev); | 1223 | free_netdev(slave_dev); |
1216 | return ret; | 1224 | return ret; |
1217 | } | 1225 | } |