[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aQ-UfmTkRX75BOfg@debian-BULLSEYE-live-builder-AMD64>
Date: Sat, 8 Nov 2025 16:05:34 -0300
From: Marcelo Schmitt <marcelo.schmitt1@...il.com>
To: Antoni Pokusinski <apokusinski01@...il.com>
Cc: 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
...
> > > + switch (chan->type) {
> > > + case IIO_PRESSURE:
> > > + val >>= 1;
> > > +
> > > + if (val < 0 || val > U16_MAX)
> > Alternatively, could use in_range() for the check.
> >
> > > + return -EINVAL;
> > > +
> > > + tmp = cpu_to_be16(val);
> > > +
> > > + return i2c_smbus_write_i2c_block_data(data->client,
> > > + MPL3115_PRESS_TGT,
> > > + sizeof(tmp), (u8 *)&tmp);
> > > + case IIO_TEMP:
> > > + 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.
> > > + return -EINVAL;
> > > +
> > > + return i2c_smbus_write_byte_data(data->client,
> > > + MPL3115_TEMP_TGT, val);
> > > + default:
> > > + return -EINVAL;
> > > + }
> > > +}
> > > +
> Kind regards,
> Antoni Pokusinski
>
Powered by blists - more mailing lists