Re: [PATCH v3 8/8] iio: magnetometer: yas530: Add YAS537 variant

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

 



On Sun, 19 Jun 2022 12:32:56 +0200
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:

> On Sat, Jun 18, 2022 at 5:19 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
> > On Sat, 18 Jun 2022 02:13:16 +0200
> > Jakob Hauser <jahau@xxxxxxxxxxxxxx> wrote:  
> 
> ...
> 
> > > +             for (i = 0; i < 17; i++) {  
> >
> > Reduce indent by doing this as multiple loops.
> > Though even better if you can use bulk writes.
> >
> >                 int j = 0;
> >                 for (i = 0; i < 12; i++) {
> >                         ret = regmap_write(yas5xx->map, YAS537_MTC + i,
> >                                            data[j++])
> >                         if (ret)
> >                                 return ret;
> >                 }
> >
> >                 for (i = 0; i < 4; i++) {
> >                         ret = regmap_write(yas5xx->map, YAS573_OFFSET_X + i,
> >                                            data[j++]);
> >                         if (ret)
> >                                 return ret;
> >                 }  
> 
> I guess you are referring to _noinc variants of regmap bulk operations.
Hi Andy,

No. These seem to be incrementing the register address, so you don't want the _noinc
variant as far as I can see.

> 
> > > +                     if (i < 12) {
> > > +                             ret = regmap_write(yas5xx->map,
> > > +                                                YAS537_MTC + i,
> > > +                                                data[i]);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +                     } else if (i < 15) {
> > > +                             ret = regmap_write(yas5xx->map,
> > > +                                                YAS537_OFFSET_X + i - 12,
> > > +                                                data[i]);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +                             yas5xx->hard_offsets[i - 12] = data[i];
> > > +                     } else {
> > > +                             ret = regmap_write(yas5xx->map,
> > > +                                                YAS537_HCK + i - 15,
> > > +                                                data[i]);
> > > +                             if (ret)
> > > +                                     return ret;
> > > +                     }
> > > +             }  
> 




[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