[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMknhBEnJXCRGEUE+7VTfve6aPWZiandvE5xX4FPo17pqhmEeQ@mail.gmail.com>
Date: Mon, 6 May 2024 10:09:11 -0500
From: David Lechner <dlechner@...libre.com>
To: Nuno Sá <noname.nuno@...il.com>
Cc: Julien Stephan <jstephan@...libre.com>, Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>, Nuno Sá <nuno.sa@...log.com>,
Jonathan Cameron <jic23@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
kernel test robot <lkp@...el.com>, linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC v6 10/10] iio: adc: ad7380: add support for resolution boost
On Mon, May 6, 2024 at 3:55 AM Nuno Sá <noname.nuno@...il.com> wrote:
>
> On Wed, 2024-05-01 at 16:55 +0200, Julien Stephan wrote:
..
> > + /*
> > + * If bits_per_word == realbits (resolution boost enabled), we don't
> > + * need to manipulate the raw data, otherwise we may need to fix things
> > + * up a bit to fit the scan_type specs
> > + */
> > + if (bits_per_word < realbits) {
> > + if (realbits > 16 && bits_per_word <= 16) {
> > + /*
> > + * Here realbits > 16 so storagebits is 32 and
> > bits_per_word is <= 16
> > + * so we need to sign extend u16 to u32 using reverse
> > order to
> > + * avoid writing over union data
> > + */
> > + for (i = st->chip_info->num_channels - 2; i >= 0; i--)
> > + st->scan_data.raw.u32[i] = sign_extend32(st-
> > >scan_data.raw.u16[i],
> > +
> > bits_per_word - 1);
> > + } else if (bits_per_word < 16) {
>
> Can't we have bits_per_word = 16 in case realbits <= 16?
>
This case is handled by the outermost if, so can't have that here. (In
that case, no manipulation is required so the whole big if statement
is skipped). realbits will never be < bits_per_word.
Powered by blists - more mailing lists