Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: iio: Prefer using the BIT macro

This patch replaces bit shifting on 1 with the BIT(x) macro
as it's extensively used by other function in this driver.

This was done with coccinelle:
@@ int g; @@

-(1 << g)
+BIT(g)

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Reviewed-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Cristina Opriceana and committed by
Greg Kroah-Hartman
f1d05b5f 6970791f

+27 -27
+1 -1
drivers/staging/iio/frequency/ad9832.c
··· 59 59 static int ad9832_write_phase(struct ad9832_state *st, 60 60 unsigned long addr, unsigned long phase) 61 61 { 62 - if (phase > (1 << AD9832_PHASE_BITS)) 62 + if (phase > BIT(AD9832_PHASE_BITS)) 63 63 return -EINVAL; 64 64 65 65 st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
+6 -6
drivers/staging/iio/frequency/ad9832.h
··· 42 42 #define AD9832_CMD_SYNCSELSRC 0x8 43 43 #define AD9832_CMD_SLEEPRESCLR 0xC 44 44 45 - #define AD9832_FREQ (1 << 11) 45 + #define AD9832_FREQ BIT(11) 46 46 #define AD9832_PHASE(x) (((x) & 3) << 9) 47 - #define AD9832_SYNC (1 << 13) 48 - #define AD9832_SELSRC (1 << 12) 49 - #define AD9832_SLEEP (1 << 13) 50 - #define AD9832_RESET (1 << 12) 51 - #define AD9832_CLR (1 << 11) 47 + #define AD9832_SYNC BIT(13) 48 + #define AD9832_SELSRC BIT(12) 49 + #define AD9832_SLEEP BIT(13) 50 + #define AD9832_RESET BIT(12) 51 + #define AD9832_CLR BIT(11) 52 52 #define CMD_SHIFT 12 53 53 #define ADD_SHIFT 8 54 54 #define AD9832_FREQ_BITS 32
+2 -2
drivers/staging/iio/frequency/ad9834.c
··· 27 27 28 28 static unsigned int ad9834_calc_freqreg(unsigned long mclk, unsigned long fout) 29 29 { 30 - unsigned long long freqreg = (u64)fout * (u64)(1 << AD9834_FREQ_BITS); 30 + unsigned long long freqreg = (u64)fout * (u64)BIT(AD9834_FREQ_BITS); 31 31 32 32 do_div(freqreg, mclk); 33 33 return freqreg; ··· 55 55 static int ad9834_write_phase(struct ad9834_state *st, 56 56 unsigned long addr, unsigned long phase) 57 57 { 58 - if (phase > (1 << AD9834_PHASE_BITS)) 58 + if (phase > BIT(AD9834_PHASE_BITS)) 59 59 return -EINVAL; 60 60 st->data = cpu_to_be16(addr | phase); 61 61
+18 -18
drivers/staging/iio/frequency/ad9834.h
··· 10 10 11 11 /* Registers */ 12 12 13 - #define AD9834_REG_CMD (0 << 14) 14 - #define AD9834_REG_FREQ0 (1 << 14) 15 - #define AD9834_REG_FREQ1 (2 << 14) 16 - #define AD9834_REG_PHASE0 (6 << 13) 17 - #define AD9834_REG_PHASE1 (7 << 13) 13 + #define AD9834_REG_CMD 0 14 + #define AD9834_REG_FREQ0 BIT(14) 15 + #define AD9834_REG_FREQ1 BIT(15) 16 + #define AD9834_REG_PHASE0 (BIT(15) | BIT(14)) 17 + #define AD9834_REG_PHASE1 (BIT(15) | BIT(14) | BIT(13)) 18 18 19 19 /* Command Control Bits */ 20 20 21 - #define AD9834_B28 (1 << 13) 22 - #define AD9834_HLB (1 << 12) 23 - #define AD9834_FSEL (1 << 11) 24 - #define AD9834_PSEL (1 << 10) 25 - #define AD9834_PIN_SW (1 << 9) 26 - #define AD9834_RESET (1 << 8) 27 - #define AD9834_SLEEP1 (1 << 7) 28 - #define AD9834_SLEEP12 (1 << 6) 29 - #define AD9834_OPBITEN (1 << 5) 30 - #define AD9834_SIGN_PIB (1 << 4) 31 - #define AD9834_DIV2 (1 << 3) 32 - #define AD9834_MODE (1 << 1) 21 + #define AD9834_B28 BIT(13) 22 + #define AD9834_HLB BIT(12) 23 + #define AD9834_FSEL BIT(11) 24 + #define AD9834_PSEL BIT(10) 25 + #define AD9834_PIN_SW BIT(9) 26 + #define AD9834_RESET BIT(8) 27 + #define AD9834_SLEEP1 BIT(7) 28 + #define AD9834_SLEEP12 BIT(6) 29 + #define AD9834_OPBITEN BIT(5) 30 + #define AD9834_SIGN_PIB BIT(4) 31 + #define AD9834_DIV2 BIT(3) 32 + #define AD9834_MODE BIT(1) 33 33 34 34 #define AD9834_FREQ_BITS 28 35 35 #define AD9834_PHASE_BITS 12 36 36 37 - #define RES_MASK(bits) ((1 << (bits)) - 1) 37 + #define RES_MASK(bits) (BIT(bits) - 1) 38 38 39 39 /** 40 40 * struct ad9834_state - driver instance specific data