lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251107220106.ihk6e46paxmyfqgg@antoni-VivoBook-ASUSLaptop-X512FAY-K512FA>
Date: Fri, 7 Nov 2025 23:01:06 +0100
From: Antoni Pokusinski <apokusinski01@...il.com>
To: Marcelo Schmitt <marcelo.schmitt1@...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

On Thu, Nov 06, 2025 at 10:55:01PM -0300, Marcelo Schmitt wrote:
> Hi Antoni,
> 
> v3 looks mostly good to me.
> A couple of minor suggestions in addition to Andy's.
> 
> On 11/05, Antoni Pokusinski wrote:
> > +
> > +static int mpl3115_write_thresh(struct iio_dev *indio_dev,
> > +				const struct iio_chan_spec *chan,
> > +				enum iio_event_type type,
> > +				enum iio_event_direction dir,
> > +				enum iio_event_info info,
> > +				int val, int val2)
> > +{
> > +	struct mpl3115_data *data = iio_priv(indio_dev);
> > +	__be16 tmp;
> > +
> > +	if (info != IIO_EV_INFO_VALUE)
> > +		return -EINVAL;
> > +
> > +	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"

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ