Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1328798 > unrolled thread
| Started by | Bhumika Goyal <bhumirks@gmail.com> |
|---|---|
| First post | 2016-02-08 08:00 +0100 |
| Last post | 2016-02-08 16:20 +0100 |
| Articles | 3 — 3 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.
[PATCH 1/2] Staging:iio:Prefer using BIT macro Bhumika Goyal <bhumirks@gmail.com> - 2016-02-08 08:00 +0100
Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro Lars-Peter Clausen <lars@metafoo.de> - 2016-02-08 10:20 +0100
Re: [PATCH 1/2] Staging:iio:Prefer using BIT macro Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-02-08 16:20 +0100
| From | Bhumika Goyal <bhumirks@gmail.com> |
|---|---|
| Date | 2016-02-08 08:00 +0100 |
| Subject | [PATCH 1/2] Staging:iio:Prefer using BIT macro |
| Message-ID | <qZNXI-1zU-1@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/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
[toc] | [next] | [standalone]
| From | Lars-Peter Clausen <lars@metafoo.de> |
|---|---|
| Date | 2016-02-08 10:20 +0100 |
| Message-ID | <qZQ9c-3eh-19@gated-at.bofh.it> |
| In reply to | #1328798 |
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); >
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2016-02-08 16:20 +0100 |
| Message-ID | <qZVLA-74r-29@gated-at.bofh.it> |
| In reply to | #1328843 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web