Re: [PATCH RFC v6 10/10] iio: adc: ad7380: add support for resolution boost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 6, 2024 at 3:55 AM Nuno Sá <noname.nuno@xxxxxxxxx> 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.





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux