* [PATCH] iio: ad7949: fix wrong ADC result due to incorrect bit mask
@ 2021-02-06 14:03 Wilfried Wessner
2021-02-06 14:11 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Wilfried Wessner @ 2021-02-06 14:03 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Peter Meerwald-Stadler
Cc: linux-iio, gregkh, Andy Shevchenko
Signed-off-by: Wilfried Wessner <wilfried.wessner@gmail.com>
Fixes a wrong bit mask used for the ADC's result, which was caused by an
improper usage of the GENMASK() macro. The bits higher than ADC's
resolution are undefined and if not masked out correctly, a wrong result
can be given. The GENMASK() macro indexing is zero based, so the mask has
to go from [resolution -1 , 0].
---
drivers/iio/adc/ad7949.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c
index 5d597e5050f6..1b4b3203e428 100644
--- a/drivers/iio/adc/ad7949.c
+++ b/drivers/iio/adc/ad7949.c
@@ -91,7 +91,7 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
int ret;
int i;
int bits_per_word = ad7949_adc->resolution;
- int mask = GENMASK(ad7949_adc->resolution, 0);
+ int mask = GENMASK(ad7949_adc->resolution - 1, 0);
struct spi_message msg;
struct spi_transfer tx[] = {
{
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iio: ad7949: fix wrong ADC result due to incorrect bit mask
2021-02-06 14:03 [PATCH] iio: ad7949: fix wrong ADC result due to incorrect bit mask Wilfried Wessner
@ 2021-02-06 14:11 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-02-06 14:11 UTC (permalink / raw)
To: Wilfried Wessner
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Peter Meerwald-Stadler, linux-iio, Andy Shevchenko
On Sat, Feb 06, 2021 at 03:03:20PM +0100, Wilfried Wessner wrote:
> Signed-off-by: Wilfried Wessner <wilfried.wessner@gmail.com>
This needs to go after the changelog text.
>
> Fixes a wrong bit mask used for the ADC's result, which was caused by an
> improper usage of the GENMASK() macro. The bits higher than ADC's
> resolution are undefined and if not masked out correctly, a wrong result
> can be given. The GENMASK() macro indexing is zero based, so the mask has
> to go from [resolution -1 , 0].
You have trailing whitespace in your text, perhaps get your editor to
show you this?
Also, this is a new version of the patch, it needs to be marked as such
so we know which is the "latest". The documentation says how to do
that.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-06 14:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-06 14:03 [PATCH] iio: ad7949: fix wrong ADC result due to incorrect bit mask Wilfried Wessner
2021-02-06 14:11 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.