Re: [PATCH v2] iio: adc: max1363: sign-extend bipolar differential channel reads

From: Jonathan Cameron

Date: Sun Aug 16 2026 - 21:03:48 EST


On Mon, 10 Aug 2026 20:04:23 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:

> On Mon, Aug 10, 2026 at 11:44:46PM +0700, Cong Nguyen wrote:
> > MAX1363 differential channels are bipolar (scan_type.sign = 's'), but
>
> The (...) can also be dropped, but I leave that to Jonathan, no need to resend.
>
> > max1363_read_single_chan() masks the raw value to the ADC resolution
> > without sign-extending it. Negative differential readings are therefore
> > reported to userspace as large positive values (e.g. -1 as 4095 on a
> > 12-bit part).
> >
> > Sign-extend the masked value from the resolution bit for differential
> > channels. Single-ended channels are unipolar and are left unchanged.
>
> Now looks good to me,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>

Applied. Amazing that's sat there for so long given it is
a reasonably common part. Oops - that younger me wrote just
as many bugs as the current version ;)

On the fixes-togreg branch but unlikely I'll do a pull request
until I've rebased that on 7.3-rc1 in a few weeks time.

Jonathan

>