lkml.org 
[lkml]   [2023]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 5/9] iio: inkern: Add a helper to query an available minimum raw value
On Mon, Jun 5, 2023 at 10:46 AM Herve Codina <herve.codina@bootlin.com> wrote:
> On Sat, 3 Jun 2023 17:04:37 +0300
> andy.shevchenko@gmail.com wrote:
> > Tue, May 23, 2023 at 05:12:19PM +0200, Herve Codina kirjoitti:

...

> > > + case IIO_VAL_INT:
> > > + *val = vals[--length];
> >
> > > + while (length) {
> >
> > while (length--) {
> >
> > will do the job and at the same time...
> >
> > > + if (vals[--length] < *val)
> > > + *val = vals[length];
> >
> > ...this construction becomes less confusing (easier to parse).
>
> Indeed, I will change in the next iteration.

And looking into above line, this whole construction I would prefer to
have a macro in minmax.h like

#define min_array(array, len) \
{( \
typeof(len) __len = (len); \
typeof(*(array)) __element = (array)[--__len]; \
while (__len--) \
__element = min(__element, (array)[__len]); \
__element; \
)}

(it might need more work, but you got the idea)

> > > + }
> > > + break;

...

> > > + default:
> > > + /* FIXME: learn about min for other iio values */
> >
> > I believe in a final version this comment won't be here.
>
> We have the same FIXME comment in the iio_channel_read_max() function I
> copied to create this iio_channel_read_min() and, to be honest, I
> don't really know how to handle these other cases.
>
> In this series, I would prefer to keep this FIXME.

I see, Jonathan needs to be involved here then.

> > > + return -EINVAL;

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2023-06-05 11:46    [W:0.084 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site