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

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

 



> From: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
> Sent: Mittwoch, 1. April 2020 16:06
> To: Sa, Nuno <Nuno.Sa@xxxxxxxxxx>
> Cc: linux-iio <linux-iio@xxxxxxxxxxxxxxx>; devicetree
> <devicetree@xxxxxxxxxxxxxxx>; Jonathan Cameron <jic23@xxxxxxxxxx>;
> Hartmut Knaack <knaack.h@xxxxxx>; Lars-Peter Clausen <lars@xxxxxxxxxx>;
> Peter Meerwald-Stadler <pmeerw@xxxxxxxxxx>; Rob Herring
> <robh+dt@xxxxxxxxxx>; Mark Rutland <mark.rutland@xxxxxxx>; Ardelean,
> Alexandru <alexandru.Ardelean@xxxxxxxxxx>; Hennerich, Michael
> <Michael.Hennerich@xxxxxxxxxx>
> Subject: Re: [PATCH v3 5/6] iio: imu: Add support for adis16475
> 
> 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.

Well, about the readability it's a bit subjective 😊. It depends who is
reading the code. Just curious, how would you get better optimization
by doing >=0 instead of > 0?

Either way, I don’t have any strong feeling about this so I can do as
you suggest.

- Nuno Sá
> > > > > > +               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