net: 3c509: 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.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Philippe Reynes 2016-11-01 16:32:27 +01:00 committed by David S. Miller
parent e19b7883ef
commit b646cf299e
1 changed files with 29 additions and 26 deletions

View File

@ -1040,67 +1040,68 @@ el3_link_ok(struct net_device *dev)
} }
static int static int
el3_netdev_get_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) el3_netdev_get_ecmd(struct net_device *dev, struct ethtool_link_ksettings *cmd)
{ {
u16 tmp; u16 tmp;
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
u32 supported;
EL3WINDOW(0); EL3WINDOW(0);
/* obtain current transceiver via WN4_MEDIA? */ /* obtain current transceiver via WN4_MEDIA? */
tmp = inw(ioaddr + WN0_ADDR_CONF); tmp = inw(ioaddr + WN0_ADDR_CONF);
ecmd->transceiver = XCVR_INTERNAL;
switch (tmp >> 14) { switch (tmp >> 14) {
case 0: case 0:
ecmd->port = PORT_TP; cmd->base.port = PORT_TP;
break; break;
case 1: case 1:
ecmd->port = PORT_AUI; cmd->base.port = PORT_AUI;
ecmd->transceiver = XCVR_EXTERNAL;
break; break;
case 3: case 3:
ecmd->port = PORT_BNC; cmd->base.port = PORT_BNC;
default: default:
break; break;
} }
ecmd->duplex = DUPLEX_HALF; cmd->base.duplex = DUPLEX_HALF;
ecmd->supported = 0; supported = 0;
tmp = inw(ioaddr + WN0_CONF_CTRL); tmp = inw(ioaddr + WN0_CONF_CTRL);
if (tmp & (1<<13)) if (tmp & (1<<13))
ecmd->supported |= SUPPORTED_AUI; supported |= SUPPORTED_AUI;
if (tmp & (1<<12)) if (tmp & (1<<12))
ecmd->supported |= SUPPORTED_BNC; supported |= SUPPORTED_BNC;
if (tmp & (1<<9)) { if (tmp & (1<<9)) {
ecmd->supported |= SUPPORTED_TP | SUPPORTED_10baseT_Half | supported |= SUPPORTED_TP | SUPPORTED_10baseT_Half |
SUPPORTED_10baseT_Full; /* hmm... */ SUPPORTED_10baseT_Full; /* hmm... */
EL3WINDOW(4); EL3WINDOW(4);
tmp = inw(ioaddr + WN4_NETDIAG); tmp = inw(ioaddr + WN4_NETDIAG);
if (tmp & FD_ENABLE) if (tmp & FD_ENABLE)
ecmd->duplex = DUPLEX_FULL; cmd->base.duplex = DUPLEX_FULL;
} }
ethtool_cmd_speed_set(ecmd, SPEED_10); ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
cmd->base.speed = SPEED_10;
EL3WINDOW(1); EL3WINDOW(1);
return 0; return 0;
} }
static int static int
el3_netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd) el3_netdev_set_ecmd(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ {
u16 tmp; u16 tmp;
int ioaddr = dev->base_addr; int ioaddr = dev->base_addr;
if (ecmd->speed != SPEED_10) if (cmd->base.speed != SPEED_10)
return -EINVAL; return -EINVAL;
if ((ecmd->duplex != DUPLEX_HALF) && (ecmd->duplex != DUPLEX_FULL)) if ((cmd->base.duplex != DUPLEX_HALF) &&
return -EINVAL; (cmd->base.duplex != DUPLEX_FULL))
if ((ecmd->transceiver != XCVR_INTERNAL) && (ecmd->transceiver != XCVR_EXTERNAL))
return -EINVAL; return -EINVAL;
/* change XCVR type */ /* change XCVR type */
EL3WINDOW(0); EL3WINDOW(0);
tmp = inw(ioaddr + WN0_ADDR_CONF); tmp = inw(ioaddr + WN0_ADDR_CONF);
switch (ecmd->port) { switch (cmd->base.port) {
case PORT_TP: case PORT_TP:
tmp &= ~(3<<14); tmp &= ~(3<<14);
dev->if_port = 0; dev->if_port = 0;
@ -1130,7 +1131,7 @@ el3_netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
EL3WINDOW(4); EL3WINDOW(4);
tmp = inw(ioaddr + WN4_NETDIAG); tmp = inw(ioaddr + WN4_NETDIAG);
if (ecmd->duplex == DUPLEX_FULL) if (cmd->base.duplex == DUPLEX_FULL)
tmp |= FD_ENABLE; tmp |= FD_ENABLE;
else else
tmp &= ~FD_ENABLE; tmp &= ~FD_ENABLE;
@ -1146,24 +1147,26 @@ static void el3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
strlcpy(info->version, DRV_VERSION, sizeof(info->version)); strlcpy(info->version, DRV_VERSION, sizeof(info->version));
} }
static int el3_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) static int el3_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ {
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
int ret; int ret;
spin_lock_irq(&lp->lock); spin_lock_irq(&lp->lock);
ret = el3_netdev_get_ecmd(dev, ecmd); ret = el3_netdev_get_ecmd(dev, cmd);
spin_unlock_irq(&lp->lock); spin_unlock_irq(&lp->lock);
return ret; return ret;
} }
static int el3_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) static int el3_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ {
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
int ret; int ret;
spin_lock_irq(&lp->lock); spin_lock_irq(&lp->lock);
ret = el3_netdev_set_ecmd(dev, ecmd); ret = el3_netdev_set_ecmd(dev, cmd);
spin_unlock_irq(&lp->lock); spin_unlock_irq(&lp->lock);
return ret; return ret;
} }
@ -1191,11 +1194,11 @@ static void el3_set_msglevel(struct net_device *dev, u32 v)
static const struct ethtool_ops ethtool_ops = { static const struct ethtool_ops ethtool_ops = {
.get_drvinfo = el3_get_drvinfo, .get_drvinfo = el3_get_drvinfo,
.get_settings = el3_get_settings,
.set_settings = el3_set_settings,
.get_link = el3_get_link, .get_link = el3_get_link,
.get_msglevel = el3_get_msglevel, .get_msglevel = el3_get_msglevel,
.set_msglevel = el3_set_msglevel, .set_msglevel = el3_set_msglevel,
.get_link_ksettings = el3_get_link_ksettings,
.set_link_ksettings = el3_set_link_ksettings,
}; };
static void static void