Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Nuno Sa <nuno.sa@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: ad4000: fix reading unsigned data
Date: Thu, 31 Oct 2024 21:42:26 +0000	[thread overview]
Message-ID: <20241031214226.47043d3f@jic23-huawei> (raw)
In-Reply-To: <20241030-iio-adc-ad4000-fix-reading-unsigned-data-v1-1-2e28dd75fe29@baylibre.com>

On Wed, 30 Oct 2024 16:09:41 -0500
David Lechner <dlechner@baylibre.com> wrote:

> Fix reading unsigned data from the AD4000 ADC via the _raw sysfs
> attribute by ensuring that *val is set before returning from
> ad4000_single_conversion(). This was not being set in any code path
> and was causing the attribute to return a random value.
> 
> Fixes: 938fd562b974 ("iio: adc: Add support for AD4000")
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Applied.
> ---
> FYI, there is also another unrelated bug I noticed but didn't fix.
> 
> We are calling iio_push_to_buffers_with_timestamp() but there isn't
> actually a IIO_CHAN_SOFT_TIMESTAMP() channel. I assume the intention
> was to have the timestamp channel?

Technically harmless as it can never be turned on, but indeed seems
doubtful - maybe something to treat as a feature rather than a fix though
given it was never there.

> ---
>  drivers/iio/adc/ad4000.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c
> index 6ea491245084..fc9c9807f89d 100644
> --- a/drivers/iio/adc/ad4000.c
> +++ b/drivers/iio/adc/ad4000.c
> @@ -344,6 +344,8 @@ static int ad4000_single_conversion(struct iio_dev *indio_dev,
>  
>  	if (chan->scan_type.sign == 's')
>  		*val = sign_extend32(sample, chan->scan_type.realbits - 1);
> +	else
> +		*val = sample;
>  
>  	return IIO_VAL_INT;
>  }
> 
> ---
> base-commit: fa4076314480bcb2bb32051027735b1cde07eea2
> change-id: 20241030-iio-adc-ad4000-fix-reading-unsigned-data-88a1de88cf57
> 
> Best regards,


      reply	other threads:[~2024-10-31 21:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 21:09 [PATCH] iio: adc: ad4000: fix reading unsigned data David Lechner
2024-10-31 21:42 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241031214226.47043d3f@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox