Re: [PATCH 2/3] staging: iio: ad7152: Use GENMASK() macro for left shifts
From: Lars-Peter Clausen <lars@metafoo.de>
Date: 2017-02-18 20:40:56
On 02/18/2017 09:21 PM, sayli karnik wrote:
quoted hunk ↗ jump to hunk
Use GENMASK() macro for left shifting integers. Done using coccinelle:@@ int a,b; @@ -(a << b) +GENMASK(a, b)Signed-off-by: sayli karnik <redacted>
Hi, Thanks for the patch. Looks mostly good, but please rework the patch for version 2 to address the comments for patch 1. Some additional comments inline. [...]
/* Setup Register Bit Designations (AD7152_REG_CHx_SETUP) */ #define AD7152_SETUP_CAPDIFF BIT(5) -#define AD7152_SETUP_RANGE_2pF (0 << 6) +#define AD7152_SETUP_RANGE_2pF GENMASK(0, 6) #define AD7152_SETUP_RANGE_0_5pF BIT(6) -#define AD7152_SETUP_RANGE_1pF (2 << 6) -#define AD7152_SETUP_RANGE_4pF (3 << 6) +#define AD7152_SETUP_RANGE_1pF GENMASK(2, 6) +#define AD7152_SETUP_RANGE_4pF GENMASK(3, 6) #define AD7152_SETUP_RANGE(x) ((x) << 6)
AD7152_SETUP_RANGE() can also use the GENMASK() macro [...]
/* CFG2 Register Bit Designations (AD7152_REG_CFG2) */ -#define AD7152_CFG2_OSR(x) (((x) & 0x3) << 4) +#define AD7152_CFG2_OSR(x) GENMASK(((x) & 0x3), 4)
The extra parenthesis around (x) & 0x3 are no needed when using the macro (the macro will add them).