net: natsemi: ns83820: 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-10 23:57:48 +01:00 committed by David S. Miller
parent 2efbe14303
commit 3b03cc0783

View File

@ -1217,12 +1217,13 @@ static struct net_device_stats *ns83820_get_stats(struct net_device *ndev)
}
/* Let ethtool retrieve info */
static int ns83820_get_settings(struct net_device *ndev,
struct ethtool_cmd *cmd)
static int ns83820_get_link_ksettings(struct net_device *ndev,
struct ethtool_link_ksettings *cmd)
{
struct ns83820 *dev = PRIV(ndev);
u32 cfg, tanar, tbicr;
int fullduplex = 0;
u32 supported;
/*
* Here's the list of available ethtool commands from other drivers:
@ -1244,44 +1245,47 @@ static int ns83820_get_settings(struct net_device *ndev,
fullduplex = (cfg & CFG_DUPSTS) ? 1 : 0;
cmd->supported = SUPPORTED_Autoneg;
supported = SUPPORTED_Autoneg;
if (dev->CFG_cache & CFG_TBI_EN) {
/* we have optical interface */
cmd->supported |= SUPPORTED_1000baseT_Half |
supported |= SUPPORTED_1000baseT_Half |
SUPPORTED_1000baseT_Full |
SUPPORTED_FIBRE;
cmd->port = PORT_FIBRE;
cmd->base.port = PORT_FIBRE;
} else {
/* we have copper */
cmd->supported |= SUPPORTED_10baseT_Half |
supported |= SUPPORTED_10baseT_Half |
SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half |
SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Half |
SUPPORTED_1000baseT_Full |
SUPPORTED_MII;
cmd->port = PORT_MII;
cmd->base.port = PORT_MII;
}
cmd->duplex = fullduplex ? DUPLEX_FULL : DUPLEX_HALF;
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
supported);
cmd->base.duplex = fullduplex ? DUPLEX_FULL : DUPLEX_HALF;
switch (cfg / CFG_SPDSTS0 & 3) {
case 2:
ethtool_cmd_speed_set(cmd, SPEED_1000);
cmd->base.speed = SPEED_1000;
break;
case 1:
ethtool_cmd_speed_set(cmd, SPEED_100);
cmd->base.speed = SPEED_100;
break;
default:
ethtool_cmd_speed_set(cmd, SPEED_10);
cmd->base.speed = SPEED_10;
break;
}
cmd->autoneg = (tbicr & TBICR_MR_AN_ENABLE)
cmd->base.autoneg = (tbicr & TBICR_MR_AN_ENABLE)
? AUTONEG_ENABLE : AUTONEG_DISABLE;
return 0;
}
/* Let ethool change settings*/
static int ns83820_set_settings(struct net_device *ndev,
struct ethtool_cmd *cmd)
static int ns83820_set_link_ksettings(struct net_device *ndev,
const struct ethtool_link_ksettings *cmd)
{
struct ns83820 *dev = PRIV(ndev);
u32 cfg, tanar;
@ -1306,10 +1310,10 @@ static int ns83820_set_settings(struct net_device *ndev,
spin_lock(&dev->tx_lock);
/* Set duplex */
if (cmd->duplex != fullduplex) {
if (cmd->base.duplex != fullduplex) {
if (have_optical) {
/*set full duplex*/
if (cmd->duplex == DUPLEX_FULL) {
if (cmd->base.duplex == DUPLEX_FULL) {
/* force full duplex */
writel(readl(dev->base + TXCFG)
| TXCFG_CSI | TXCFG_HBI | TXCFG_ATP,
@ -1333,7 +1337,7 @@ static int ns83820_set_settings(struct net_device *ndev,
/* Set autonegotiation */
if (1) {
if (cmd->autoneg == AUTONEG_ENABLE) {
if (cmd->base.autoneg == AUTONEG_ENABLE) {
/* restart auto negotiation */
writel(TBICR_MR_AN_ENABLE | TBICR_MR_RESTART_AN,
dev->base + TBICR);
@ -1348,7 +1352,7 @@ static int ns83820_set_settings(struct net_device *ndev,
}
printk(KERN_INFO "%s: autoneg %s via ethtool\n", ndev->name,
cmd->autoneg ? "ENABLED" : "DISABLED");
cmd->base.autoneg ? "ENABLED" : "DISABLED");
}
phy_intr(ndev);
@ -1375,10 +1379,10 @@ static u32 ns83820_get_link(struct net_device *ndev)
}
static const struct ethtool_ops ops = {
.get_settings = ns83820_get_settings,
.set_settings = ns83820_set_settings,
.get_drvinfo = ns83820_get_drvinfo,
.get_link = ns83820_get_link
.get_link = ns83820_get_link,
.get_link_ksettings = ns83820_get_link_ksettings,
.set_link_ksettings = ns83820_set_link_ksettings,
};
static inline void ns83820_disable_interrupts(struct ns83820 *dev)