The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Nguyễn Công" <congnt264@gmail.com>
Cc: "Andy Shevchenko" <andy.shevchenko@gmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: adc: max1363: sign-extend bipolar differential channel reads
Date: Mon, 17 Aug 2026 02:01:54 +0100	[thread overview]
Message-ID: <20260817020154.343c5080@jic23-huawei> (raw)
In-Reply-To: <CAJpJ=GvyZLEwbAS_iZ1sU8tR_cu=uSRZPwsWqXSKFhHauy4nmw@mail.gmail.com>

On Mon, 10 Aug 2026 23:50:53 +0700
Nguyễn Công <congnt264@gmail.com> wrote:

> On Mon, Aug 10, 2026 at 1:45 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> > On Mon, Aug 10, 2026 at 9:42 AM Cong Nguyen <congnt264@gmail.com> wrote:  
> > >
> > > The MAX1363 differential channels are bipolar (scan_type.sign = 's') and
> > > the device returns those samples in two's complement. However
> > > max1363_read_single_chan() masks the raw value to the ADC resolution and
> > > stores it as-is, without sign extension. A negative differential reading
> > > is therefore reported to userspace as a large positive value (for a 12-bit
> > > part, -1 reads back as 4095).  
> >
> > Try to make it more compact (remove unneeded or duplicative details,
> > do not blindly rely on AI).  
> 
> Done in v2 - trimmed both paragraphs down to the bug, one example, and
> the fix.
> 
> >  
> > > These channels expose only IIO_CHAN_INFO_RAW (no offset), so the raw sysfs
> > > value is expected to be the signed result. Sign-extend the masked value
> > > from the resolution bit for differential channels before returning it.
> > > Single-ended channels are unipolar (sign = 'u') and are left unchanged.  
> >
> > Same here.
> >  
> > > Fixes: 168c9d95a940 ("iio:adc:max1363 move from staging.")  
> >
> > This is a wrong reference in case the driver existed before (and that
> > is suggested by the commit description).
> >
> > --
> > With Best Regards,
> > Andy Shevchenko  
> 
> Right, the bug predates the move. The driver was added in 2010 by
> d1325cf45077 ("Staging: IIO: max1363 ADC driver"), which already reads
> differential channels with an unsigned mask, so v2 uses that as the
> Fixes: tag.

Trivial thing to watch out for - don't put anything a thread that
smells like a tag.  b4 tends to scrape them and if I'm not paying
attention (or like in this case my git hooks catch it) we end up
with bonus tags.


> Thanks for the review.
> Cong


      reply	other threads:[~2026-08-17  1:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  6:42 [PATCH] iio: adc: max1363: sign-extend bipolar differential channel reads Cong Nguyen
2026-08-10  6:45 ` Andy Shevchenko
2026-08-10 16:50   ` Nguyễn Công
2026-08-17  1:01     ` 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=20260817020154.343c5080@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=congnt264@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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