mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Arnav Kapoor" <kapoorarnav43@gmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Gwendal Grignou" <gwendal@chromium.org>,
	"Stephen Boyd" <swboyd@chromium.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/6] iio: proximity: sx9324: reject negative hysteresis values
Date: Sat, 28 Nov 2026 23:45:58 +0000	[thread overview]
Message-ID: <20261128234558.280961b6@jic23-hlaptop> (raw)
In-Reply-To: <awQg6X1ay0zyyyaf@ashevche-desk.local>

On Mon, 23 Nov 2026 13:18:01 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, Nov 23, 2026 at 01:15:42PM +0200, Andy Shevchenko wrote:
> > On Sun, Nov 22, 2026 at 01:16:43PM +0530, Arnav Kapoor wrote:  
> 
> ...
> 
> > >  static int sx9324_write_hysteresis(struct sx_common_data *data,
> > >  				   const struct iio_chan_spec *chan, int _val)
> > >  {
> > > -	unsigned int hyst, val = _val;
> > > +	unsigned int hyst, val;
> > >  	int ret, pthresh;
> > >  
> > > +	if (_val < 0)
> > > +		return -EINVAL;
> > > +
> > > +	val = _val;  
> > 
> > You can validate assigned value instead as there are no side-effects.
> > But while I wrote it, I have noticed that there is actually one, we
> > modify the sign of the value. With that in mind maybe better to have
> > 
> > 	/*
> > 	 * Assume only positive input, negative, after conversion to unsigned
> > 	 * is unsupported. // or something like this
> > 	 */
> > 	val = _val;
> > 	if (val > INT_MAX)
> > 		return -EINVAL;  
> 
> On the second thought, the original < 0 check might be cleaner... Dunno.
> Jonathan, what do you think?
I think the < 0 is indeed cleaner. Hopefully that is what is in v3!

This series lost under my usual approach of working backwards through
my inbox whenever I get time to do IIO review!  Sorry for delay.
> 


  parent reply	other threads:[~2026-11-28 23:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  7:46 [PATCH v2 0/6] iio: proximity: sx93xx: fix raw reads, thresholds, hysteresis and gain Arnav Kapoor
2026-11-22  7:46 ` [PATCH v2 1/6] iio: proximity: sx_common: fix raw reads while the trigger is in use Arnav Kapoor
2026-11-22  7:46 ` [PATCH v2 2/6] iio: proximity: sx9324: fix proximity threshold writes Arnav Kapoor
2026-11-23 11:11   ` Andy Shevchenko
2026-11-23 11:16     ` Andy Shevchenko
2026-11-23 13:17     ` Arnav Kapoor
2026-11-22  7:46 ` [PATCH v2 3/6] iio: proximity: sx9324: reject negative hysteresis values Arnav Kapoor
2026-11-23 11:15   ` Andy Shevchenko
2026-11-23 11:18     ` Andy Shevchenko
2026-11-23 13:17       ` Arnav Kapoor
2026-11-28 23:45       ` Jonathan Cameron [this message]
2026-11-22  7:46 ` [PATCH v2 4/6] iio: proximity: sx9360: fix hardware gain encoding Arnav Kapoor
2026-11-22  7:46 ` [PATCH v2 5/6] iio: proximity: sx9360: fix proximity threshold writes Arnav Kapoor
2026-11-22  7:46 ` [PATCH v2 6/6] iio: proximity: sx9360: reject negative hysteresis values Arnav Kapoor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128234558.280961b6@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=gwendal@chromium.org \
    --cc=kapoorarnav43@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=swboyd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®