From: Julia Lawall <julia.lawall@lip6.fr>
To: Shraddha Barke <shraddha.6596@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@kernel.org>,
Peter Meerwald <pmeerw@pmeerw.net>,
Hartmut Knaack <knaack.h@gmx.de>,
linux-kernel@vger.kernel.org, Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 5/6] Staging: iio: impedance-analyzer: Prefer using the BIT macro
Date: Thu, 10 Sep 2015 07:57:30 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1509100756440.2148@localhost6.localdomain6> (raw)
In-Reply-To: <1441858434-2846-5-git-send-email-shraddha.6596@gmail.com>
On Thu, 10 Sep 2015, Shraddha Barke wrote:
> 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)
This doesn't look like a good idea here, since there is a mixture of uses
of BIT and other things for similar values.
julia
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> drivers/staging/iio/impedance-analyzer/ad5933.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index c18109c..48acad0 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -39,7 +39,7 @@
> #define AD5933_REG_IMAG_DATA 0x96 /* R, 2 bytes*/
>
> /* AD5933_REG_CONTROL_HB Bits */
> -#define AD5933_CTRL_INIT_START_FREQ (0x1 << 4)
> +#define AD5933_CTRL_INIT_START_FREQ BIT(4)
> #define AD5933_CTRL_START_SWEEP (0x2 << 4)
> #define AD5933_CTRL_INC_FREQ (0x3 << 4)
> #define AD5933_CTRL_REPEAT_FREQ (0x4 << 4)
> @@ -48,23 +48,23 @@
> #define AD5933_CTRL_STANDBY (0xB << 4)
>
> #define AD5933_CTRL_RANGE_2000mVpp (0x0 << 1)
> -#define AD5933_CTRL_RANGE_200mVpp (0x1 << 1)
> +#define AD5933_CTRL_RANGE_200mVpp BIT(1)
> #define AD5933_CTRL_RANGE_400mVpp (0x2 << 1)
> #define AD5933_CTRL_RANGE_1000mVpp (0x3 << 1)
> #define AD5933_CTRL_RANGE(x) ((x) << 1)
>
> -#define AD5933_CTRL_PGA_GAIN_1 (0x1 << 0)
> +#define AD5933_CTRL_PGA_GAIN_1 BIT(0)
> #define AD5933_CTRL_PGA_GAIN_5 (0x0 << 0)
>
> /* AD5933_REG_CONTROL_LB Bits */
> -#define AD5933_CTRL_RESET (0x1 << 4)
> +#define AD5933_CTRL_RESET BIT(4)
> #define AD5933_CTRL_INT_SYSCLK (0x0 << 3)
> -#define AD5933_CTRL_EXT_SYSCLK (0x1 << 3)
> +#define AD5933_CTRL_EXT_SYSCLK BIT(3)
>
> /* AD5933_REG_STATUS Bits */
> -#define AD5933_STAT_TEMP_VALID (0x1 << 0)
> -#define AD5933_STAT_DATA_VALID (0x1 << 1)
> -#define AD5933_STAT_SWEEP_DONE (0x1 << 2)
> +#define AD5933_STAT_TEMP_VALID BIT(0)
> +#define AD5933_STAT_DATA_VALID BIT(1)
> +#define AD5933_STAT_SWEEP_DONE BIT(2)
>
> /* I2C Block Commands */
> #define AD5933_I2C_BLOCK_WRITE 0xA0
> @@ -222,7 +222,7 @@ static int ad5933_set_freq(struct ad5933_state *st,
> u8 d8[4];
> } dat;
>
> - freqreg = (u64) freq * (u64) (1 << 27);
> + freqreg = (u64) freq * (u64) BIT(27);
> do_div(freqreg, st->mclk_hz / 4);
>
> switch (reg) {
> @@ -308,7 +308,7 @@ static ssize_t ad5933_show_frequency(struct device *dev,
> freqreg = be32_to_cpu(dat.d32) & 0xFFFFFF;
>
> freqreg = (u64) freqreg * (u64) (st->mclk_hz / 4);
> - do_div(freqreg, 1 << 27);
> + do_div(freqreg, BIT(27));
>
> return sprintf(buf, "%d\n", (int) freqreg);
> }
> @@ -437,7 +437,7 @@ static ssize_t ad5933_store(struct device *dev,
>
> /* 2x, 4x handling, see datasheet */
> if (val > 511)
> - val = (val >> 1) | (1 << 9);
> + val = (val >> 1) | BIT(9);
> else if (val > 1022)
> val = (val >> 2) | (3 << 9);
>
> --
> 2.1.4
>
>
next prev parent reply other threads:[~2015-09-10 5:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 4:13 [PATCH 1/6] Staging: iio: addac: adt7316.c : Prefer using " Shraddha Barke
2015-09-10 4:13 ` [PATCH 2/6] Staging: iio: cdc: ad7152.c: Prefer using the " Shraddha Barke
2015-09-10 6:01 ` Julia Lawall
2015-09-10 4:13 ` [PATCH 3/6] Staging: iio: meter: " Shraddha Barke
2015-09-10 4:13 ` [PATCH 4/6] Staging: iio: cdc: ad7746.c: " Shraddha Barke
2015-09-10 5:59 ` Julia Lawall
2015-09-10 4:13 ` [PATCH 5/6] Staging: iio: impedance-analyzer: " Shraddha Barke
2015-09-10 5:57 ` Julia Lawall [this message]
2015-09-10 10:05 ` Shraddha Barke
2015-09-10 12:42 ` Julia Lawall
2015-09-10 4:13 ` [PATCH 6/6] Staging: iio: resolver: " Shraddha Barke
2015-09-10 4:24 ` Joe Perches
2015-09-10 8:05 ` Julia Lawall
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.02.1509100756440.2148@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=shraddha.6596@gmail.com \
/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
all inboxes | Powered by JetHome®