Re: [PATCH v3 2/3] iio: mpl3115: add threshold events support
From: Andy Shevchenko
Date: Sun Nov 09 2025 - 11:02:40 EST
On Sat, Nov 08, 2025 at 04:05:34PM -0300, Marcelo Schmitt wrote:
...
> > > > + if (val < 0 || val > U16_MAX)
> > > Alternatively, could use in_range() for the check.
> > >
> > > > + return -EINVAL;
,,,
> > > > + if (val < S8_MIN || val > S8_MAX)
> > > this could also use in_range().
> > >
> > > If you opt for the macro,
> > > #include <linux/minmax.h>
> > >
> > I see that the in_range() macro operates only on unsigned values, so
> > placing it here would be wrong I guess. In order to keep the style
> > consistenc in this function, I'd keep both checks as "val < x || val > y"
> >
> Ah, good point. Okay, no objection.
Actually we need something like in_the_range() or so which takes the min/max pair instead of start-end. And make it work for any signdness.
> > > > + return -EINVAL;
--
With Best Regards,
Andy Shevchenko