All of lore.kernel.org
 help / color / mirror / Atom feed
* patch "iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask" added to staging-linus
@ 2021-03-15 15:35 gregkh
  2021-03-22  9:50 ` Wilfried Wessner
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2021-03-15 15:35 UTC (permalink / raw)
  To: wilfried.wessner, Jonathan.Cameron, Stable, andy.shevchenko,
	charles-antoine.couret


This is a note to let you know that I've just added the patch titled

    iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask

to my staging git tree which can be found at
    git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.

The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the
next -rc kernel release.

If you have any questions about this process, please let me know.


From f890987fac8153227258121740a9609668c427f3 Mon Sep 17 00:00:00 2001
From: Wilfried Wessner <wilfried.wessner@gmail.com>
Date: Mon, 8 Feb 2021 15:27:05 +0100
Subject: iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask

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].

Fixes: 7f40e0614317f ("iio:adc:ad7949: Add AD7949 ADC driver family")
Signed-off-by: Wilfried Wessner <wilfried.wessner@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Charles-Antoine Couret <charles-antoine.couret@essensium.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210208142705.GA51260@ubuntu
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 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.30.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: patch "iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask" added to staging-linus
  2021-03-15 15:35 patch "iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask" added to staging-linus gregkh
@ 2021-03-22  9:50 ` Wilfried Wessner
  0 siblings, 0 replies; 2+ messages in thread
From: Wilfried Wessner @ 2021-03-22  9:50 UTC (permalink / raw)
  To: Greg KH; +Cc: Jonathan.Cameron, Stable, Andy Shevchenko, Charles-Antoine Couret

Hi all,

That is exciting news.

Thanks everybody!

Best regards,
Willi



On Mon, Mar 15, 2021 at 4:35 PM <gregkh@linuxfoundation.org> wrote:
>
>
> This is a note to let you know that I've just added the patch titled
>
>     iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask
>
> to my staging git tree which can be found at
>     git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
> in the staging-linus branch.
>
> The patch will show up in the next release of the linux-next tree
> (usually sometime within the next 24 hours during the week.)
>
> The patch will hopefully also be merged in Linus's tree for the
> next -rc kernel release.
>
> If you have any questions about this process, please let me know.
>
>
> From f890987fac8153227258121740a9609668c427f3 Mon Sep 17 00:00:00 2001
> From: Wilfried Wessner <wilfried.wessner@gmail.com>
> Date: Mon, 8 Feb 2021 15:27:05 +0100
> Subject: iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask
>
> 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].
>
> Fixes: 7f40e0614317f ("iio:adc:ad7949: Add AD7949 ADC driver family")
> Signed-off-by: Wilfried Wessner <wilfried.wessner@gmail.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Reviewed-by: Charles-Antoine Couret <charles-antoine.couret@essensium.com>
> Cc: <Stable@vger.kernel.org>
> Link: https://lore.kernel.org/r/20210208142705.GA51260@ubuntu
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  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.30.2
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-22  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 15:35 patch "iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask" added to staging-linus gregkh
2021-03-22  9:50 ` Wilfried Wessner

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.