Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1328797 > unrolled thread

[PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro

Started byBhumika Goyal <bhumirks@gmail.com>
First post2016-02-08 08:00 +0100
Last post2016-02-08 11:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro Bhumika Goyal <bhumirks@gmail.com> - 2016-02-08 08:00 +0100
    Re: [PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro Lars-Peter Clausen <lars@metafoo.de> - 2016-02-08 11:20 +0100

#1328797 — [PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro

FromBhumika Goyal <bhumirks@gmail.com>
Date2016-02-08 08:00 +0100
Subject[PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro
Message-ID<qZNXI-1zU-5@gated-at.bofh.it>
This patch replaces bit shifting on 1 with the BIT(x) macro.

This was done with coccinelle:

@@ int g; @@

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

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 0c73bce..ccf3157 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -117,7 +117,7 @@
  */
 #define POLYNOM		0x2F
 #define POLYNOM_ORDER	8
-#define HIGHBIT		(1 << (POLYNOM_ORDER - 1))
+#define HIGHBIT		BIT((POLYNOM_ORDER - 1))
 
 struct ad7280_state {
 	struct spi_device		*spi;
@@ -388,7 +388,7 @@ static ssize_t ad7280_show_balance_sw(struct device *dev,
 
 	return sprintf(buf, "%d\n",
 		       !!(st->cb_mask[this_attr->address >> 8] &
-		       (1 << ((this_attr->address & 0xFF) + 2))));
+		       BIT(((this_attr->address & 0xFF) + 2))));
 }
 
 static ssize_t ad7280_store_balance_sw(struct device *dev,
-- 
1.9.1

[toc] | [next] | [standalone]


#1328883

FromLars-Peter Clausen <lars@metafoo.de>
Date2016-02-08 11:20 +0100
Message-ID<qZR5f-3R9-9@gated-at.bofh.it>
In reply to#1328797
On 02/08/2016 07:48 AM, Bhumika Goyal wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro.
> 
> This was done with coccinelle:
> 
> @@ int g; @@
> 
> -(1 << g)
> +BIT(g)
> 
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>

Hi,

Thanks for the patch. This looks good.

> ---
>  drivers/staging/iio/adc/ad7280a.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 0c73bce..ccf3157 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -117,7 +117,7 @@
>   */
>  #define POLYNOM		0x2F
>  #define POLYNOM_ORDER	8
> -#define HIGHBIT		(1 << (POLYNOM_ORDER - 1))
> +#define HIGHBIT		BIT((POLYNOM_ORDER - 1))

But please drop the extra brackets and resend the patch.

>  
>  struct ad7280_state {
>  	struct spi_device		*spi;
> @@ -388,7 +388,7 @@ static ssize_t ad7280_show_balance_sw(struct device *dev,
>  
>  	return sprintf(buf, "%d\n",
>  		       !!(st->cb_mask[this_attr->address >> 8] &
> -		       (1 << ((this_attr->address & 0xFF) + 2))));
> +		       BIT(((this_attr->address & 0xFF) + 2))));

Same here.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web