Skip to content

Commit afa9e26

Browse files
committed
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue
Tony Nguyen says: ==================== intel: use bitfield operations Jesse Brandeburg says: After repeatedly getting review comments on new patches, and sporadic patches to fix parts of our drivers, we should just convert the Intel code to use FIELD_PREP() and FIELD_GET(). It's then "common" in the code and hopefully future change-sets will see the context and do-the-right-thing. This conversion was done with a coccinelle script which is mentioned in the commit messages. Generally there were only a couple conversions that were "undone" after the automatic changes because they tried to convert a non-contiguous mask. Patch 1 is required at the beginning of this series to fix a "forever" issue in the e1000e driver that fails the compilation test after conversion because the shift / mask was out of range. The second patch just adds all the new #includes in one go. The patch titled: "ice: fix pre-shifted bit usage" is needed to allow the use of the FIELD_* macros and fix up the unexpected "shifts included" defines found while creating this series. The rest are the conversion to use FIELD_PREP()/FIELD_GET(), and the occasional leXX_{get,set,encode}_bits() call, as suggested by Alex. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 56794e5 + 6aa7ca3 commit afa9e26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+734
-1016
lines changed

drivers/net/ethernet/intel/e1000/e1000_hw.c

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Shared functions for accessing and configuring the MAC
66
*/
77

8+
#include <linux/bitfield.h>
89
#include "e1000.h"
910

1011
static s32 e1000_check_downshift(struct e1000_hw *hw);
@@ -3260,8 +3261,7 @@ static s32 e1000_phy_igp_get_info(struct e1000_hw *hw,
32603261
return ret_val;
32613262

32623263
phy_info->mdix_mode =
3263-
(e1000_auto_x_mode) ((phy_data & IGP01E1000_PSSR_MDIX) >>
3264-
IGP01E1000_PSSR_MDIX_SHIFT);
3264+
(e1000_auto_x_mode)FIELD_GET(IGP01E1000_PSSR_MDIX, phy_data);
32653265

32663266
if ((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
32673267
IGP01E1000_PSSR_SPEED_1000MBPS) {
@@ -3272,11 +3272,11 @@ static s32 e1000_phy_igp_get_info(struct e1000_hw *hw,
32723272
if (ret_val)
32733273
return ret_val;
32743274

3275-
phy_info->local_rx = ((phy_data & SR_1000T_LOCAL_RX_STATUS) >>
3276-
SR_1000T_LOCAL_RX_STATUS_SHIFT) ?
3275+
phy_info->local_rx = FIELD_GET(SR_1000T_LOCAL_RX_STATUS,
3276+
phy_data) ?
32773277
e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
3278-
phy_info->remote_rx = ((phy_data & SR_1000T_REMOTE_RX_STATUS) >>
3279-
SR_1000T_REMOTE_RX_STATUS_SHIFT) ?
3278+
phy_info->remote_rx = FIELD_GET(SR_1000T_REMOTE_RX_STATUS,
3279+
phy_data) ?
32803280
e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
32813281

32823282
/* Get cable length */
@@ -3326,14 +3326,12 @@ static s32 e1000_phy_m88_get_info(struct e1000_hw *hw,
33263326
return ret_val;
33273327

33283328
phy_info->extended_10bt_distance =
3329-
((phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE) >>
3330-
M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT) ?
3329+
FIELD_GET(M88E1000_PSCR_10BT_EXT_DIST_ENABLE, phy_data) ?
33313330
e1000_10bt_ext_dist_enable_lower :
33323331
e1000_10bt_ext_dist_enable_normal;
33333332

33343333
phy_info->polarity_correction =
3335-
((phy_data & M88E1000_PSCR_POLARITY_REVERSAL) >>
3336-
M88E1000_PSCR_POLARITY_REVERSAL_SHIFT) ?
3334+
FIELD_GET(M88E1000_PSCR_POLARITY_REVERSAL, phy_data) ?
33373335
e1000_polarity_reversal_disabled : e1000_polarity_reversal_enabled;
33383336

33393337
/* Check polarity status */
@@ -3347,27 +3345,25 @@ static s32 e1000_phy_m88_get_info(struct e1000_hw *hw,
33473345
return ret_val;
33483346

33493347
phy_info->mdix_mode =
3350-
(e1000_auto_x_mode) ((phy_data & M88E1000_PSSR_MDIX) >>
3351-
M88E1000_PSSR_MDIX_SHIFT);
3348+
(e1000_auto_x_mode)FIELD_GET(M88E1000_PSSR_MDIX, phy_data);
33523349

33533350
if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {
33543351
/* Cable Length Estimation and Local/Remote Receiver Information
33553352
* are only valid at 1000 Mbps.
33563353
*/
33573354
phy_info->cable_length =
3358-
(e1000_cable_length) ((phy_data &
3359-
M88E1000_PSSR_CABLE_LENGTH) >>
3360-
M88E1000_PSSR_CABLE_LENGTH_SHIFT);
3355+
(e1000_cable_length)FIELD_GET(M88E1000_PSSR_CABLE_LENGTH,
3356+
phy_data);
33613357

33623358
ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
33633359
if (ret_val)
33643360
return ret_val;
33653361

3366-
phy_info->local_rx = ((phy_data & SR_1000T_LOCAL_RX_STATUS) >>
3367-
SR_1000T_LOCAL_RX_STATUS_SHIFT) ?
3362+
phy_info->local_rx = FIELD_GET(SR_1000T_LOCAL_RX_STATUS,
3363+
phy_data) ?
33683364
e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
3369-
phy_info->remote_rx = ((phy_data & SR_1000T_REMOTE_RX_STATUS) >>
3370-
SR_1000T_REMOTE_RX_STATUS_SHIFT) ?
3365+
phy_info->remote_rx = FIELD_GET(SR_1000T_REMOTE_RX_STATUS,
3366+
phy_data) ?
33713367
e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
33723368
}
33733369

@@ -3515,7 +3511,7 @@ s32 e1000_init_eeprom_params(struct e1000_hw *hw)
35153511
if (ret_val)
35163512
return ret_val;
35173513
eeprom_size =
3518-
(eeprom_size & EEPROM_SIZE_MASK) >> EEPROM_SIZE_SHIFT;
3514+
FIELD_GET(EEPROM_SIZE_MASK, eeprom_size);
35193515
/* 256B eeprom size was not supported in earlier hardware, so we
35203516
* bump eeprom_size up one to ensure that "1" (which maps to
35213517
* 256B) is never the result used in the shifting logic below.
@@ -4891,8 +4887,7 @@ static s32 e1000_get_cable_length(struct e1000_hw *hw, u16 *min_length,
48914887
&phy_data);
48924888
if (ret_val)
48934889
return ret_val;
4894-
cable_length = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
4895-
M88E1000_PSSR_CABLE_LENGTH_SHIFT;
4890+
cable_length = FIELD_GET(M88E1000_PSSR_CABLE_LENGTH, phy_data);
48964891

48974892
/* Convert the enum value to ranged values */
48984893
switch (cable_length) {
@@ -5001,8 +4996,7 @@ static s32 e1000_check_polarity(struct e1000_hw *hw,
50014996
&phy_data);
50024997
if (ret_val)
50034998
return ret_val;
5004-
*polarity = ((phy_data & M88E1000_PSSR_REV_POLARITY) >>
5005-
M88E1000_PSSR_REV_POLARITY_SHIFT) ?
4999+
*polarity = FIELD_GET(M88E1000_PSSR_REV_POLARITY, phy_data) ?
50065000
e1000_rev_polarity_reversed : e1000_rev_polarity_normal;
50075001

50085002
} else if (hw->phy_type == e1000_phy_igp) {
@@ -5072,8 +5066,8 @@ static s32 e1000_check_downshift(struct e1000_hw *hw)
50725066
if (ret_val)
50735067
return ret_val;
50745068

5075-
hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >>
5076-
M88E1000_PSSR_DOWNSHIFT_SHIFT;
5069+
hw->speed_downgraded = FIELD_GET(M88E1000_PSSR_DOWNSHIFT,
5070+
phy_data);
50775071
}
50785072

50795073
return E1000_SUCCESS;

drivers/net/ethernet/intel/e1000e/80003es2lan.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
9292

9393
nvm->type = e1000_nvm_eeprom_spi;
9494

95-
size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
96-
E1000_EECD_SIZE_EX_SHIFT);
95+
size = (u16)FIELD_GET(E1000_EECD_SIZE_EX_MASK, eecd);
9796

9897
/* Added to a constant, "size" becomes the left-shift value
9998
* for setting word_size.
@@ -1035,17 +1034,18 @@ static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
10351034
* iteration and increase the max iterations when
10361035
* polling the phy; this fixes erroneous timeouts at 10Mbps.
10371036
*/
1038-
ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
1039-
0xFFFF);
1037+
/* these next three accesses were always meant to use page 0x34 using
1038+
* GG82563_REG(0x34, N) but never did, so we've just corrected the call
1039+
* to not drop bits
1040+
*/
1041+
ret_val = e1000_write_kmrn_reg_80003es2lan(hw, 4, 0xFFFF);
10401042
if (ret_val)
10411043
return ret_val;
1042-
ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1043-
&reg_data);
1044+
ret_val = e1000_read_kmrn_reg_80003es2lan(hw, 9, &reg_data);
10441045
if (ret_val)
10451046
return ret_val;
10461047
reg_data |= 0x3F;
1047-
ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1048-
reg_data);
1048+
ret_val = e1000_write_kmrn_reg_80003es2lan(hw, 9, reg_data);
10491049
if (ret_val)
10501050
return ret_val;
10511051
ret_val =
@@ -1209,8 +1209,8 @@ static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
12091209
if (ret_val)
12101210
return ret_val;
12111211

1212-
kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1213-
E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
1212+
kmrnctrlsta = FIELD_PREP(E1000_KMRNCTRLSTA_OFFSET, offset) |
1213+
E1000_KMRNCTRLSTA_REN;
12141214
ew32(KMRNCTRLSTA, kmrnctrlsta);
12151215
e1e_flush();
12161216

@@ -1244,8 +1244,7 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
12441244
if (ret_val)
12451245
return ret_val;
12461246

1247-
kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1248-
E1000_KMRNCTRLSTA_OFFSET) | data;
1247+
kmrnctrlsta = FIELD_PREP(E1000_KMRNCTRLSTA_OFFSET, offset) | data;
12491248
ew32(KMRNCTRLSTA, kmrnctrlsta);
12501249
e1e_flush();
12511250

drivers/net/ethernet/intel/e1000e/82571.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
157157
fallthrough;
158158
default:
159159
nvm->type = e1000_nvm_eeprom_spi;
160-
size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
161-
E1000_EECD_SIZE_EX_SHIFT);
160+
size = (u16)FIELD_GET(E1000_EECD_SIZE_EX_MASK, eecd);
162161
/* Added to a constant, "size" becomes the left-shift value
163162
* for setting word_size.
164163
*/

drivers/net/ethernet/intel/e1000e/ethtool.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ static void e1000_get_drvinfo(struct net_device *netdev,
654654
*/
655655
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
656656
"%d.%d-%d",
657-
(adapter->eeprom_vers & 0xF000) >> 12,
658-
(adapter->eeprom_vers & 0x0FF0) >> 4,
657+
FIELD_GET(0xF000, adapter->eeprom_vers),
658+
FIELD_GET(0x0FF0, adapter->eeprom_vers),
659659
(adapter->eeprom_vers & 0x000F));
660660

661661
strscpy(drvinfo->bus_info, pci_name(adapter->pdev),
@@ -925,8 +925,7 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
925925
}
926926

927927
if (mac->type >= e1000_pch_lpt)
928-
wlock_mac = (er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK) >>
929-
E1000_FWSM_WLOCK_MAC_SHIFT;
928+
wlock_mac = FIELD_GET(E1000_FWSM_WLOCK_MAC_MASK, er32(FWSM));
930929

931930
for (i = 0; i < mac->rar_entry_count; i++) {
932931
if (mac->type >= e1000_pch_lpt) {

drivers/net/ethernet/intel/e1000e/ich8lan.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,13 +1072,11 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
10721072

10731073
lat_enc_d = (lat_enc & E1000_LTRV_VALUE_MASK) *
10741074
(1U << (E1000_LTRV_SCALE_FACTOR *
1075-
((lat_enc & E1000_LTRV_SCALE_MASK)
1076-
>> E1000_LTRV_SCALE_SHIFT)));
1075+
FIELD_GET(E1000_LTRV_SCALE_MASK, lat_enc)));
10771076

10781077
max_ltr_enc_d = (max_ltr_enc & E1000_LTRV_VALUE_MASK) *
1079-
(1U << (E1000_LTRV_SCALE_FACTOR *
1080-
((max_ltr_enc & E1000_LTRV_SCALE_MASK)
1081-
>> E1000_LTRV_SCALE_SHIFT)));
1078+
(1U << (E1000_LTRV_SCALE_FACTOR *
1079+
FIELD_GET(E1000_LTRV_SCALE_MASK, max_ltr_enc)));
10821080

10831081
if (lat_enc_d > max_ltr_enc_d)
10841082
lat_enc = max_ltr_enc;
@@ -2075,8 +2073,7 @@ static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
20752073
{
20762074
u16 phy_data;
20772075
u32 strap = er32(STRAP);
2078-
u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
2079-
E1000_STRAP_SMT_FREQ_SHIFT;
2076+
u32 freq = FIELD_GET(E1000_STRAP_SMT_FREQ_MASK, strap);
20802077
s32 ret_val;
20812078

20822079
strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
@@ -2562,8 +2559,7 @@ void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
25622559
hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
25632560
(u16)(mac_reg & 0xFFFF));
25642561
hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
2565-
(u16)((mac_reg & E1000_RAH_AV)
2566-
>> 16));
2562+
FIELD_GET(E1000_RAH_AV, mac_reg));
25672563
}
25682564

25692565
e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
@@ -3205,7 +3201,7 @@ static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
32053201
&nvm_dword);
32063202
if (ret_val)
32073203
return ret_val;
3208-
sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3204+
sig_byte = FIELD_GET(0xFF00, nvm_dword);
32093205
if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
32103206
E1000_ICH_NVM_SIG_VALUE) {
32113207
*bank = 0;
@@ -3218,7 +3214,7 @@ static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
32183214
&nvm_dword);
32193215
if (ret_val)
32203216
return ret_val;
3221-
sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
3217+
sig_byte = FIELD_GET(0xFF00, nvm_dword);
32223218
if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
32233219
E1000_ICH_NVM_SIG_VALUE) {
32243220
*bank = 1;

drivers/net/ethernet/intel/e1000e/mac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw)
5050
* for the device regardless of function swap state.
5151
*/
5252
reg = er32(STATUS);
53-
bus->func = (reg & E1000_STATUS_FUNC_MASK) >> E1000_STATUS_FUNC_SHIFT;
53+
bus->func = FIELD_GET(E1000_STATUS_FUNC_MASK, reg);
5454
}
5555

5656
/**

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,8 +1788,7 @@ static irqreturn_t e1000_intr_msi(int __always_unused irq, void *data)
17881788
adapter->corr_errors +=
17891789
pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
17901790
adapter->uncorr_errors +=
1791-
(pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
1792-
E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
1791+
FIELD_GET(E1000_PBECCSTS_UNCORR_ERR_CNT_MASK, pbeccsts);
17931792

17941793
/* Do the reset outside of interrupt context */
17951794
schedule_work(&adapter->reset_task);
@@ -1868,8 +1867,7 @@ static irqreturn_t e1000_intr(int __always_unused irq, void *data)
18681867
adapter->corr_errors +=
18691868
pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
18701869
adapter->uncorr_errors +=
1871-
(pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
1872-
E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
1870+
FIELD_GET(E1000_PBECCSTS_UNCORR_ERR_CNT_MASK, pbeccsts);
18731871

18741872
/* Do the reset outside of interrupt context */
18751873
schedule_work(&adapter->reset_task);
@@ -5031,8 +5029,7 @@ static void e1000e_update_stats(struct e1000_adapter *adapter)
50315029
adapter->corr_errors +=
50325030
pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK;
50335031
adapter->uncorr_errors +=
5034-
(pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >>
5035-
E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT;
5032+
FIELD_GET(E1000_PBECCSTS_UNCORR_ERR_CNT_MASK, pbeccsts);
50365033
}
50375034
}
50385035

@@ -6249,7 +6246,7 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)
62496246
phy_reg |= BM_RCTL_MPE;
62506247
phy_reg &= ~(BM_RCTL_MO_MASK);
62516248
if (mac_reg & E1000_RCTL_MO_3)
6252-
phy_reg |= (((mac_reg & E1000_RCTL_MO_3) >> E1000_RCTL_MO_SHIFT)
6249+
phy_reg |= (FIELD_GET(E1000_RCTL_MO_3, mac_reg)
62536250
<< BM_RCTL_MO_SHIFT);
62546251
if (mac_reg & E1000_RCTL_BAM)
62556252
phy_reg |= BM_RCTL_BAM;

drivers/net/ethernet/intel/e1000e/phy.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
154154
e_dbg("MDI Read PHY Reg Address %d Error\n", offset);
155155
return -E1000_ERR_PHY;
156156
}
157-
if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) {
157+
if (FIELD_GET(E1000_MDIC_REG_MASK, mdic) != offset) {
158158
e_dbg("MDI Read offset error - requested %d, returned %d\n",
159-
offset,
160-
(mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT);
159+
offset, FIELD_GET(E1000_MDIC_REG_MASK, mdic));
161160
return -E1000_ERR_PHY;
162161
}
163162
*data = (u16)mdic;
@@ -167,7 +166,6 @@ s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
167166
*/
168167
if (hw->mac.type == e1000_pch2lan)
169168
udelay(100);
170-
171169
return 0;
172170
}
173171

@@ -218,10 +216,9 @@ s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
218216
e_dbg("MDI Write PHY Red Address %d Error\n", offset);
219217
return -E1000_ERR_PHY;
220218
}
221-
if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) {
219+
if (FIELD_GET(E1000_MDIC_REG_MASK, mdic) != offset) {
222220
e_dbg("MDI Write offset error - requested %d, returned %d\n",
223-
offset,
224-
(mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT);
221+
offset, FIELD_GET(E1000_MDIC_REG_MASK, mdic));
225222
return -E1000_ERR_PHY;
226223
}
227224

@@ -463,8 +460,8 @@ static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data,
463460
return ret_val;
464461
}
465462

466-
kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
467-
E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
463+
kmrnctrlsta = FIELD_PREP(E1000_KMRNCTRLSTA_OFFSET, offset) |
464+
E1000_KMRNCTRLSTA_REN;
468465
ew32(KMRNCTRLSTA, kmrnctrlsta);
469466
e1e_flush();
470467

@@ -536,8 +533,7 @@ static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data,
536533
return ret_val;
537534
}
538535

539-
kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
540-
E1000_KMRNCTRLSTA_OFFSET) | data;
536+
kmrnctrlsta = FIELD_PREP(E1000_KMRNCTRLSTA_OFFSET, offset) | data;
541537
ew32(KMRNCTRLSTA, kmrnctrlsta);
542538
e1e_flush();
543539

@@ -1793,8 +1789,7 @@ s32 e1000e_get_cable_length_m88(struct e1000_hw *hw)
17931789
if (ret_val)
17941790
return ret_val;
17951791

1796-
index = ((phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
1797-
M88E1000_PSSR_CABLE_LENGTH_SHIFT);
1792+
index = FIELD_GET(M88E1000_PSSR_CABLE_LENGTH, phy_data);
17981793

17991794
if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1)
18001795
return -E1000_ERR_PHY;
@@ -3234,8 +3229,7 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw)
32343229
if (ret_val)
32353230
return ret_val;
32363231

3237-
length = ((phy_data & I82577_DSTATUS_CABLE_LENGTH) >>
3238-
I82577_DSTATUS_CABLE_LENGTH_SHIFT);
3232+
length = FIELD_GET(I82577_DSTATUS_CABLE_LENGTH, phy_data);
32393233

32403234
if (length == E1000_CABLE_LENGTH_UNDEFINED)
32413235
return -E1000_ERR_PHY;

0 commit comments

Comments
 (0)