@@ -183,7 +183,7 @@ static int _apl_rd_reg(int port, int off, int op, u32 *data)
183183 }
184184
185185 P2SB_READ (dword , P2SB_DATA_OFF , data );
186- ret = (status >> 1 ) & 0x3 ;
186+ ret = (status >> 1 ) & GENMASK ( 1 , 0 ) ;
187187out :
188188 /* Hide the P2SB device, if it was hidden before */
189189 if (hidden )
@@ -307,7 +307,7 @@ static bool two_channels; /* Both PMI channels in one slice enabled */
307307
308308static u8 sym_chan_mask ;
309309static u8 asym_chan_mask ;
310- static u8 chan_mask ;
310+ static unsigned long chan_mask ;
311311
312312static int slice_selector = -1 ;
313313static int chan_selector = -1 ;
@@ -598,7 +598,7 @@ static void remove_addr_bit(u64 *addr, int bitidx)
598598 if (bitidx == -1 )
599599 return ;
600600
601- mask = ( 1ull << bitidx ) - 1 ;
601+ mask = BIT_ULL ( bitidx ) - 1 ;
602602 * addr = ((* addr >> 1 ) & ~mask ) | (* addr & mask );
603603}
604604
@@ -642,7 +642,7 @@ static int sys2pmi(const u64 addr, u32 *pmiidx, u64 *pmiaddr, char *msg)
642642 int sym_chan_shift = sym_channels >> 1 ;
643643
644644 /* Give up if address is out of range, or in MMIO gap */
645- if (addr >= ( 1ul << PND_MAX_PHYS_BIT ) ||
645+ if (addr >= BIT ( PND_MAX_PHYS_BIT ) ||
646646 (addr >= top_lm && addr < SZ_4G ) || addr >= top_hm ) {
647647 snprintf (msg , PND2_MSG_SIZE , "Error address 0x%llx is not DRAM" , addr );
648648 return - EINVAL ;
@@ -727,10 +727,10 @@ static int sys2pmi(const u64 addr, u32 *pmiidx, u64 *pmiaddr, char *msg)
727727}
728728
729729/* Translate PMI address to memory (rank, row, bank, column) */
730- #define C (n ) (0x10 | (n)) /* column */
731- #define B (n ) (0x20 | (n)) /* bank */
732- #define R (n ) (0x40 | (n)) /* row */
733- #define RS (0x80) /* rank */
730+ #define C (n ) (BIT(4) | (n)) /* column */
731+ #define B (n ) (BIT(5) | (n)) /* bank */
732+ #define R (n ) (BIT(6) | (n)) /* row */
733+ #define RS (BIT(7)) /* rank */
734734
735735/* addrdec values */
736736#define AMAP_1KB 0
@@ -1064,9 +1064,9 @@ static int apl_check_ecc_active(void)
10641064 int i , ret = 0 ;
10651065
10661066 /* Check dramtype and ECC mode for each present DIMM */
1067- for ( i = 0 ; i < APL_NUM_CHANNELS ; i ++ )
1068- if ( chan_mask & BIT (i ))
1069- ret += check_channel ( i );
1067+ for_each_set_bit ( i , & chan_mask , APL_NUM_CHANNELS )
1068+ ret += check_channel (i );
1069+
10701070 return ret ? - EINVAL : 0 ;
10711071}
10721072
@@ -1205,10 +1205,7 @@ static void apl_get_dimm_config(struct mem_ctl_info *mci)
12051205 u64 capacity ;
12061206 int i , g ;
12071207
1208- for (i = 0 ; i < APL_NUM_CHANNELS ; i ++ ) {
1209- if (!(chan_mask & BIT (i )))
1210- continue ;
1211-
1208+ for_each_set_bit (i , & chan_mask , APL_NUM_CHANNELS ) {
12121209 dimm = edac_get_dimm (mci , i , 0 , 0 );
12131210 if (!dimm ) {
12141211 edac_dbg (0 , "No allocated DIMM for channel %d\n" , i );
@@ -1228,8 +1225,7 @@ static void apl_get_dimm_config(struct mem_ctl_info *mci)
12281225 }
12291226
12301227 pvt -> dimm_geom [i ] = g ;
1231- capacity = (d -> rken0 + d -> rken1 ) * 8 * (1ul << dimms [g ].rowbits ) *
1232- (1ul << dimms [g ].colbits );
1228+ capacity = (d -> rken0 + d -> rken1 ) * 8 * BIT (dimms [g ].rowbits + dimms [g ].colbits );
12331229 edac_dbg (0 , "Channel %d: %lld MByte DIMM\n" , i , capacity >> (20 - 3 ));
12341230 dimm -> nr_pages = MiB_TO_PAGES (capacity >> (20 - 3 ));
12351231 dimm -> grain = 32 ;
@@ -1295,7 +1291,7 @@ static void dnv_get_dimm_config(struct mem_ctl_info *mci)
12951291 continue ;
12961292 }
12971293
1298- capacity = ranks_of_dimm [j ] * banks * ( 1ul << rowbits ) * ( 1ul << colbits );
1294+ capacity = ranks_of_dimm [j ] * banks * BIT ( rowbits + colbits );
12991295 edac_dbg (0 , "Channel %d DIMM %d: %lld MByte DIMM\n" , i , j , capacity >> (20 - 3 ));
13001296 dimm -> nr_pages = MiB_TO_PAGES (capacity >> (20 - 3 ));
13011297 dimm -> grain = 32 ;
0 commit comments