diff options
author | Lennert Buytenhek <buytenh@wantstofly.org> | 2009-02-12 09:06:46 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-02-16 02:43:53 -0500 |
commit | 6bdf576e4b068e86381280c58393cad42ffc8cc8 (patch) | |
tree | 8c83f2c09ecaf591f37714278683d5113015b771 /drivers/net/mv643xx_eth.c | |
parent | aa611f85d0d656870dbb906e75d8cac6acb58943 (diff) |
mv643xx_eth: unify ethtool ops for phy'd and phy-less interfaces
It's a waste having two different versions of this structure around
when the differences between ethtool ops for phy'd and phy-less
interfaces are so minor.
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mv643xx_eth.c')
-rw-r--r-- | drivers/net/mv643xx_eth.c | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index 8fab31f631a0..e8fbc0badf7e 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c | |||
@@ -1279,9 +1279,9 @@ static const struct mv643xx_eth_stats mv643xx_eth_stats[] = { | |||
1279 | }; | 1279 | }; |
1280 | 1280 | ||
1281 | static int | 1281 | static int |
1282 | mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1282 | mv643xx_eth_get_settings_phy(struct mv643xx_eth_private *mp, |
1283 | struct ethtool_cmd *cmd) | ||
1283 | { | 1284 | { |
1284 | struct mv643xx_eth_private *mp = netdev_priv(dev); | ||
1285 | int err; | 1285 | int err; |
1286 | 1286 | ||
1287 | err = phy_read_status(mp->phy); | 1287 | err = phy_read_status(mp->phy); |
@@ -1298,10 +1298,9 @@ mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | static int | 1300 | static int |
1301 | mv643xx_eth_get_settings_phyless(struct net_device *dev, | 1301 | mv643xx_eth_get_settings_phyless(struct mv643xx_eth_private *mp, |
1302 | struct ethtool_cmd *cmd) | 1302 | struct ethtool_cmd *cmd) |
1303 | { | 1303 | { |
1304 | struct mv643xx_eth_private *mp = netdev_priv(dev); | ||
1305 | u32 port_status; | 1304 | u32 port_status; |
1306 | 1305 | ||
1307 | port_status = rdlp(mp, PORT_STATUS); | 1306 | port_status = rdlp(mp, PORT_STATUS); |
@@ -1334,10 +1333,24 @@ mv643xx_eth_get_settings_phyless(struct net_device *dev, | |||
1334 | } | 1333 | } |
1335 | 1334 | ||
1336 | static int | 1335 | static int |
1336 | mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | ||
1337 | { | ||
1338 | struct mv643xx_eth_private *mp = netdev_priv(dev); | ||
1339 | |||
1340 | if (mp->phy != NULL) | ||
1341 | return mv643xx_eth_get_settings_phy(mp, cmd); | ||
1342 | else | ||
1343 | return mv643xx_eth_get_settings_phyless(mp, cmd); | ||
1344 | } | ||
1345 | |||
1346 | static int | ||
1337 | mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1347 | mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
1338 | { | 1348 | { |
1339 | struct mv643xx_eth_private *mp = netdev_priv(dev); | 1349 | struct mv643xx_eth_private *mp = netdev_priv(dev); |
1340 | 1350 | ||
1351 | if (mp->phy == NULL) | ||
1352 | return -EINVAL; | ||
1353 | |||
1341 | /* | 1354 | /* |
1342 | * The MAC does not support 1000baseT_Half. | 1355 | * The MAC does not support 1000baseT_Half. |
1343 | */ | 1356 | */ |
@@ -1346,13 +1359,6 @@ mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
1346 | return phy_ethtool_sset(mp->phy, cmd); | 1359 | return phy_ethtool_sset(mp->phy, cmd); |
1347 | } | 1360 | } |
1348 | 1361 | ||
1349 | static int | ||
1350 | mv643xx_eth_set_settings_phyless(struct net_device *dev, | ||
1351 | struct ethtool_cmd *cmd) | ||
1352 | { | ||
1353 | return -EINVAL; | ||
1354 | } | ||
1355 | |||
1356 | static void mv643xx_eth_get_drvinfo(struct net_device *dev, | 1362 | static void mv643xx_eth_get_drvinfo(struct net_device *dev, |
1357 | struct ethtool_drvinfo *drvinfo) | 1363 | struct ethtool_drvinfo *drvinfo) |
1358 | { | 1364 | { |
@@ -1367,12 +1373,10 @@ static int mv643xx_eth_nway_reset(struct net_device *dev) | |||
1367 | { | 1373 | { |
1368 | struct mv643xx_eth_private *mp = netdev_priv(dev); | 1374 | struct mv643xx_eth_private *mp = netdev_priv(dev); |
1369 | 1375 | ||
1370 | return genphy_restart_aneg(mp->phy); | 1376 | if (mp->phy == NULL) |
1371 | } | 1377 | return -EINVAL; |
1372 | 1378 | ||
1373 | static int mv643xx_eth_nway_reset_phyless(struct net_device *dev) | 1379 | return genphy_restart_aneg(mp->phy); |
1374 | { | ||
1375 | return -EINVAL; | ||
1376 | } | 1380 | } |
1377 | 1381 | ||
1378 | static u32 mv643xx_eth_get_link(struct net_device *dev) | 1382 | static u32 mv643xx_eth_get_link(struct net_device *dev) |
@@ -1440,18 +1444,6 @@ static const struct ethtool_ops mv643xx_eth_ethtool_ops = { | |||
1440 | .get_sset_count = mv643xx_eth_get_sset_count, | 1444 | .get_sset_count = mv643xx_eth_get_sset_count, |
1441 | }; | 1445 | }; |
1442 | 1446 | ||
1443 | static const struct ethtool_ops mv643xx_eth_ethtool_ops_phyless = { | ||
1444 | .get_settings = mv643xx_eth_get_settings_phyless, | ||
1445 | .set_settings = mv643xx_eth_set_settings_phyless, | ||
1446 | .get_drvinfo = mv643xx_eth_get_drvinfo, | ||
1447 | .nway_reset = mv643xx_eth_nway_reset_phyless, | ||
1448 | .get_link = mv643xx_eth_get_link, | ||
1449 | .set_sg = ethtool_op_set_sg, | ||
1450 | .get_strings = mv643xx_eth_get_strings, | ||
1451 | .get_ethtool_stats = mv643xx_eth_get_ethtool_stats, | ||
1452 | .get_sset_count = mv643xx_eth_get_sset_count, | ||
1453 | }; | ||
1454 | |||
1455 | 1447 | ||
1456 | /* address handling *********************************************************/ | 1448 | /* address handling *********************************************************/ |
1457 | static void uc_addr_get(struct mv643xx_eth_private *mp, unsigned char *addr) | 1449 | static void uc_addr_get(struct mv643xx_eth_private *mp, unsigned char *addr) |
@@ -2673,12 +2665,10 @@ static int mv643xx_eth_probe(struct platform_device *pdev) | |||
2673 | if (pd->phy_addr != MV643XX_ETH_PHY_NONE) | 2665 | if (pd->phy_addr != MV643XX_ETH_PHY_NONE) |
2674 | mp->phy = phy_scan(mp, pd->phy_addr); | 2666 | mp->phy = phy_scan(mp, pd->phy_addr); |
2675 | 2667 | ||
2676 | if (mp->phy != NULL) { | 2668 | if (mp->phy != NULL) |
2677 | phy_init(mp, pd->speed, pd->duplex); | 2669 | phy_init(mp, pd->speed, pd->duplex); |
2678 | SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops); | 2670 | |
2679 | } else { | 2671 | SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops); |
2680 | SET_ETHTOOL_OPS(dev, &mv643xx_eth_ethtool_ops_phyless); | ||
2681 | } | ||
2682 | 2672 | ||
2683 | init_pscr(mp, pd->speed, pd->duplex); | 2673 | init_pscr(mp, pd->speed, pd->duplex); |
2684 | 2674 | ||