Re: [PATCH v3 5/6] iio: imu: Add support for adis16475

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

 



On Wed, Apr 1, 2020 at 4:27 PM Sa, Nuno <Nuno.Sa@xxxxxxxxxx> wrote:
> > On Wed, Apr 1, 2020 at 10:13 AM Sa, Nuno <Nuno.Sa@xxxxxxxxxx> wrote:
> > > > On Tue, Mar 31, 2020 at 2:49 PM Nuno Sá <nuno.sa@xxxxxxxxxx> wrote:

...

> > > > > +       for (i = ARRAY_SIZE(adis16475_3db_freqs) - 2; i >= 1; i--) {
> > > >
> > > > Why those margins? size-2 and 1 ?
> > > >
> > >
> > > The -2 is needed since index 7 is not valid. The 1 I honestly don't remember
> > why I did it
> > > like this. Using > 0 is the same and more "common"...
> >
> > More common is >= 0. That's my question basically.
> > And if 7 is not valid why to keep it in the array at all?
>
> Well, I can remove the 7. I honestly took it from another driver and I guess the idea
> is to make explicit that 7 is not supported. Since this is a 3 bit field and the datasheet
> does not state this directly.
>
> As for the >=0, I prefer to have either as is or >0 since we don't really need to check the
> index 0. If 1 fails, then we will use 0 either way...

It makes sense to check to get better optimization (and increased readability).
Look for this

i = ARRAY_SIZE(...);

while (i--) {
 ...
}

It's much better to read and understand.

> > > > > +               if (adis16475_3db_freqs[i] >= filter)
> > > > > +                       break;
> > > > > +       }

-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux