Re: [Outreachy kernel] Re: [PATCH 2/3] staging: iio: ad7152: Use GENMASK() macro for left shifts
From: sayli karnik <hidden>
Date: 2017-02-19 06:01:52
On Sun, Feb 19, 2017 at 2:10 AM, Lars-Peter Clausen [off-list ref] wrote:
On 02/18/2017 09:21 PM, sayli karnik wrote:quoted
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.
Yes I am sending another version.
Some additional comments inline. [...]quoted
/* 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 [...]quoted
/* 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).
The outer parentheses are certainly not needed but for the ones around x, checkpatch.pl complains otherwise- CHECK: Macro argument 'x' may be better as '(x)' to avoid precedence issues Should I still remove them? thanks, sayli
-- You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com. To post to this group, send email to outreachy-kernel@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/0b5ef4d0-14b5-1196-8bc4-deda9d8f75ce%40metafoo.de. For more options, visit https://groups.google.com/d/optout.