Skip to content

Commit 8103015

Browse files
Philippe Reynesdavem330
authored andcommitted
net: sun: sunhme: 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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9dff2de commit 8103015

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

drivers/net/ethernet/sun/sunhme.c

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,10 @@ static void happy_meal_init_rings(struct happy_meal *hp)
12941294
}
12951295

12961296
/* hp->happy_lock must be held */
1297-
static void happy_meal_begin_auto_negotiation(struct happy_meal *hp,
1298-
void __iomem *tregs,
1299-
struct ethtool_cmd *ep)
1297+
static void
1298+
happy_meal_begin_auto_negotiation(struct happy_meal *hp,
1299+
void __iomem *tregs,
1300+
const struct ethtool_link_ksettings *ep)
13001301
{
13011302
int timeout;
13021303

@@ -1309,7 +1310,7 @@ static void happy_meal_begin_auto_negotiation(struct happy_meal *hp,
13091310
/* XXX Check BMSR_ANEGCAPABLE, should not be necessary though. */
13101311

13111312
hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE);
1312-
if (ep == NULL || ep->autoneg == AUTONEG_ENABLE) {
1313+
if (!ep || ep->base.autoneg == AUTONEG_ENABLE) {
13131314
/* Advertise everything we can support. */
13141315
if (hp->sw_bmsr & BMSR_10HALF)
13151316
hp->sw_advertise |= (ADVERTISE_10HALF);
@@ -1384,14 +1385,14 @@ static void happy_meal_begin_auto_negotiation(struct happy_meal *hp,
13841385
/* Disable auto-negotiation in BMCR, enable the duplex and
13851386
* speed setting, init the timer state machine, and fire it off.
13861387
*/
1387-
if (ep == NULL || ep->autoneg == AUTONEG_ENABLE) {
1388+
if (!ep || ep->base.autoneg == AUTONEG_ENABLE) {
13881389
hp->sw_bmcr = BMCR_SPEED100;
13891390
} else {
1390-
if (ethtool_cmd_speed(ep) == SPEED_100)
1391+
if (ep->base.speed == SPEED_100)
13911392
hp->sw_bmcr = BMCR_SPEED100;
13921393
else
13931394
hp->sw_bmcr = 0;
1394-
if (ep->duplex == DUPLEX_FULL)
1395+
if (ep->base.duplex == DUPLEX_FULL)
13951396
hp->sw_bmcr |= BMCR_FULLDPLX;
13961397
}
13971398
happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr);
@@ -2434,20 +2435,21 @@ static void happy_meal_set_multicast(struct net_device *dev)
24342435
}
24352436

24362437
/* Ethtool support... */
2437-
static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2438+
static int hme_get_link_ksettings(struct net_device *dev,
2439+
struct ethtool_link_ksettings *cmd)
24382440
{
24392441
struct happy_meal *hp = netdev_priv(dev);
24402442
u32 speed;
2443+
u32 supported;
24412444

2442-
cmd->supported =
2445+
supported =
24432446
(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
24442447
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
24452448
SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII);
24462449

24472450
/* XXX hardcoded stuff for now */
2448-
cmd->port = PORT_TP; /* XXX no MII support */
2449-
cmd->transceiver = XCVR_INTERNAL; /* XXX no external xcvr support */
2450-
cmd->phy_address = 0; /* XXX fixed PHYAD */
2451+
cmd->base.port = PORT_TP; /* XXX no MII support */
2452+
cmd->base.phy_address = 0; /* XXX fixed PHYAD */
24512453

24522454
/* Record PHY settings. */
24532455
spin_lock_irq(&hp->happy_lock);
@@ -2456,41 +2458,45 @@ static int hme_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
24562458
spin_unlock_irq(&hp->happy_lock);
24572459

24582460
if (hp->sw_bmcr & BMCR_ANENABLE) {
2459-
cmd->autoneg = AUTONEG_ENABLE;
2461+
cmd->base.autoneg = AUTONEG_ENABLE;
24602462
speed = ((hp->sw_lpa & (LPA_100HALF | LPA_100FULL)) ?
24612463
SPEED_100 : SPEED_10);
24622464
if (speed == SPEED_100)
2463-
cmd->duplex =
2465+
cmd->base.duplex =
24642466
(hp->sw_lpa & (LPA_100FULL)) ?
24652467
DUPLEX_FULL : DUPLEX_HALF;
24662468
else
2467-
cmd->duplex =
2469+
cmd->base.duplex =
24682470
(hp->sw_lpa & (LPA_10FULL)) ?
24692471
DUPLEX_FULL : DUPLEX_HALF;
24702472
} else {
2471-
cmd->autoneg = AUTONEG_DISABLE;
2473+
cmd->base.autoneg = AUTONEG_DISABLE;
24722474
speed = (hp->sw_bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
2473-
cmd->duplex =
2475+
cmd->base.duplex =
24742476
(hp->sw_bmcr & BMCR_FULLDPLX) ?
24752477
DUPLEX_FULL : DUPLEX_HALF;
24762478
}
2477-
ethtool_cmd_speed_set(cmd, speed);
2479+
cmd->base.speed = speed;
2480+
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
2481+
supported);
2482+
24782483
return 0;
24792484
}
24802485

2481-
static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2486+
static int hme_set_link_ksettings(struct net_device *dev,
2487+
const struct ethtool_link_ksettings *cmd)
24822488
{
24832489
struct happy_meal *hp = netdev_priv(dev);
24842490

24852491
/* Verify the settings we care about. */
2486-
if (cmd->autoneg != AUTONEG_ENABLE &&
2487-
cmd->autoneg != AUTONEG_DISABLE)
2492+
if (cmd->base.autoneg != AUTONEG_ENABLE &&
2493+
cmd->base.autoneg != AUTONEG_DISABLE)
24882494
return -EINVAL;
2489-
if (cmd->autoneg == AUTONEG_DISABLE &&
2490-
((ethtool_cmd_speed(cmd) != SPEED_100 &&
2491-
ethtool_cmd_speed(cmd) != SPEED_10) ||
2492-
(cmd->duplex != DUPLEX_HALF &&
2493-
cmd->duplex != DUPLEX_FULL)))
2495+
if (cmd->base.autoneg == AUTONEG_DISABLE &&
2496+
((cmd->base.speed != SPEED_100 &&
2497+
cmd->base.speed != SPEED_10) ||
2498+
(cmd->base.duplex != DUPLEX_HALF &&
2499+
cmd->base.duplex != DUPLEX_FULL)))
24942500
return -EINVAL;
24952501

24962502
/* Ok, do it to it. */
@@ -2537,10 +2543,10 @@ static u32 hme_get_link(struct net_device *dev)
25372543
}
25382544

25392545
static const struct ethtool_ops hme_ethtool_ops = {
2540-
.get_settings = hme_get_settings,
2541-
.set_settings = hme_set_settings,
25422546
.get_drvinfo = hme_get_drvinfo,
25432547
.get_link = hme_get_link,
2548+
.get_link_ksettings = hme_get_link_ksettings,
2549+
.set_link_ksettings = hme_set_link_ksettings,
25442550
};
25452551

25462552
static int hme_version_printed;

0 commit comments

Comments
 (0)