[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRC7EPHXEtcwkGak@smile.fi.intel.com>
Date: Sun, 9 Nov 2025 18:02:24 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Marcelo Schmitt <marcelo.schmitt1@...il.com>
Cc: Antoni Pokusinski <apokusinski01@...il.com>, jic23@...nel.org,
dlechner@...libre.com, nuno.sa@...log.com, andy@...nel.org,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/3] iio: mpl3115: add threshold events support
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
Powered by blists - more mailing lists