net: silan: sc92031: use new api ethtool_{get|set}_link_ksettings

The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

As I don't have the hardware, I'd be very pleased if
someone may test this patch.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Philippe Reynes 2017-02-27 22:50:25 +01:00 committed by David S. Miller
parent b61a26f8d4
commit a972c3062f
1 changed files with 47 additions and 36 deletions

View File

@ -1122,14 +1122,16 @@ static void sc92031_poll_controller(struct net_device *dev)
} }
#endif #endif
static int sc92031_ethtool_get_settings(struct net_device *dev, static int
struct ethtool_cmd *cmd) sc92031_ethtool_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ {
struct sc92031_priv *priv = netdev_priv(dev); struct sc92031_priv *priv = netdev_priv(dev);
void __iomem *port_base = priv->port_base; void __iomem *port_base = priv->port_base;
u8 phy_address; u8 phy_address;
u32 phy_ctrl; u32 phy_ctrl;
u16 output_status; u16 output_status;
u32 supported, advertising;
spin_lock_bh(&priv->lock); spin_lock_bh(&priv->lock);
@ -1142,68 +1144,77 @@ static int sc92031_ethtool_get_settings(struct net_device *dev,
spin_unlock_bh(&priv->lock); spin_unlock_bh(&priv->lock);
cmd->supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full
| SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full
| SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII; | SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII;
cmd->advertising = ADVERTISED_TP | ADVERTISED_MII; advertising = ADVERTISED_TP | ADVERTISED_MII;
if ((phy_ctrl & (PhyCtrlDux | PhyCtrlSpd100 | PhyCtrlSpd10)) if ((phy_ctrl & (PhyCtrlDux | PhyCtrlSpd100 | PhyCtrlSpd10))
== (PhyCtrlDux | PhyCtrlSpd100 | PhyCtrlSpd10)) == (PhyCtrlDux | PhyCtrlSpd100 | PhyCtrlSpd10))
cmd->advertising |= ADVERTISED_Autoneg; advertising |= ADVERTISED_Autoneg;
if ((phy_ctrl & PhyCtrlSpd10) == PhyCtrlSpd10) if ((phy_ctrl & PhyCtrlSpd10) == PhyCtrlSpd10)
cmd->advertising |= ADVERTISED_10baseT_Half; advertising |= ADVERTISED_10baseT_Half;
if ((phy_ctrl & (PhyCtrlSpd10 | PhyCtrlDux)) if ((phy_ctrl & (PhyCtrlSpd10 | PhyCtrlDux))
== (PhyCtrlSpd10 | PhyCtrlDux)) == (PhyCtrlSpd10 | PhyCtrlDux))
cmd->advertising |= ADVERTISED_10baseT_Full; advertising |= ADVERTISED_10baseT_Full;
if ((phy_ctrl & PhyCtrlSpd100) == PhyCtrlSpd100) if ((phy_ctrl & PhyCtrlSpd100) == PhyCtrlSpd100)
cmd->advertising |= ADVERTISED_100baseT_Half; advertising |= ADVERTISED_100baseT_Half;
if ((phy_ctrl & (PhyCtrlSpd100 | PhyCtrlDux)) if ((phy_ctrl & (PhyCtrlSpd100 | PhyCtrlDux))
== (PhyCtrlSpd100 | PhyCtrlDux)) == (PhyCtrlSpd100 | PhyCtrlDux))
cmd->advertising |= ADVERTISED_100baseT_Full; advertising |= ADVERTISED_100baseT_Full;
if (phy_ctrl & PhyCtrlAne) if (phy_ctrl & PhyCtrlAne)
cmd->advertising |= ADVERTISED_Autoneg; advertising |= ADVERTISED_Autoneg;
ethtool_cmd_speed_set(cmd, cmd->base.speed = (output_status & 0x2) ? SPEED_100 : SPEED_10;
(output_status & 0x2) ? SPEED_100 : SPEED_10); cmd->base.duplex = (output_status & 0x4) ? DUPLEX_FULL : DUPLEX_HALF;
cmd->duplex = (output_status & 0x4) ? DUPLEX_FULL : DUPLEX_HALF; cmd->base.port = PORT_MII;
cmd->port = PORT_MII; cmd->base.phy_address = phy_address;
cmd->phy_address = phy_address; cmd->base.autoneg = (phy_ctrl & PhyCtrlAne) ?
cmd->transceiver = XCVR_INTERNAL; AUTONEG_ENABLE : AUTONEG_DISABLE;
cmd->autoneg = (phy_ctrl & PhyCtrlAne) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising,
advertising);
return 0; return 0;
} }
static int sc92031_ethtool_set_settings(struct net_device *dev, static int
struct ethtool_cmd *cmd) sc92031_ethtool_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ {
struct sc92031_priv *priv = netdev_priv(dev); struct sc92031_priv *priv = netdev_priv(dev);
void __iomem *port_base = priv->port_base; void __iomem *port_base = priv->port_base;
u32 speed = ethtool_cmd_speed(cmd); u32 speed = cmd->base.speed;
u32 phy_ctrl; u32 phy_ctrl;
u32 old_phy_ctrl; u32 old_phy_ctrl;
u32 advertising;
ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising);
if (!(speed == SPEED_10 || speed == SPEED_100)) if (!(speed == SPEED_10 || speed == SPEED_100))
return -EINVAL; return -EINVAL;
if (!(cmd->duplex == DUPLEX_HALF || cmd->duplex == DUPLEX_FULL)) if (!(cmd->base.duplex == DUPLEX_HALF ||
cmd->base.duplex == DUPLEX_FULL))
return -EINVAL; return -EINVAL;
if (!(cmd->port == PORT_MII)) if (!(cmd->base.port == PORT_MII))
return -EINVAL; return -EINVAL;
if (!(cmd->phy_address == 0x1f)) if (!(cmd->base.phy_address == 0x1f))
return -EINVAL; return -EINVAL;
if (!(cmd->transceiver == XCVR_INTERNAL)) if (!(cmd->base.autoneg == AUTONEG_DISABLE ||
return -EINVAL; cmd->base.autoneg == AUTONEG_ENABLE))
if (!(cmd->autoneg == AUTONEG_DISABLE || cmd->autoneg == AUTONEG_ENABLE))
return -EINVAL; return -EINVAL;
if (cmd->autoneg == AUTONEG_ENABLE) { if (cmd->base.autoneg == AUTONEG_ENABLE) {
if (!(cmd->advertising & (ADVERTISED_Autoneg if (!(advertising & (ADVERTISED_Autoneg
| ADVERTISED_100baseT_Full | ADVERTISED_100baseT_Full
| ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Half
| ADVERTISED_10baseT_Full | ADVERTISED_10baseT_Full
@ -1213,15 +1224,15 @@ static int sc92031_ethtool_set_settings(struct net_device *dev,
phy_ctrl = PhyCtrlAne; phy_ctrl = PhyCtrlAne;
// FIXME: I'm not sure what the original code was trying to do // FIXME: I'm not sure what the original code was trying to do
if (cmd->advertising & ADVERTISED_Autoneg) if (advertising & ADVERTISED_Autoneg)
phy_ctrl |= PhyCtrlDux | PhyCtrlSpd100 | PhyCtrlSpd10; phy_ctrl |= PhyCtrlDux | PhyCtrlSpd100 | PhyCtrlSpd10;
if (cmd->advertising & ADVERTISED_100baseT_Full) if (advertising & ADVERTISED_100baseT_Full)
phy_ctrl |= PhyCtrlDux | PhyCtrlSpd100; phy_ctrl |= PhyCtrlDux | PhyCtrlSpd100;
if (cmd->advertising & ADVERTISED_100baseT_Half) if (advertising & ADVERTISED_100baseT_Half)
phy_ctrl |= PhyCtrlSpd100; phy_ctrl |= PhyCtrlSpd100;
if (cmd->advertising & ADVERTISED_10baseT_Full) if (advertising & ADVERTISED_10baseT_Full)
phy_ctrl |= PhyCtrlSpd10 | PhyCtrlDux; phy_ctrl |= PhyCtrlSpd10 | PhyCtrlDux;
if (cmd->advertising & ADVERTISED_10baseT_Half) if (advertising & ADVERTISED_10baseT_Half)
phy_ctrl |= PhyCtrlSpd10; phy_ctrl |= PhyCtrlSpd10;
} else { } else {
// FIXME: Whole branch guessed // FIXME: Whole branch guessed
@ -1232,7 +1243,7 @@ static int sc92031_ethtool_set_settings(struct net_device *dev,
else /* cmd->speed == SPEED_100 */ else /* cmd->speed == SPEED_100 */
phy_ctrl |= PhyCtrlSpd100; phy_ctrl |= PhyCtrlSpd100;
if (cmd->duplex == DUPLEX_FULL) if (cmd->base.duplex == DUPLEX_FULL)
phy_ctrl |= PhyCtrlDux; phy_ctrl |= PhyCtrlDux;
} }
@ -1368,8 +1379,6 @@ static void sc92031_ethtool_get_ethtool_stats(struct net_device *dev,
} }
static const struct ethtool_ops sc92031_ethtool_ops = { static const struct ethtool_ops sc92031_ethtool_ops = {
.get_settings = sc92031_ethtool_get_settings,
.set_settings = sc92031_ethtool_set_settings,
.get_wol = sc92031_ethtool_get_wol, .get_wol = sc92031_ethtool_get_wol,
.set_wol = sc92031_ethtool_set_wol, .set_wol = sc92031_ethtool_set_wol,
.nway_reset = sc92031_ethtool_nway_reset, .nway_reset = sc92031_ethtool_nway_reset,
@ -1377,6 +1386,8 @@ static const struct ethtool_ops sc92031_ethtool_ops = {
.get_strings = sc92031_ethtool_get_strings, .get_strings = sc92031_ethtool_get_strings,
.get_sset_count = sc92031_ethtool_get_sset_count, .get_sset_count = sc92031_ethtool_get_sset_count,
.get_ethtool_stats = sc92031_ethtool_get_ethtool_stats, .get_ethtool_stats = sc92031_ethtool_get_ethtool_stats,
.get_link_ksettings = sc92031_ethtool_get_link_ksettings,
.set_link_ksettings = sc92031_ethtool_set_link_ksettings,
}; };