From: Julia Lawall <julia.lawall@lip6.fr>
To: sayli karnik <karniksayli1995@gmail.com>
Cc: outreachy-kernel@googlegroups.com,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org
Subject: Re: [Outreachy kernel] [PATCH 2/3] staging: iio: ad7152: Use GENMASK() macro for left shifts
Date: Sat, 18 Feb 2017 21:35:32 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.20.1702182135010.2383@hadrien> (raw)
In-Reply-To: <92240a3dca0138880fe47a7df0a5e6df869c8199.1487448326.git.karniksayli1995@gmail.com>
On Sun, 19 Feb 2017, sayli karnik wrote:
> Use GENMASK() macro for left shifting integers.
> Done using coccinelle:
> @@ int a,b; @@
>
> -(a << b)
> +GENMASK(a, b)
>
> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
> ---
> drivers/staging/iio/cdc/ad7152.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c
> index 0c97d5a..988b89b 100644
> --- a/drivers/staging/iio/cdc/ad7152.c
> +++ b/drivers/staging/iio/cdc/ad7152.c
> @@ -48,27 +48,27 @@
>
> /* 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)
I think it would be more understandable to do all of the cases in the same
way.
julia
>
> /* Config Register Bit Designations (AD7152_REG_CFG) */
> #define AD7152_CONF_CH2EN BIT(3)
> #define AD7152_CONF_CH1EN BIT(4)
> -#define AD7152_CONF_MODE_IDLE (0 << 0)
> +#define AD7152_CONF_MODE_IDLE GENMASK(0, 0)
> #define AD7152_CONF_MODE_CONT_CONV BIT(0)
> -#define AD7152_CONF_MODE_SINGLE_CONV (2 << 0)
> -#define AD7152_CONF_MODE_OFFS_CAL (5 << 0)
> -#define AD7152_CONF_MODE_GAIN_CAL (6 << 0)
> +#define AD7152_CONF_MODE_SINGLE_CONV GENMASK(2, 0)
> +#define AD7152_CONF_MODE_OFFS_CAL GENMASK(5, 0)
> +#define AD7152_CONF_MODE_GAIN_CAL GENMASK(6, 0)
>
> /* Capdac Register Bit Designations (AD7152_REG_CAPDAC_XXX) */
> #define AD7152_CAPDAC_DACEN BIT(7)
> #define AD7152_CAPDAC_DACP(x) ((x) & 0x1F)
>
> /* CFG2 Register Bit Designations (AD7152_REG_CFG2) */
> -#define AD7152_CFG2_OSR(x) (((x) & 0x3) << 4)
> +#define AD7152_CFG2_OSR(x) GENMASK(((x) & 0x3), 4)
>
> enum {
> AD7152_DATA,
> --
> 2.7.4
>
> --
> 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/92240a3dca0138880fe47a7df0a5e6df869c8199.1487448326.git.karniksayli1995%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
next prev parent reply other threads:[~2017-02-18 20:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-18 20:19 [PATCH 0/3] Use macros BIT() and GENMASK() sayli karnik
2017-02-18 20:20 ` [PATCH 1/3] staging: iio: ad7152: Use BIT() macro for left shifting 1 sayli karnik
2017-02-18 20:35 ` Lars-Peter Clausen
2017-02-18 20:21 ` [PATCH 2/3] staging: iio: ad7152: Use GENMASK() macro for left shifts sayli karnik
2017-02-18 20:35 ` Julia Lawall [this message]
2017-02-18 20:40 ` Lars-Peter Clausen
2017-02-19 6:01 ` [Outreachy kernel] " sayli karnik
2017-02-19 9:29 ` Lars-Peter Clausen
2017-02-18 20:22 ` [PATCH 3/3] staging: iio: ad7152: Add a blank line after a function definition sayli karnik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1702182135010.2383@hadrien \
--to=julia.lawall@lip6.fr \
--cc=Michael.Hennerich@analog.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=karniksayli1995@gmail.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=outreachy-kernel@googlegroups.com \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox