Staging:iio:adc:Prefer using BIT macro
Subsystems (4)
cover Staging:iio:adc:Prefer using BIT macro
This patchset replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
Bhumika Goyal (2):
Staging:iio:Prefer using BIT macro
Staging: iio: adc: Prefer using the BIT macro
drivers/staging/iio/adc/ad7280a.c | 4 ++-- drivers/staging/iio/adc/ad7816.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 Staging:iio:Prefer using BIT macro
This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
--- drivers/staging/iio/adc/ad7816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7816.c +1 -1
@@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev, value = (s8)((data >>AD7816_TEMP_FLOAT_OFFSET ) -103 ); data &=AD7816_TEMP_FLOAT_MASK ;if (value <0 ) - data = (1 <<AD7816_TEMP_FLOAT_OFFSET ) - data; + data =BIT (AD7816_TEMP_FLOAT_OFFSET ) - data;return sprintf (buf,"%d.%.2d\n" , value, data *25 ); }return sprintf (buf,"%u\n" , data);
Signature · 1 line
1.9.1
PATCH 2/2 Staging: iio: adc: Prefer using the BIT macro
In reply to Bhumika GoyalThis patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
--- drivers/staging/iio/adc/ad7280a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/adc/ad7280a.c +2 -2
@@ -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,
Signature · 1 line
1.9.1
Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro
In reply to Bhumika GoyalQuoted 7 lines · Bhumika Goyal
This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@ int g; @@(quoted diff) +1
-1-(1 << g) +BIT(g)Signed-off-by Bhumika Goyal <[email protected]>
Hi,
Thanks for the patch.
Quoted 9 lines
--- drivers/staging/iio/adc/ad7816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/iio/adc/ad7816.c +0
-0
drivers/staging/iio/adc/ad7816.c static ssize_t ad7816_show_value(struct device *dev, · line 225
Quoted 5 lines
drivers/staging/iio/adc/ad7816.c +1
-1@@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev, value = (s8)((data >>AD7816_TEMP_FLOAT_OFFSET ) -103 ); data &=AD7816_TEMP_FLOAT_MASK ;if (value <0 ) - data = (1 <<AD7816_TEMP_FLOAT_OFFSET ) - data; + data =BIT (AD7816_TEMP_FLOAT_OFFSET ) - data;
But in this case this is a false positive. The intended semantic meaning here is 2**... not BIT(...). Using BIT() here in my opinion only causes confusion.
Quoted 4 lines
drivers/staging/iio/adc/ad7816.c +0
-0return sprintf (buf,"%d.%.2d\n" , value, data *25 ); }return sprintf (buf,"%u\n" , data);
Re: [PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro
In reply to Bhumika GoyalQuoted 10 lines · Bhumika Goyal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@ int g; @@
(quoted diff) +1
-1-(1 << g) +BIT(g)Signed-off-by Bhumika Goyal <[email protected]>
Hi,
Thanks for the patch. This looks good.
Quoted 9 lines
--- drivers/staging/iio/adc/ad7280a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/iio/adc/ad7280a.c +0
-0
drivers/staging/iio/adc/ad7280a.c line 120
Quoted 5 lines
drivers/staging/iio/adc/ad7280a.c +1
-1@@ -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.
drivers/staging/iio/adc/ad7280a.c static ssize_t ad7280_show_balance_sw(struct device *dev, · line 391
Quoted 9 lines
drivers/staging/iio/adc/ad7280a.c +1
-1struct 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.
Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro
In reply to Lars-Peter ClausenQuoted 9 lines · Lars-Peter Clausen
drivers/staging/iio/adc/ad7816.c static ssize_t ad7816_show_value(struct device *dev, · line 225
Quoted 5 lines · Bhumika Goyal
value = (s8)((data >> AD7816_TEMP_FLOAT_OFFSET) - 103); data &= AD7816_TEMP_FLOAT_MASK; if (value < 0)drivers/staging/iio/adc/ad7816.c +1
-1- data = (1 <<AD7816_TEMP_FLOAT_OFFSET ) - data; + data =BIT (AD7816_TEMP_FLOAT_OFFSET ) - data;
Quoted 3 lines
But in this case this is a false positive. The intended semantic meaning here is 2**... not BIT(...). Using
BIT()here in my opinion only causes confusion.
+1. Here clearly the intention is to change sign of the value which fits less than 32/16/8 bits. 1 << OFFSET represents '-0'.
Signature · 2 lines
With Best Regards, Andy Shevchenko