* [PATCH 0/2] Staging:iio:adc:Prefer using BIT macro
@ 2016-02-08 6:48 Bhumika Goyal
2016-02-08 6:48 ` [PATCH 1/2] Staging:iio:Prefer " Bhumika Goyal
2016-02-08 6:48 ` [PATCH 2/2] Staging: iio: adc: Prefer using the " Bhumika Goyal
0 siblings, 2 replies; 6+ messages in thread
From: Bhumika Goyal @ 2016-02-08 6:48 UTC (permalink / raw)
To: lars, gregkh, Michael.Hennerich, jic23, knaack.h, pmeerw
Cc: linux-iio, devel, linux-kernel, Bhumika Goyal
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(-)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Staging:iio:Prefer using BIT macro
2016-02-08 6:48 [PATCH 0/2] Staging:iio:adc:Prefer using BIT macro Bhumika Goyal
@ 2016-02-08 6:48 ` Bhumika Goyal
2016-02-08 9:14 ` Lars-Peter Clausen
2016-02-08 6:48 ` [PATCH 2/2] Staging: iio: adc: Prefer using the " Bhumika Goyal
1 sibling, 1 reply; 6+ messages in thread
From: Bhumika Goyal @ 2016-02-08 6:48 UTC (permalink / raw)
To: lars, gregkh, Michael.Hennerich, jic23, knaack.h, pmeerw
Cc: linux-iio, devel, linux-kernel, Bhumika Goyal
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/ad7816.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 2226051..f631012 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro
2016-02-08 6:48 [PATCH 0/2] Staging:iio:adc:Prefer using BIT macro Bhumika Goyal
2016-02-08 6:48 ` [PATCH 1/2] Staging:iio:Prefer " Bhumika Goyal
@ 2016-02-08 6:48 ` Bhumika Goyal
2016-02-08 9:16 ` Lars-Peter Clausen
1 sibling, 1 reply; 6+ messages in thread
From: Bhumika Goyal @ 2016-02-08 6:48 UTC (permalink / raw)
To: lars, gregkh, Michael.Hennerich, jic23, knaack.h, pmeerw
Cc: linux-iio, devel, linux-kernel, Bhumika Goyal
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro
2016-02-08 6:48 ` [PATCH 1/2] Staging:iio:Prefer " Bhumika Goyal
@ 2016-02-08 9:14 ` Lars-Peter Clausen
2016-02-08 15:11 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Lars-Peter Clausen @ 2016-02-08 9:14 UTC (permalink / raw)
To: Bhumika Goyal, gregkh, Michael.Hennerich, jic23, knaack.h, pmeerw
Cc: linux-iio, devel, linux-kernel
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.
> ---
> drivers/staging/iio/adc/ad7816.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
> index 2226051..f631012 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -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.
> return sprintf(buf, "%d.%.2d\n", value, data * 25);
> }
> return sprintf(buf, "%u\n", data);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Staging: iio: adc: Prefer using the BIT macro
2016-02-08 6:48 ` [PATCH 2/2] Staging: iio: adc: Prefer using the " Bhumika Goyal
@ 2016-02-08 9:16 ` Lars-Peter Clausen
0 siblings, 0 replies; 6+ messages in thread
From: Lars-Peter Clausen @ 2016-02-08 9:16 UTC (permalink / raw)
To: Bhumika Goyal, gregkh, Michael.Hennerich, jic23, knaack.h, pmeerw
Cc: linux-iio, devel, linux-kernel
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro
2016-02-08 9:14 ` Lars-Peter Clausen
@ 2016-02-08 15:11 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2016-02-08 15:11 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Bhumika Goyal, Greg Kroah-Hartman, Michael Hennerich, jic23,
knaack.h, Peter Meerwald-Stadler, linux-iio, devel,
linux-kernel@vger.kernel.org
On Mon, Feb 8, 2016 at 11:14 AM, Lars-Peter Clausen <lars@metafoo.de> wrote:
> On 02/08/2016 07:48 AM, Bhumika Goyal wrote:
>> 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.
+1. Here clearly the intention is to change sign of the value which
fits less than 32/16/8 bits. 1 << OFFSET represents '-0'.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-08 15:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-08 6:48 [PATCH 0/2] Staging:iio:adc:Prefer using BIT macro Bhumika Goyal
2016-02-08 6:48 ` [PATCH 1/2] Staging:iio:Prefer " Bhumika Goyal
2016-02-08 9:14 ` Lars-Peter Clausen
2016-02-08 15:11 ` Andy Shevchenko
2016-02-08 6:48 ` [PATCH 2/2] Staging: iio: adc: Prefer using the " Bhumika Goyal
2016-02-08 9:16 ` Lars-Peter Clausen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).