ethtool: Use full 32 bit speed range in ethtool's set_settings
authorDavid Decotigny <decot@google.com>
Wed, 27 Apr 2011 18:32:39 +0000 (18:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Apr 2011 21:03:00 +0000 (14:03 -0700)
This makes sure the ethtool's set_settings() callback of network
drivers don't ignore the 16 most significant bits when ethtool calls
their set_settings().

All drivers compiled with make allyesconfig on x86_64 have been
updated.

Signed-off-by: David Decotigny <decot@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
44 files changed:
drivers/net/acenic.c
drivers/net/atl1c/atl1c_ethtool.c
drivers/net/atlx/atl1.c
drivers/net/b44.c
drivers/net/bna/bnad_ethtool.c
drivers/net/bnx2.c
drivers/net/cassini.c
drivers/net/chelsio/cxgb2.c
drivers/net/cxgb3/cxgb3_main.c
drivers/net/cxgb4/cxgb4_main.c
drivers/net/dl2k.c
drivers/net/e100.c
drivers/net/e1000/e1000_ethtool.c
drivers/net/e1000e/ethtool.c
drivers/net/enc28j60.c
drivers/net/forcedeth.c
drivers/net/igb/igb_ethtool.c
drivers/net/ixgb/ixgb_ethtool.c
drivers/net/ixgbe/ixgbe_ethtool.c
drivers/net/jme.c
drivers/net/ksz884x.c
drivers/net/mii.c
drivers/net/mlx4/en_ethtool.c
drivers/net/natsemi.c
drivers/net/netxen/netxen_nic_ethtool.c
drivers/net/niu.c
drivers/net/pch_gbe/pch_gbe_ethtool.c
drivers/net/pcmcia/smc91c92_cs.c
drivers/net/phy/phy.c
drivers/net/r8169.c
drivers/net/s2io.c
drivers/net/sc92031.c
drivers/net/sfc/ethtool.c
drivers/net/sfc/mcdi_phy.c
drivers/net/skge.c
drivers/net/sky2.c
drivers/net/sungem.c
drivers/net/sunhme.c
drivers/net/tg3.c
drivers/net/tulip/de2104x.c
drivers/net/typhoon.c
drivers/net/via-velocity.c
drivers/net/vxge/vxge-ethtool.c
net/bridge/br_if.c

index ee648fe5d96fc48b65c59c1a2965aea7902cbf63..0b4d8d13c488026a6a4b660f6fdb54670e9580f0 100644 (file)
@@ -2718,7 +2718,7 @@ static int ace_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                link |= LNK_TX_FLOW_CTL_Y;
        if (ecmd->autoneg == AUTONEG_ENABLE)
                link |= LNK_NEGOTIATE;
-       if (ecmd->speed != speed) {
+       if (ethtool_cmd_speed(ecmd) != speed) {
                link &= ~(LNK_1000MB | LNK_100MB | LNK_10MB);
                switch (speed) {
                case SPEED_1000:
index 3af5a336a5afd40c60b07935b559c18b7f065248..b1eceee424aa601c040c2b0ac8414575a20e8b3e 100644 (file)
@@ -77,7 +77,8 @@ static int atl1c_set_settings(struct net_device *netdev,
        if (ecmd->autoneg == AUTONEG_ENABLE) {
                autoneg_advertised = ADVERTISED_Autoneg;
        } else {
-               if (ecmd->speed == SPEED_1000) {
+               u32 speed = ethtool_cmd_speed(ecmd);
+               if (speed == SPEED_1000) {
                        if (ecmd->duplex != DUPLEX_FULL) {
                                if (netif_msg_link(adapter))
                                        dev_warn(&adapter->pdev->dev,
@@ -86,7 +87,7 @@ static int atl1c_set_settings(struct net_device *netdev,
                                return -EINVAL;
                        }
                        autoneg_advertised = ADVERTISED_1000baseT_Full;
-               } else if (ecmd->speed == SPEED_100) {
+               } else if (speed == SPEED_100) {
                        if (ecmd->duplex == DUPLEX_FULL)
                                autoneg_advertised = ADVERTISED_100baseT_Full;
                        else
index dffa6919a4198a93520901d07938832eaadafd97..37a092fa2ba64868368349469d54bdd28af6a255 100644 (file)
@@ -3268,7 +3268,8 @@ static int atl1_set_settings(struct net_device *netdev,
        if (ecmd->autoneg == AUTONEG_ENABLE)
                hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
        else {
-               if (ecmd->speed == SPEED_1000) {
+               u32 speed = ethtool_cmd_speed(ecmd);
+               if (speed == SPEED_1000) {
                        if (ecmd->duplex != DUPLEX_FULL) {
                                if (netif_msg_link(adapter))
                                        dev_warn(&adapter->pdev->dev,
@@ -3277,7 +3278,7 @@ static int atl1_set_settings(struct net_device *netdev,
                                goto exit_sset;
                        }
                        hw->media_type = MEDIA_TYPE_1000M_FULL;
-               } else if (ecmd->speed == SPEED_100) {
+               } else if (speed == SPEED_100) {
                        if (ecmd->duplex == DUPLEX_FULL)
                                hw->media_type = MEDIA_TYPE_100M_FULL;
                        else
index 2e2b76258ab42cbc6b0dc73f70bd9547a5846857..909cc4b2a2f38befe2b42bc2a0ae1cc71f1aa028 100644 (file)
@@ -1831,6 +1831,7 @@ static int b44_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct b44 *bp = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(cmd);
 
        /* We do not support gigabit. */
        if (cmd->autoneg == AUTONEG_ENABLE) {
@@ -1838,8 +1839,8 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                    (ADVERTISED_1000baseT_Half |
                     ADVERTISED_1000baseT_Full))
                        return -EINVAL;
-       } else if ((cmd->speed != SPEED_100 &&
-                   cmd->speed != SPEED_10) ||
+       } else if ((speed != SPEED_100 &&
+                   speed != SPEED_10) ||
                   (cmd->duplex != DUPLEX_HALF &&
                    cmd->duplex != DUPLEX_FULL)) {
                        return -EINVAL;
@@ -1873,7 +1874,7 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        } else {
                bp->flags |= B44_FLAG_FORCE_LINK;
                bp->flags &= ~(B44_FLAG_100_BASE_T | B44_FLAG_FULL_DUPLEX);
-               if (cmd->speed == SPEED_100)
+               if (speed == SPEED_100)
                        bp->flags |= B44_FLAG_100_BASE_T;
                if (cmd->duplex == DUPLEX_FULL)
                        bp->flags |= B44_FLAG_FULL_DUPLEX;
index c51e078e8f0de3716791231a5a7f626091a72001..ae1e118f9c3a52ab457c45ee50eedd22cef3d2f2 100644 (file)
@@ -256,7 +256,8 @@ bnad_set_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
        /* 10G full duplex setting supported only */
        if (cmd->autoneg == AUTONEG_ENABLE)
                return -EOPNOTSUPP; else {
-               if ((cmd->speed == SPEED_10000) && (cmd->duplex == DUPLEX_FULL))
+               if ((ethtool_cmd_speed(cmd) == SPEED_10000)
+                   && (cmd->duplex == DUPLEX_FULL))
                        return 0;
        }
 
index bf729ee6acbdc7fc227668eaba2af71214e091c0..e43efd86425b3b2e48628855e8e1e2bce543ed1c 100644 (file)
@@ -6758,21 +6758,21 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                advertising |= ADVERTISED_Autoneg;
        }
        else {
+               u32 speed = ethtool_cmd_speed(cmd);
                if (cmd->port == PORT_FIBRE) {
-                       if ((cmd->speed != SPEED_1000 &&
-                            cmd->speed != SPEED_2500) ||
+                       if ((speed != SPEED_1000 &&
+                            speed != SPEED_2500) ||
                            (cmd->duplex != DUPLEX_FULL))
                                goto err_out_unlock;
 
-                       if (cmd->speed == SPEED_2500 &&
+                       if (speed == SPEED_2500 &&
                            !(bp->phy_flags & BNX2_PHY_FLAG_2_5G_CAPABLE))
                                goto err_out_unlock;
-               }
-               else if (cmd->speed == SPEED_1000 || cmd->speed == SPEED_2500)
+               } else if (speed == SPEED_1000 || speed == SPEED_2500)
                        goto err_out_unlock;
 
                autoneg &= ~AUTONEG_SPEED;
-               req_line_speed = cmd->speed;
+               req_line_speed = speed;
                req_duplex = cmd->duplex;
                advertising = 0;
        }
index 143a28c666af3ef1157f0a7779e50abad936a903..a6c3f8c8c302017f603de5b0fdbb8bbbfbac8de1 100644 (file)
@@ -709,10 +709,11 @@ static void cas_begin_auto_negotiation(struct cas *cp, struct ethtool_cmd *ep)
        if (ep->autoneg == AUTONEG_ENABLE)
                cp->link_cntl = BMCR_ANENABLE;
        else {
+               u32 speed = ethtool_cmd_speed(ep);
                cp->link_cntl = 0;
-               if (ep->speed == SPEED_100)
+               if (speed == SPEED_100)
                        cp->link_cntl |= BMCR_SPEED100;
-               else if (ep->speed == SPEED_1000)
+               else if (speed == SPEED_1000)
                        cp->link_cntl |= CAS_BMCR_SPEED1000;
                if (ep->duplex == DUPLEX_FULL)
                        cp->link_cntl |= BMCR_FULLDPLX;
@@ -4653,6 +4654,7 @@ static int cas_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct cas *cp = netdev_priv(dev);
        unsigned long flags;
+       u32 speed = ethtool_cmd_speed(cmd);
 
        /* Verify the settings we care about. */
        if (cmd->autoneg != AUTONEG_ENABLE &&
@@ -4660,9 +4662,9 @@ static int cas_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                return -EINVAL;
 
        if (cmd->autoneg == AUTONEG_DISABLE &&
-           ((cmd->speed != SPEED_1000 &&
-             cmd->speed != SPEED_100 &&
-             cmd->speed != SPEED_10) ||
+           ((speed != SPEED_1000 &&
+             speed != SPEED_100 &&
+             speed != SPEED_10) ||
             (cmd->duplex != DUPLEX_HALF &&
              cmd->duplex != DUPLEX_FULL)))
                return -EINVAL;
index 5f82c9c349780aaee490c0b6028f7fd112aa3534..8e14d652996b3d5639f8ce37d1e3d2cffc7d8dde 100644 (file)
@@ -638,11 +638,12 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                return -EOPNOTSUPP;             /* can't change speed/duplex */
 
        if (cmd->autoneg == AUTONEG_DISABLE) {
-               int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
+               u32 speed = ethtool_cmd_speed(cmd);
+               int cap = speed_duplex_to_caps(speed, cmd->duplex);
 
-               if (!(lc->supported & cap) || cmd->speed == SPEED_1000)
+               if (!(lc->supported & cap) || (speed == SPEED_1000))
                        return -EINVAL;
-               lc->requested_speed = cmd->speed;
+               lc->requested_speed = speed;
                lc->requested_duplex = cmd->duplex;
                lc->advertising = 0;
        } else {
index 040491804efbc330f6fc7714c770088dd1b1dbce..0526715cc8c7debbec325947875269560cf0ac4d 100644 (file)
@@ -1821,7 +1821,8 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                 * being requested.
                 */
                if (cmd->autoneg == AUTONEG_DISABLE) {
-                       int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
+                       u32 speed = ethtool_cmd_speed(cmd);
+                       int cap = speed_duplex_to_caps(speed, cmd->duplex);
                        if (lc->supported & cap)
                                return 0;
                }
@@ -1829,11 +1830,12 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        }
 
        if (cmd->autoneg == AUTONEG_DISABLE) {
-               int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
+               u32 speed = ethtool_cmd_speed(cmd);
+               int cap = speed_duplex_to_caps(speed, cmd->duplex);
 
-               if (!(lc->supported & cap) || cmd->speed == SPEED_1000)
+               if (!(lc->supported & cap) || (speed == SPEED_1000))
                        return -EINVAL;
-               lc->requested_speed = cmd->speed;
+               lc->requested_speed = speed;
                lc->requested_duplex = cmd->duplex;
                lc->advertising = 0;
        } else {
index bdc868ca47ec4624a33b1a3f8ab6d3e3cdc3005c..c02b4d3b73fceedb3f0841b3f2dfa2c3b7747a45 100644 (file)
@@ -1460,6 +1460,7 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        unsigned int cap;
        struct port_info *p = netdev_priv(dev);
        struct link_config *lc = &p->link_cfg;
+       u32 speed = ethtool_cmd_speed(cmd);
 
        if (cmd->duplex != DUPLEX_FULL)     /* only full-duplex supported */
                return -EINVAL;
@@ -1470,16 +1471,16 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                 * being requested.
                 */
                if (cmd->autoneg == AUTONEG_DISABLE &&
-                   (lc->supported & speed_to_caps(cmd->speed)))
-                               return 0;
+                   (lc->supported & speed_to_caps(speed)))
+                       return 0;
                return -EINVAL;
        }
 
        if (cmd->autoneg == AUTONEG_DISABLE) {
-               cap = speed_to_caps(cmd->speed);
+               cap = speed_to_caps(speed);
 
-               if (!(lc->supported & cap) || cmd->speed == SPEED_1000 ||
-                   cmd->speed == SPEED_10000)
+               if (!(lc->supported & cap) || (speed == SPEED_1000) ||
+                   (speed == SPEED_10000))
                        return -EINVAL;
                lc->requested_speed = cap;
                lc->advertising = 0;
index c05db6046050981360c7789859a12b953bafe20c..ab63989619d43d20782689e56f396d0102cc7bf6 100644 (file)
@@ -1219,31 +1219,20 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        } else {
                np->an_enable = 0;
                if (np->speed == 1000) {
-                       cmd->speed = SPEED_100;
+                       ethtool_cmd_speed_set(cmd, SPEED_100);
                        cmd->duplex = DUPLEX_FULL;
                        printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n");
                }
-               switch(cmd->speed + cmd->duplex) {
-
-               case SPEED_10 + DUPLEX_HALF:
-                       np->speed = 10;
-                       np->full_duplex = 0;
-                       break;
-
-               case SPEED_10 + DUPLEX_FULL:
+               switch (ethtool_cmd_speed(cmd)) {
+               case SPEED_10:
                        np->speed = 10;
-                       np->full_duplex = 1;
+                       np->full_duplex = (cmd->duplex == DUPLEX_FULL);
                        break;
-               case SPEED_100 + DUPLEX_HALF:
+               case SPEED_100:
                        np->speed = 100;
-                       np->full_duplex = 0;
-                       break;
-               case SPEED_100 + DUPLEX_FULL:
-                       np->speed = 100;
-                       np->full_duplex = 1;
+                       np->full_duplex = (cmd->duplex == DUPLEX_FULL);
                        break;
-               case SPEED_1000 + DUPLEX_HALF:/* not supported */
-               case SPEED_1000 + DUPLEX_FULL:/* not supported */
+               case SPEED_1000: /* not supported */
                default:
                        return -EINVAL;
                }
index 66ba596a4d3791c061520722322ae23c4624bd52..c810cda3bf1ff91c63f640809699d8ffe9dbee4f 100644 (file)
@@ -1669,6 +1669,7 @@ static void e100_watchdog(unsigned long data)
 {
        struct nic *nic = (struct nic *)data;
        struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
+       u32 speed;
 
        netif_printk(nic, timer, KERN_DEBUG, nic->netdev,
                     "right now = %ld\n", jiffies);
@@ -1676,10 +1677,11 @@ static void e100_watchdog(unsigned long data)
        /* mii library handles link maintenance tasks */
 
        mii_ethtool_gset(&nic->mii, &cmd);
+       speed = ethtool_cmd_speed(&cmd);
 
        if (mii_link_ok(&nic->mii) && !netif_carrier_ok(nic->netdev)) {
                netdev_info(nic->netdev, "NIC Link is Up %u Mbps %s Duplex\n",
-                           cmd.speed == SPEED_100 ? 100 : 10,
+                           speed == SPEED_100 ? 100 : 10,
                            cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
        } else if (!mii_link_ok(&nic->mii) && netif_carrier_ok(nic->netdev)) {
                netdev_info(nic->netdev, "NIC Link is Down\n");
@@ -1698,13 +1700,13 @@ static void e100_watchdog(unsigned long data)
        spin_unlock_irq(&nic->cmd_lock);
 
        e100_update_stats(nic);
-       e100_adjust_adaptive_ifs(nic, cmd.speed, cmd.duplex);
+       e100_adjust_adaptive_ifs(nic, speed, cmd.duplex);
 
        if (nic->mac <= mac_82557_D100_C)
                /* Issue a multicast command to workaround a 557 lock up */
                e100_set_multicast_list(nic->netdev);
 
-       if (nic->flags & ich && cmd.speed==SPEED_10 && cmd.duplex==DUPLEX_HALF)
+       if (nic->flags & ich && speed == SPEED_10 && cmd.duplex == DUPLEX_HALF)
                /* Need SW workaround for ICH[x] 10Mbps/half duplex Tx hang. */
                nic->flags |= ich_10h_workaround;
        else
index dd70738eb2f48cb245b3d843ccdde1151b902feb..a53629d9325d1e08543b505170a3f83138f16306 100644 (file)
@@ -197,11 +197,13 @@ static int e1000_set_settings(struct net_device *netdev,
                                                 ADVERTISED_TP |
                                                 ADVERTISED_Autoneg;
                ecmd->advertising = hw->autoneg_advertised;
-       } else
-               if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
+       } else {
+               u32 speed = ethtool_cmd_speed(ecmd);
+               if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) {
                        clear_bit(__E1000_RESETTING, &adapter->flags);
                        return -EINVAL;
                }
+       }
 
        /* reset the link */
 
index 1d7bf4049c02213166414c50d093f2841601c11b..bc02c6b91f15e8e47e5a0daa0589f2e248b7a05e 100644 (file)
@@ -269,7 +269,8 @@ static int e1000_set_settings(struct net_device *netdev,
                if (adapter->fc_autoneg)
                        hw->fc.requested_mode = e1000_fc_default;
        } else {
-               if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
+               u32 speed = ethtool_cmd_speed(ecmd);
+               if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) {
                        clear_bit(__E1000_RESETTING, &adapter->state);
                        return -EINVAL;
                }
index 907b05a1c65955c22b02dfe742729d95792a0f12..81a793747f2e88c9163fd86f5c47034956100122 100644 (file)
@@ -1499,7 +1499,8 @@ enc28j60_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 static int
 enc28j60_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       return enc28j60_setlink(dev, cmd->autoneg, cmd->speed, cmd->duplex);
+       return enc28j60_setlink(dev, cmd->autoneg,
+                               ethtool_cmd_speed(cmd), cmd->duplex);
 }
 
 static u32 enc28j60_get_msglevel(struct net_device *dev)
index 0e1c76a8c045dd5deebd24c153557b59c3111eb9..d24b3f3e646bcaec37c0930edf9abd4f4f1615f4 100644 (file)
@@ -4029,6 +4029,7 @@ static int nv_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
        struct fe_priv *np = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(ecmd);
 
        if (ecmd->port != PORT_MII)
                return -EINVAL;
@@ -4054,7 +4055,7 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                /* Note: autonegotiation disable, speed 1000 intentionally
                 * forbidden - no one should need that. */
 
-               if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100)
+               if (speed != SPEED_10 && speed != SPEED_100)
                        return -EINVAL;
                if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
                        return -EINVAL;
@@ -4138,13 +4139,13 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 
                adv = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ);
                adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
-               if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF)
+               if (speed == SPEED_10 && ecmd->duplex == DUPLEX_HALF)
                        adv |= ADVERTISE_10HALF;
-               if (ecmd->speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL)
+               if (speed == SPEED_10 && ecmd->duplex == DUPLEX_FULL)
                        adv |= ADVERTISE_10FULL;
-               if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_HALF)
+               if (speed == SPEED_100 && ecmd->duplex == DUPLEX_HALF)
                        adv |= ADVERTISE_100HALF;
-               if (ecmd->speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL)
+               if (speed == SPEED_100 && ecmd->duplex == DUPLEX_FULL)
                        adv |= ADVERTISE_100FULL;
                np->pause_flags &= ~(NV_PAUSEFRAME_AUTONEG|NV_PAUSEFRAME_RX_ENABLE|NV_PAUSEFRAME_TX_ENABLE);
                if (np->pause_flags & NV_PAUSEFRAME_RX_REQ) {/* for rx we set both advertisements but disable tx pause */
index d976733bbcc2de9cbf527fe56c421c18f22172c6..2cc221b65cd4850b83d4fd256ca6afa90fc1a868 100644 (file)
@@ -223,7 +223,8 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
                if (adapter->fc_autoneg)
                        hw->fc.requested_mode = e1000_fc_default;
        } else {
-               if (igb_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
+               u32 speed = ethtool_cmd_speed(ecmd);
+               if (igb_set_spd_dplx(adapter, speed + ecmd->duplex)) {
                        clear_bit(__IGB_RESETTING, &adapter->state);
                        return -EINVAL;
                }
index cc53aa1541badb915ed45ea74029332c141006ed..edb3d7eaf6d521dd2d2bdd55efc0c1e5eaee802b 100644 (file)
@@ -129,9 +129,10 @@ static int
 ixgb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 {
        struct ixgb_adapter *adapter = netdev_priv(netdev);
+       u32 speed = ethtool_cmd_speed(ecmd);
 
        if (ecmd->autoneg == AUTONEG_ENABLE ||
-          ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL)
+           (speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL))
                return -EINVAL;
 
        if (netif_running(adapter->netdev)) {
index 7279345b1ed7258a289d6591a1a34dfcfe23c512..c52243d67edcea84c896cdaa11331a1e04d4bc59 100644 (file)
@@ -346,9 +346,10 @@ static int ixgbe_set_settings(struct net_device *netdev,
                }
        } else {
                /* in this case we currently only support 10Gb/FULL */
+               u32 speed = ethtool_cmd_speed(ecmd);
                if ((ecmd->autoneg == AUTONEG_ENABLE) ||
                    (ecmd->advertising != ADVERTISED_10000baseT_Full) ||
-                   (ecmd->speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL))
+                   (speed + ecmd->duplex != SPEED_10000 + DUPLEX_FULL))
                        return -EINVAL;
        }
 
index be4773f54a244073fee58a55861419d1fb0911cb..b5b174a8c149be9f07e56d8b9f07524ea3505792 100644 (file)
@@ -2555,7 +2555,8 @@ jme_set_settings(struct net_device *netdev,
        struct jme_adapter *jme = netdev_priv(netdev);
        int rc, fdc = 0;
 
-       if (ecmd->speed == SPEED_1000 && ecmd->autoneg != AUTONEG_ENABLE)
+       if (ethtool_cmd_speed(ecmd) == SPEED_1000
+           && ecmd->autoneg != AUTONEG_ENABLE)
                return -EINVAL;
 
        /*
index 2c37a38043032a311a49bd4f1d31d24911c7deaf..41ea5920c158d37ef1c54580ae95326145ddb8dc 100644 (file)
@@ -5998,6 +5998,7 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        struct dev_priv *priv = netdev_priv(dev);
        struct dev_info *hw_priv = priv->adapter;
        struct ksz_port *port = &priv->port;
+       u32 speed = ethtool_cmd_speed(cmd);
        int rc;
 
        /*
@@ -6006,11 +6007,11 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
         */
        if (cmd->autoneg && priv->advertising == cmd->advertising) {
                cmd->advertising |= ADVERTISED_ALL;
-               if (10 == cmd->speed)
+               if (10 == speed)
                        cmd->advertising &=
                                ~(ADVERTISED_100baseT_Full |
                                ADVERTISED_100baseT_Half);
-               else if (100 == cmd->speed)
+               else if (100 == speed)
                        cmd->advertising &=
                                ~(ADVERTISED_10baseT_Full |
                                ADVERTISED_10baseT_Half);
@@ -6032,8 +6033,8 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                port->force_link = 0;
        } else {
                port->duplex = cmd->duplex + 1;
-               if (cmd->speed != 1000)
-                       port->speed = cmd->speed;
+               if (1000 != speed)
+                       port->speed = speed;
                if (cmd->autoneg)
                        port->force_link = 0;
                else
index 05acca78f63a9a6ce294c49a902a65485b7aed71..e8198edeaa761712aa7840ea290c19a9e8b5613c 100644 (file)
@@ -157,10 +157,11 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 {
        struct net_device *dev = mii->dev;
+       u32 speed = ethtool_cmd_speed(ecmd);
 
-       if (ecmd->speed != SPEED_10 &&
-           ecmd->speed != SPEED_100 &&
-           ecmd->speed != SPEED_1000)
+       if (speed != SPEED_10 &&
+           speed != SPEED_100 &&
+           speed != SPEED_1000)
                return -EINVAL;
        if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
                return -EINVAL;
@@ -172,7 +173,7 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
                return -EINVAL;
        if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE)
                return -EINVAL;
-       if ((ecmd->speed == SPEED_1000) && (!mii->supports_gmii))
+       if ((speed == SPEED_1000) && (!mii->supports_gmii))
                return -EINVAL;
 
        /* ignore supported, maxtxpkt, maxrxpkt */
@@ -230,9 +231,9 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
                bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
                tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 |
                               BMCR_SPEED1000 | BMCR_FULLDPLX);
-               if (ecmd->speed == SPEED_1000)
+               if (speed == SPEED_1000)
                        tmp |= BMCR_SPEED1000;
-               else if (ecmd->speed == SPEED_100)
+               else if (speed == SPEED_100)
                        tmp |= BMCR_SPEED100;
                if (ecmd->duplex == DUPLEX_FULL) {
                        tmp |= BMCR_FULLDPLX;
index da1b64d6860797db679330c2f392028b38eb8ce7..be4a9e0b2406cfe1e39e2992664ad070184af016 100644 (file)
@@ -292,7 +292,8 @@ static int mlx4_en_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 static int mlx4_en_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        if ((cmd->autoneg == AUTONEG_ENABLE) ||
-           (cmd->speed != SPEED_10000) || (cmd->duplex != DUPLEX_FULL))
+           (ethtool_cmd_speed(cmd) != SPEED_10000) ||
+           (cmd->duplex != DUPLEX_FULL))
                return -EINVAL;
 
        /* Nothing to change */
index 1074231f0a0d722a803bcc968372d9705b582a53..7633c67b7842fa8cc2f70d802287436dd931995b 100644 (file)
@@ -2908,7 +2908,8 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
                        return -EINVAL;
                }
        } else if (ecmd->autoneg == AUTONEG_DISABLE) {
-               if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100)
+               u32 speed = ethtool_cmd_speed(ecmd);
+               if (speed != SPEED_10 && speed != SPEED_100)
                        return -EINVAL;
                if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
                        return -EINVAL;
@@ -2956,7 +2957,7 @@ static int netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
                if (ecmd->advertising & ADVERTISED_100baseT_Full)
                        np->advertising |= ADVERTISE_100FULL;
        } else {
-               np->speed  = ecmd->speed;
+               np->speed  = ethtool_cmd_speed(ecmd);
                np->duplex = ecmd->duplex;
                /* user overriding the initial full duplex parm? */
                if (np->duplex == DUPLEX_HALF)
index 29f90baaa79b830b33d6c265cb9314e96e4a7546..e8d16f6f11e3d8a4370acd28c8ed85783325501f 100644 (file)
@@ -251,6 +251,7 @@ static int
 netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
        struct netxen_adapter *adapter = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(ecmd);
        int ret;
 
        if (adapter->ahw.port_type != NETXEN_NIC_GBE)
@@ -259,14 +260,14 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
        if (!(adapter->capabilities & NX_FW_CAPABILITY_GBE_LINK_CFG))
                return -EOPNOTSUPP;
 
-       ret = nx_fw_cmd_set_gbe_port(adapter, ecmd->speed, ecmd->duplex,
+       ret = nx_fw_cmd_set_gbe_port(adapter, speed, ecmd->duplex,
                                     ecmd->autoneg);
        if (ret == NX_RCODE_NOT_SUPPORTED)
                return -EOPNOTSUPP;
        else if (ret)
                return -EIO;
 
-       adapter->link_speed = ecmd->speed;
+       adapter->link_speed = speed;
        adapter->link_duplex = ecmd->duplex;
        adapter->link_autoneg = ecmd->autoneg;
 
index a7072174ffa700ce73b1a485bc1743a93bd0f6c2..524e800ddcf468f078189d6a5136372ecb801ed8 100644 (file)
@@ -6859,7 +6859,7 @@ static int niu_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        struct niu_link_config *lp = &np->link_config;
 
        lp->advertising = cmd->advertising;
-       lp->speed = cmd->speed;
+       lp->speed = ethtool_cmd_speed(cmd);
        lp->duplex = cmd->duplex;
        lp->autoneg = cmd->autoneg;
        return niu_init_link(np);
index c35d105ab28585b246c4dcd7c6e42014473bb1fd..ea2d8e41887a67a679d52a8d7f6e6962d1c42644 100644 (file)
@@ -92,7 +92,7 @@ static int pch_gbe_get_settings(struct net_device *netdev,
        ecmd->advertising &= ~(ADVERTISED_TP | ADVERTISED_1000baseT_Half);
 
        if (!netif_carrier_ok(adapter->netdev))
-               ecmd->speed = -1;
+               ethtool_cmd_speed_set(ecmd, -1);
        return ret;
 }
 
@@ -109,12 +109,15 @@ static int pch_gbe_set_settings(struct net_device *netdev,
 {
        struct pch_gbe_adapter *adapter = netdev_priv(netdev);
        struct pch_gbe_hw *hw = &adapter->hw;
+       u32 speed = ethtool_cmd_speed(ecmd);
        int ret;
 
        pch_gbe_hal_write_phy_reg(hw, MII_BMCR, BMCR_RESET);
 
-       if (ecmd->speed == USHRT_MAX) {
-               ecmd->speed = SPEED_1000;
+       /* when set_settings() is called with a ethtool_cmd previously
+        * filled by get_settings() on a down link, speed is -1: */
+       if (speed == UINT_MAX) {
+               speed = SPEED_1000;
                ecmd->duplex = DUPLEX_FULL;
        }
        ret = mii_ethtool_sset(&adapter->mii, ecmd);
@@ -122,7 +125,7 @@ static int pch_gbe_set_settings(struct net_device *netdev,
                pr_err("Error: mii_ethtool_sset\n");
                return ret;
        }
-       hw->mac.link_speed = ecmd->speed;
+       hw->mac.link_speed = speed;
        hw->mac.link_duplex = ecmd->duplex;
        hw->phy.autoneg_advertised = ecmd->advertising;
        hw->mac.autoneg = ecmd->autoneg;
index 1085917564400c587795e744c6cf8ef36ce34cc5..bc71cb260ff4d5cbec771c68c824322b537c0faf 100644 (file)
@@ -1875,8 +1875,8 @@ static int smc_netdev_set_ecmd(struct net_device *dev, struct ethtool_cmd *ecmd)
     u16 tmp;
     unsigned int ioaddr = dev->base_addr;
 
-    if (ecmd->speed != SPEED_10)
-       return -EINVAL;
+    if (ethtool_cmd_speed(ecmd) != SPEED_10)
+       return -EINVAL;
     if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
        return -EINVAL;
     if (ecmd->port != PORT_TP && ecmd->port != PORT_AUI)
index f7670330f98829e021c994376fb49b145fc74ef0..e3f3501d4347d26e7d2f3521a12fc3527779da74 100644 (file)
@@ -238,6 +238,8 @@ static void phy_sanitize_settings(struct phy_device *phydev)
  */
 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
 {
+       u32 speed = ethtool_cmd_speed(cmd);
+
        if (cmd->phy_address != phydev->addr)
                return -EINVAL;
 
@@ -253,16 +255,16 @@ int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
                return -EINVAL;
 
        if (cmd->autoneg == AUTONEG_DISABLE &&
-           ((cmd->speed != SPEED_1000 &&
-             cmd->speed != SPEED_100 &&
-             cmd->speed != SPEED_10) ||
+           ((speed != SPEED_1000 &&
+             speed != SPEED_100 &&
+             speed != SPEED_10) ||
             (cmd->duplex != DUPLEX_HALF &&
              cmd->duplex != DUPLEX_FULL)))
                return -EINVAL;
 
        phydev->autoneg = cmd->autoneg;
 
-       phydev->speed = cmd->speed;
+       phydev->speed = speed;
 
        phydev->advertising = cmd->advertising;
 
index 6364e0b03fddd8b8a23504e94c3a4e24d83f1cc1..b52ee17de74d30259ad19c2e7e77f7bbd468eaf7 100644 (file)
@@ -1349,7 +1349,8 @@ static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
        spin_lock_irqsave(&tp->lock, flags);
        ret = rtl8169_set_speed(dev,
-               cmd->autoneg, cmd->speed, cmd->duplex, cmd->advertising);
+                               cmd->autoneg, ethtool_cmd_speed(cmd),
+                               cmd->duplex, cmd->advertising);
        spin_unlock_irqrestore(&tp->lock, flags);
 
        return ret;
index 58b78f46e54f73d2369d4e28dea27286fc340b30..5443985c019e514651dea6ffaf94fdea552eaf1e 100644 (file)
@@ -5380,7 +5380,7 @@ static int s2io_ethtool_sset(struct net_device *dev,
 {
        struct s2io_nic *sp = netdev_priv(dev);
        if ((info->autoneg == AUTONEG_ENABLE) ||
-           (info->speed != SPEED_10000) ||
+           (ethtool_cmd_speed(info) != SPEED_10000) ||
            (info->duplex != DUPLEX_FULL))
                return -EINVAL;
        else {
index 76290a8c3c146f8eec24bd8e93cf201469c1082a..f3ffc1df3b2decde6905c716111f69d1997f7475 100644 (file)
@@ -1188,10 +1188,11 @@ static int sc92031_ethtool_set_settings(struct net_device *dev,
 {
        struct sc92031_priv *priv = netdev_priv(dev);
        void __iomem *port_base = priv->port_base;
+       u32 speed = ethtool_cmd_speed(cmd);
        u32 phy_ctrl;
        u32 old_phy_ctrl;
 
-       if (!(cmd->speed == SPEED_10 || cmd->speed == SPEED_100))
+       if (!(speed == SPEED_10 || speed == SPEED_100))
                return -EINVAL;
        if (!(cmd->duplex == DUPLEX_HALF || cmd->duplex == DUPLEX_FULL))
                return -EINVAL;
@@ -1229,7 +1230,7 @@ static int sc92031_ethtool_set_settings(struct net_device *dev,
                // FIXME: Whole branch guessed
                phy_ctrl = 0;
 
-               if (cmd->speed == SPEED_10)
+               if (speed == SPEED_10)
                        phy_ctrl |= PhyCtrlSpd10;
                else /* cmd->speed == SPEED_100 */
                        phy_ctrl |= PhyCtrlSpd100;
index 5d8468fc58042c2434e480160f346ce5e61986bd..10b160a508f375de37ba0791bac37c586c7ea0be 100644 (file)
@@ -234,7 +234,8 @@ static int efx_ethtool_set_settings(struct net_device *net_dev,
        int rc;
 
        /* GMAC does not support 1000Mbps HD */
-       if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) {
+       if ((ethtool_cmd_speed(ecmd) == SPEED_1000) &&
+           (ecmd->duplex != DUPLEX_FULL)) {
                netif_dbg(efx, drv, efx->net_dev,
                          "rejecting unsupported 1000Mbps HD setting\n");
                return -EINVAL;
index 1fcda2d82399ebfeb45345565018719451207c19..6c5fccbdeca20b224d4152fcd0b59d612016924e 100644 (file)
@@ -545,7 +545,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
                caps = (ethtool_to_mcdi_cap(ecmd->advertising) |
                         1 << MC_CMD_PHY_CAP_AN_LBN);
        } else if (ecmd->duplex) {
-               switch (ecmd->speed) {
+               switch (ethtool_cmd_speed(ecmd)) {
                case 10:    caps = 1 << MC_CMD_PHY_CAP_10FDX_LBN;    break;
                case 100:   caps = 1 << MC_CMD_PHY_CAP_100FDX_LBN;   break;
                case 1000:  caps = 1 << MC_CMD_PHY_CAP_1000FDX_LBN;  break;
@@ -553,7 +553,7 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
                default:    return -EINVAL;
                }
        } else {
-               switch (ecmd->speed) {
+               switch (ethtool_cmd_speed(ecmd)) {
                case 10:    caps = 1 << MC_CMD_PHY_CAP_10HDX_LBN;    break;
                case 100:   caps = 1 << MC_CMD_PHY_CAP_100HDX_LBN;   break;
                case 1000:  caps = 1 << MC_CMD_PHY_CAP_1000HDX_LBN;  break;
index 176d784cbb542bdf5a64d3dad1f9195cf3c07659..a05e864de6744ff9872e1266eab85c8924b7a9ec 100644 (file)
@@ -321,8 +321,9 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                skge->speed = -1;
        } else {
                u32 setting;
+               u32 speed = ethtool_cmd_speed(ecmd);
 
-               switch (ecmd->speed) {
+               switch (speed) {
                case SPEED_1000:
                        if (ecmd->duplex == DUPLEX_FULL)
                                setting = SUPPORTED_1000baseT_Full;
@@ -355,7 +356,7 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                if ((setting & supported) == 0)
                        return -EINVAL;
 
-               skge->speed = ecmd->speed;
+               skge->speed = speed;
                skge->duplex = ecmd->duplex;
        }
 
index c8d045114c66902abbea9054503d816aad6229f2..5c7e2d68df2a952450ea55ff82ea6cf087973338 100644 (file)
@@ -3452,8 +3452,9 @@ static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                sky2->speed = -1;
        } else {
                u32 setting;
+               u32 speed = ethtool_cmd_speed(ecmd);
 
-               switch (ecmd->speed) {
+               switch (speed) {
                case SPEED_1000:
                        if (ecmd->duplex == DUPLEX_FULL)
                                setting = SUPPORTED_1000baseT_Full;
@@ -3486,7 +3487,7 @@ static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
                if ((setting & supported) == 0)
                        return -EINVAL;
 
-               sky2->speed = ecmd->speed;
+               sky2->speed = speed;
                sky2->duplex = ecmd->duplex;
                sky2->flags &= ~SKY2_FLAG_AUTO_SPEED;
        }
index 81b6eb8ed4d701751945988ac8a2e3eef006219f..40a755dd1a26d86e5a13c69e13b52d38d5d1bdf5 100644 (file)
@@ -1294,7 +1294,7 @@ static void gem_begin_auto_negotiation(struct gem *gp, struct ethtool_cmd *ep)
                autoneg = 1;
        } else {
                autoneg = 0;
-               speed = ep->speed;
+               speed = ethtool_cmd_speed(ep);
                duplex = ep->duplex;
        }
 
@@ -2686,6 +2686,7 @@ static int gem_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct gem *gp = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(cmd);
 
        /* Verify the settings we care about. */
        if (cmd->autoneg != AUTONEG_ENABLE &&
@@ -2697,9 +2698,9 @@ static int gem_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                return -EINVAL;
 
        if (cmd->autoneg == AUTONEG_DISABLE &&
-           ((cmd->speed != SPEED_1000 &&
-             cmd->speed != SPEED_100 &&
-             cmd->speed != SPEED_10) ||
+           ((speed != SPEED_1000 &&
+             speed != SPEED_100 &&
+             speed != SPEED_10) ||
             (cmd->duplex != DUPLEX_HALF &&
              cmd->duplex != DUPLEX_FULL)))
                return -EINVAL;
index 80e907df36b449c2346b5e3813a4985c31b2a279..8f3f02802427b8d58110745eb3163235e30cce30 100644 (file)
@@ -1383,7 +1383,7 @@ force_link:
                if (ep == NULL || ep->autoneg == AUTONEG_ENABLE) {
                        hp->sw_bmcr = BMCR_SPEED100;
                } else {
-                       if (ep->speed == SPEED_100)
+                       if (ethtool_cmd_speed(ep) == SPEED_100)
                                hp->sw_bmcr = BMCR_SPEED100;
                        else
                                hp->sw_bmcr = 0;
@@ -2452,8 +2452,8 @@ static int hme_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
            cmd->autoneg != AUTONEG_DISABLE)
                return -EINVAL;
        if (cmd->autoneg == AUTONEG_DISABLE &&
-           ((cmd->speed != SPEED_100 &&
-             cmd->speed != SPEED_10) ||
+           ((ethtool_cmd_speed(cmd) != SPEED_100 &&
+             ethtool_cmd_speed(cmd) != SPEED_10) ||
             (cmd->duplex != DUPLEX_HALF &&
              cmd->duplex != DUPLEX_FULL)))
                return -EINVAL;
index fa57e3d699deef083e5b036b0f99682c46e25fd1..004f266e4352555ae968f5e9ec3f1d978648dabb 100644 (file)
@@ -10042,6 +10042,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct tg3 *tp = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(cmd);
 
        if (tg3_flag(tp, USE_PHYLIB)) {
                struct phy_device *phydev;
@@ -10091,14 +10092,14 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                cmd->advertising &= mask;
        } else {
                if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES) {
-                       if (cmd->speed != SPEED_1000)
+                       if (speed != SPEED_1000)
                                return -EINVAL;
 
                        if (cmd->duplex != DUPLEX_FULL)
                                return -EINVAL;
                } else {
-                       if (cmd->speed != SPEED_100 &&
-                           cmd->speed != SPEED_10)
+                       if (speed != SPEED_100 &&
+                           speed != SPEED_10)
                                return -EINVAL;
                }
        }
@@ -10113,7 +10114,7 @@ static int tg3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                tp->link_config.duplex = DUPLEX_INVALID;
        } else {
                tp->link_config.advertising = 0;
-               tp->link_config.speed = cmd->speed;
+               tp->link_config.speed = speed;
                tp->link_config.duplex = cmd->duplex;
        }
 
index b13c6b040be3687c5852e6534f16119c10a1f089..f8d26bf9b2c4666a8e22682a5f18b2a462a155c2 100644 (file)
@@ -1549,10 +1549,11 @@ static int __de_set_settings(struct de_private *de, struct ethtool_cmd *ecmd)
 {
        u32 new_media;
        unsigned int media_lock;
+       u32 speed = ethtool_cmd_speed(ecmd);
 
-       if (ecmd->speed != SPEED_10 && ecmd->speed != 5 && ecmd->speed != 2)
+       if (speed != SPEED_10 && speed != 5 && speed != 2)
                return -EINVAL;
-       if (de->de21040 && ecmd->speed == 2)
+       if (de->de21040 && speed == 2)
                return -EINVAL;
        if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
                return -EINVAL;
index 119c394f71cea1328a0523853e7aec5883512d13..9f11c111b65dcf08bcd75dde34c8d732cf6a5e2b 100644 (file)
@@ -1068,25 +1068,26 @@ static int
 typhoon_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct typhoon *tp = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(cmd);
        struct cmd_desc xp_cmd;
        __le16 xcvr;
        int err;
 
        err = -EINVAL;
-       if(cmd->autoneg == AUTONEG_ENABLE) {
+       if (cmd->autoneg == AUTONEG_ENABLE) {
                xcvr = TYPHOON_XCVR_AUTONEG;
        } else {
-               if(cmd->duplex == DUPLEX_HALF) {
-                       if(cmd->speed == SPEED_10)
+               if (cmd->duplex == DUPLEX_HALF) {
+                       if (speed == SPEED_10)
                                xcvr = TYPHOON_XCVR_10HALF;
-                       else if(cmd->speed == SPEED_100)
+                       else if (speed == SPEED_100)
                                xcvr = TYPHOON_XCVR_100HALF;
                        else
                                goto out;
-               } else if(cmd->duplex == DUPLEX_FULL) {
-                       if(cmd->speed == SPEED_10)
+               } else if (cmd->duplex == DUPLEX_FULL) {
+                       if (speed == SPEED_10)
                                xcvr = TYPHOON_XCVR_10FULL;
-                       else if(cmd->speed == SPEED_100)
+                       else if (speed == SPEED_100)
                                xcvr = TYPHOON_XCVR_100FULL;
                        else
                                goto out;
@@ -1105,7 +1106,7 @@ typhoon_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                tp->speed = 0xff;       /* invalid */
                tp->duplex = 0xff;      /* invalid */
        } else {
-               tp->speed = cmd->speed;
+               tp->speed = speed;
                tp->duplex = cmd->duplex;
        }
 
index baf04b0a65759ca884ba99082a61b7a91d05af0b..9a8f116e6920137c573509ee472313488ca83bf0 100644 (file)
@@ -3247,9 +3247,11 @@ static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd
        return 0;
 }
 
-static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int velocity_set_settings(struct net_device *dev,
+                                struct ethtool_cmd *cmd)
 {
        struct velocity_info *vptr = netdev_priv(dev);
+       u32 speed = ethtool_cmd_speed(cmd);
        u32 curr_status;
        u32 new_status = 0;
        int ret = 0;
@@ -3258,9 +3260,9 @@ static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd
        curr_status &= (~VELOCITY_LINK_FAIL);
 
        new_status |= ((cmd->autoneg) ? VELOCITY_AUTONEG_ENABLE : 0);
-       new_status |= ((cmd->speed == SPEED_1000) ? VELOCITY_SPEED_1000 : 0);
-       new_status |= ((cmd->speed == SPEED_100) ? VELOCITY_SPEED_100 : 0);
-       new_status |= ((cmd->speed == SPEED_10) ? VELOCITY_SPEED_10 : 0);
+       new_status |= ((speed == SPEED_1000) ? VELOCITY_SPEED_1000 : 0);
+       new_status |= ((speed == SPEED_100) ? VELOCITY_SPEED_100 : 0);
+       new_status |= ((speed == SPEED_10) ? VELOCITY_SPEED_10 : 0);
        new_status |= ((cmd->duplex == DUPLEX_FULL) ? VELOCITY_DUPLEX_FULL : 0);
 
        if ((new_status & VELOCITY_AUTONEG_ENABLE) &&
index 5aef6c893aeef7d7d0891b30a318bd331e30d91f..a70874e64d0e03f84dcfec29dac2c1392309e431 100644 (file)
@@ -33,7 +33,8 @@ static int vxge_ethtool_sset(struct net_device *dev, struct ethtool_cmd *info)
 {
        /* We currently only support 10Gb/FULL */
        if ((info->autoneg == AUTONEG_ENABLE) ||
-           (info->speed != SPEED_10000) || (info->duplex != DUPLEX_FULL))
+           (ethtool_cmd_speed(info) != SPEED_10000) ||
+           (info->duplex != DUPLEX_FULL))
                return -EINVAL;
 
        return 0;
index 1156460773dc1dd059c572f881c32bc55bf97d0f..5dbdfdfc3a34a13f02815e574da427d88d228526 100644 (file)
@@ -36,8 +36,8 @@ static int port_cost(struct net_device *dev)
        if (dev->ethtool_ops && dev->ethtool_ops->get_settings) {
                struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET, };
 
-               if (!dev->ethtool_ops->get_settings(dev, &ecmd)) {
-                       switch(ecmd.speed) {
+               if (!dev_ethtool_get_settings(dev, &ecmd)) {
+                       switch (ethtool_cmd_speed(&ecmd)) {
                        case SPEED_10000:
                                return 2;
                        case SPEED_1000: