Re: [PATCH 6/7] iio: adc: ad485x: add ad485x driver

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

 



On Thu, Sep 26, 2024 at 04:39:18PM +0200, David Lechner wrote:
> On Mon, Sep 23, 2024 at 12:17 PM Antoniu Miclaus
> <antoniu.miclaus@xxxxxxxxxx> wrote:

...

> > +static int ad485x_find_opt(bool *field, u32 size, u32 *ret_start)
> > +{
> > +       int i, cnt = 0, max_cnt = 0, start, max_start = 0;
> > +
> > +       for (i = 0, start = -1; i < size; i++) {
> > +               if (field[i] == 0) {
> > +                       if (start == -1)
> > +                               start = i;
> > +                       cnt++;
> > +               } else {
> > +                       if (cnt > max_cnt) {
> > +                               max_cnt = cnt;
> > +                               max_start = start;
> > +                       }
> > +                       start = -1;
> > +                       cnt = 0;
> > +               }
> > +       }
> > +
> > +       if (cnt > max_cnt) {
> > +               max_cnt = cnt;
> > +               max_start = start;
> > +       }
> > +
> > +       if (!max_cnt)
> > +               return -EIO;
> 
> EIO seems an odd choice since this function doesn't actually do any
> I/O. Maybe EINVAL would be better?

I would even go with -ENOENT as function called 'find'.

> > +       *ret_start = max_start;
> > +
> > +       return max_cnt;
> > +}

-- 
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