extern void e1000_down(struct e1000_adapter *adapter);
 extern void e1000_reinit_locked(struct e1000_adapter *adapter);
 extern void e1000_reset(struct e1000_adapter *adapter);
-extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
+extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx);
 extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
 extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
 extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
 
                ecmd->advertising = hw->autoneg_advertised;
        } else {
                u32 speed = ethtool_cmd_speed(ecmd);
-               if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) {
+               if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
                        clear_bit(__E1000_RESETTING, &adapter->flags);
                        return -EINVAL;
                }
 
 void e1000_down(struct e1000_adapter *adapter);
 void e1000_reinit_locked(struct e1000_adapter *adapter);
 void e1000_reset(struct e1000_adapter *adapter);
-int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
 int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
 int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
 void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
        struct mii_ioctl_data *data = if_mii(ifr);
        int retval;
        u16 mii_reg;
-       u16 spddplx;
        unsigned long flags;
 
        if (hw->media_type != e1000_media_type_copper)
                                        hw->autoneg = 1;
                                        hw->autoneg_advertised = 0x2F;
                                } else {
+                                       u32 speed;
                                        if (mii_reg & 0x40)
-                                               spddplx = SPEED_1000;
+                                               speed = SPEED_1000;
                                        else if (mii_reg & 0x2000)
-                                               spddplx = SPEED_100;
+                                               speed = SPEED_100;
                                        else
-                                               spddplx = SPEED_10;
-                                       spddplx += (mii_reg & 0x100)
-                                                  ? DUPLEX_FULL :
-                                                  DUPLEX_HALF;
-                                       retval = e1000_set_spd_dplx(adapter,
-                                                                   spddplx);
+                                               speed = SPEED_10;
+                                       retval = e1000_set_spd_dplx(
+                                               adapter, speed,
+                                               ((mii_reg & 0x100)
+                                                ? DUPLEX_FULL :
+                                                DUPLEX_HALF));
                                        if (retval)
                                                return retval;
                                }
        }
 }
 
-int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
+int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
 {
        struct e1000_hw *hw = &adapter->hw;
 
        hw->autoneg = 0;
 
+       /* Make sure dplx is at most 1 bit and lsb of speed is not set
+        * for the switch() below to work */
+       if ((spd & 1) || (dplx & ~1))
+               goto err_inval;
+
        /* Fiber NICs only allow 1000 gbps Full duplex */
        if ((hw->media_type == e1000_media_type_fiber) &&
-               spddplx != (SPEED_1000 + DUPLEX_FULL)) {
-               e_err(probe, "Unsupported Speed/Duplex configuration\n");
-               return -EINVAL;
-       }
+           spd != SPEED_1000 &&
+           dplx != DUPLEX_FULL)
+               goto err_inval;
 
-       switch (spddplx) {
+       switch (spd + dplx) {
        case SPEED_10 + DUPLEX_HALF:
                hw->forced_speed_duplex = e1000_10_half;
                break;
                break;
        case SPEED_1000 + DUPLEX_HALF: /* not supported */
        default:
-               e_err(probe, "Unsupported Speed/Duplex configuration\n");
-               return -EINVAL;
+               goto err_inval;
        }
        return 0;
+
+err_inval:
+       e_err(probe, "Unsupported Speed/Duplex configuration\n");
+       return -EINVAL;
 }
 
 static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
 
        return 0;
 }
 
-static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
+static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
 {
        struct e1000_mac_info *mac = &adapter->hw.mac;
 
        mac->autoneg = 0;
 
+       /* Make sure dplx is at most 1 bit and lsb of speed is not set
+        * for the switch() below to work */
+       if ((spd & 1) || (dplx & ~1))
+               goto err_inval;
+
        /* Fiber NICs only allow 1000 gbps Full duplex */
        if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
-               spddplx != (SPEED_1000 + DUPLEX_FULL)) {
-               e_err("Unsupported Speed/Duplex configuration\n");
-               return -EINVAL;
+           spd != SPEED_1000 &&
+           dplx != DUPLEX_FULL) {
+               goto err_inval;
        }
 
-       switch (spddplx) {
+       switch (spd + dplx) {
        case SPEED_10 + DUPLEX_HALF:
                mac->forced_speed_duplex = ADVERTISE_10_HALF;
                break;
                break;
        case SPEED_1000 + DUPLEX_HALF: /* not supported */
        default:
-               e_err("Unsupported Speed/Duplex configuration\n");
-               return -EINVAL;
+               goto err_inval;
        }
        return 0;
+
+err_inval:
+       e_err("Unsupported Speed/Duplex configuration\n");
+       return -EINVAL;
 }
 
 static int e1000_set_settings(struct net_device *netdev,
                        hw->fc.requested_mode = e1000_fc_default;
        } else {
                u32 speed = ethtool_cmd_speed(ecmd);
-               if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) {
+               if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
                        clear_bit(__E1000_RESETTING, &adapter->state);
                        return -EINVAL;
                }
 
 extern void igb_down(struct igb_adapter *);
 extern void igb_reinit_locked(struct igb_adapter *);
 extern void igb_reset(struct igb_adapter *);
-extern int igb_set_spd_dplx(struct igb_adapter *, u16);
+extern int igb_set_spd_dplx(struct igb_adapter *, u32, u8);
 extern int igb_setup_tx_resources(struct igb_ring *);
 extern int igb_setup_rx_resources(struct igb_ring *);
 extern void igb_free_tx_resources(struct igb_ring *);
 
                        hw->fc.requested_mode = e1000_fc_default;
        } else {
                u32 speed = ethtool_cmd_speed(ecmd);
-               if (igb_set_spd_dplx(adapter, speed + ecmd->duplex)) {
+               if (igb_set_spd_dplx(adapter, speed, ecmd->duplex)) {
                        clear_bit(__IGB_RESETTING, &adapter->state);
                        return -EINVAL;
                }
 
        }
 }
 
-int igb_set_spd_dplx(struct igb_adapter *adapter, u16 spddplx)
+int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx)
 {
        struct pci_dev *pdev = adapter->pdev;
        struct e1000_mac_info *mac = &adapter->hw.mac;
 
        mac->autoneg = 0;
 
+       /* Make sure dplx is at most 1 bit and lsb of speed is not set
+        * for the switch() below to work */
+       if ((spd & 1) || (dplx & ~1))
+               goto err_inval;
+
        /* Fiber NIC's only allow 1000 Gbps Full duplex */
        if ((adapter->hw.phy.media_type == e1000_media_type_internal_serdes) &&
-               spddplx != (SPEED_1000 + DUPLEX_FULL)) {
-               dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n");
-               return -EINVAL;
-       }
+           spd != SPEED_1000 &&
+           dplx != DUPLEX_FULL)
+               goto err_inval;
 
-       switch (spddplx) {
+       switch (spd + dplx) {
        case SPEED_10 + DUPLEX_HALF:
                mac->forced_speed_duplex = ADVERTISE_10_HALF;
                break;
                break;
        case SPEED_1000 + DUPLEX_HALF: /* not supported */
        default:
-               dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n");
-               return -EINVAL;
+               goto err_inval;
        }
        return 0;
+
+err_inval:
+       dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n");
+       return -EINVAL;
 }
 
 static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake)