Commit 2fb93a1a authored by Philippe Reynes's avatar Philippe Reynes Committed by David S. Miller

net: micrel: ksz884x: 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: default avatarPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2095093
...@@ -5944,7 +5944,7 @@ static u16 eeprom_data[EEPROM_SIZE] = { 0 }; ...@@ -5944,7 +5944,7 @@ static u16 eeprom_data[EEPROM_SIZE] = { 0 };
/* These functions use the MII functions in mii.c. */ /* These functions use the MII functions in mii.c. */
/** /**
* netdev_get_settings - get network device settings * netdev_get_link_ksettings - get network device settings
* @dev: Network device. * @dev: Network device.
* @cmd: Ethtool command. * @cmd: Ethtool command.
* *
...@@ -5952,23 +5952,26 @@ static u16 eeprom_data[EEPROM_SIZE] = { 0 }; ...@@ -5952,23 +5952,26 @@ static u16 eeprom_data[EEPROM_SIZE] = { 0 };
* *
* Return 0 if successful; otherwise an error code. * Return 0 if successful; otherwise an error code.
*/ */
static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int netdev_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ {
struct dev_priv *priv = netdev_priv(dev); struct dev_priv *priv = netdev_priv(dev);
struct dev_info *hw_priv = priv->adapter; struct dev_info *hw_priv = priv->adapter;
mutex_lock(&hw_priv->lock); mutex_lock(&hw_priv->lock);
mii_ethtool_gset(&priv->mii_if, cmd); mii_ethtool_get_link_ksettings(&priv->mii_if, cmd);
cmd->advertising |= SUPPORTED_TP; ethtool_link_ksettings_add_link_mode(cmd, advertising, TP);
mutex_unlock(&hw_priv->lock); mutex_unlock(&hw_priv->lock);
/* Save advertised settings for workaround in next function. */ /* Save advertised settings for workaround in next function. */
priv->advertising = cmd->advertising; ethtool_convert_link_mode_to_legacy_u32(&priv->advertising,
cmd->link_modes.advertising);
return 0; return 0;
} }
/** /**
* netdev_set_settings - set network device settings * netdev_set_link_ksettings - set network device settings
* @dev: Network device. * @dev: Network device.
* @cmd: Ethtool command. * @cmd: Ethtool command.
* *
...@@ -5976,54 +5979,65 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -5976,54 +5979,65 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
* *
* Return 0 if successful; otherwise an error code. * Return 0 if successful; otherwise an error code.
*/ */
static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int netdev_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ {
struct dev_priv *priv = netdev_priv(dev); struct dev_priv *priv = netdev_priv(dev);
struct dev_info *hw_priv = priv->adapter; struct dev_info *hw_priv = priv->adapter;
struct ksz_port *port = &priv->port; struct ksz_port *port = &priv->port;
u32 speed = ethtool_cmd_speed(cmd); struct ethtool_link_ksettings copy_cmd;
u32 speed = cmd->base.speed;
u32 advertising;
int rc; int rc;
ethtool_convert_link_mode_to_legacy_u32(&advertising,
cmd->link_modes.advertising);
/* /*
* ethtool utility does not change advertised setting if auto * ethtool utility does not change advertised setting if auto
* negotiation is not specified explicitly. * negotiation is not specified explicitly.
*/ */
if (cmd->autoneg && priv->advertising == cmd->advertising) { if (cmd->base.autoneg && priv->advertising == advertising) {
cmd->advertising |= ADVERTISED_ALL; advertising |= ADVERTISED_ALL;
if (10 == speed) if (10 == speed)
cmd->advertising &= advertising &=
~(ADVERTISED_100baseT_Full | ~(ADVERTISED_100baseT_Full |
ADVERTISED_100baseT_Half); ADVERTISED_100baseT_Half);
else if (100 == speed) else if (100 == speed)
cmd->advertising &= advertising &=
~(ADVERTISED_10baseT_Full | ~(ADVERTISED_10baseT_Full |
ADVERTISED_10baseT_Half); ADVERTISED_10baseT_Half);
if (0 == cmd->duplex) if (0 == cmd->base.duplex)
cmd->advertising &= advertising &=
~(ADVERTISED_100baseT_Full | ~(ADVERTISED_100baseT_Full |
ADVERTISED_10baseT_Full); ADVERTISED_10baseT_Full);
else if (1 == cmd->duplex) else if (1 == cmd->base.duplex)
cmd->advertising &= advertising &=
~(ADVERTISED_100baseT_Half | ~(ADVERTISED_100baseT_Half |
ADVERTISED_10baseT_Half); ADVERTISED_10baseT_Half);
} }
mutex_lock(&hw_priv->lock); mutex_lock(&hw_priv->lock);
if (cmd->autoneg && if (cmd->base.autoneg &&
(cmd->advertising & ADVERTISED_ALL) == (advertising & ADVERTISED_ALL) == ADVERTISED_ALL) {
ADVERTISED_ALL) {
port->duplex = 0; port->duplex = 0;
port->speed = 0; port->speed = 0;
port->force_link = 0; port->force_link = 0;
} else { } else {
port->duplex = cmd->duplex + 1; port->duplex = cmd->base.duplex + 1;
if (1000 != speed) if (1000 != speed)
port->speed = speed; port->speed = speed;
if (cmd->autoneg) if (cmd->base.autoneg)
port->force_link = 0; port->force_link = 0;
else else
port->force_link = 1; port->force_link = 1;
} }
rc = mii_ethtool_sset(&priv->mii_if, cmd);
memcpy(&copy_cmd, cmd, sizeof(copy_cmd));
ethtool_convert_legacy_u32_to_link_mode(copy_cmd.link_modes.advertising,
advertising);
rc = mii_ethtool_set_link_ksettings(
&priv->mii_if,
(const struct ethtool_link_ksettings *)&copy_cmd);
mutex_unlock(&hw_priv->lock); mutex_unlock(&hw_priv->lock);
return rc; return rc;
} }
...@@ -6597,8 +6611,6 @@ static int netdev_set_features(struct net_device *dev, ...@@ -6597,8 +6611,6 @@ static int netdev_set_features(struct net_device *dev,
} }
static const struct ethtool_ops netdev_ethtool_ops = { static const struct ethtool_ops netdev_ethtool_ops = {
.get_settings = netdev_get_settings,
.set_settings = netdev_set_settings,
.nway_reset = netdev_nway_reset, .nway_reset = netdev_nway_reset,
.get_link = netdev_get_link, .get_link = netdev_get_link,
.get_drvinfo = netdev_get_drvinfo, .get_drvinfo = netdev_get_drvinfo,
...@@ -6617,6 +6629,8 @@ static const struct ethtool_ops netdev_ethtool_ops = { ...@@ -6617,6 +6629,8 @@ static const struct ethtool_ops netdev_ethtool_ops = {
.get_strings = netdev_get_strings, .get_strings = netdev_get_strings,
.get_sset_count = netdev_get_sset_count, .get_sset_count = netdev_get_sset_count,
.get_ethtool_stats = netdev_get_ethtool_stats, .get_ethtool_stats = netdev_get_ethtool_stats,
.get_link_ksettings = netdev_get_link_ksettings,
.set_link_ksettings = netdev_set_link_ksettings,
}; };
/* /*
......
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