All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Jakub Szczudlo <jakubszczudlo40@gmail.com>,
	linux-iio@vger.kernel.org, andy@kernel.org,
	antoniu.miclaus@analog.com, conor+dt@kernel.org,
	devicetree@vger.kernel.org, dlechner@baylibre.com,
	duje@dujemihanovic.xyz, jishnu.prakash@oss.qualcomm.com,
	jorge.marques@analog.com, joshua.crofts1@gmail.com,
	krzk+dt@kernel.org, linusw@kernel.org,
	linux-kernel@vger.kernel.org, marcelo.schmitt@analog.com,
	mazziesaccount@gmail.com, mike.looijmans@topic.nl,
	nuno.sa@analog.com, robh@kernel.org,
	sakari.ailus@linux.intel.com, wens@kernel.org
Subject: Re: [PATCH v4 1/3] iio: adc: Fix incorrect reading when datarate changed in single mode
Date: Tue, 30 Jun 2026 14:36:01 +0300	[thread overview]
Message-ID: <akOqIVDibovrbBAK@ashevche-desk.local> (raw)
In-Reply-To: <20260629235118.1abc4067@jic23-huawei>

On Mon, Jun 29, 2026 at 11:51:18PM +0100, Jonathan Cameron wrote:

...

> > >  	size = data->supports_data_rate ? ARRAY_SIZE(ads1100_data_rate) : 1;
> > >  	for (i = 0; i < size; i++) {
> > > -		if (ads1100_data_rate[i] == rate)
> > > -			return ads1100_set_config_bits(data, ADS1100_DR_MASK,
> > > -						       FIELD_PREP(ADS1100_DR_MASK, i));  
> > 
> > > +		if (ads1100_data_rate[i] != rate)
> > > +			continue;  
> > 
> > This will look better if you break here and add a check
> > 
> > 	if (i == size)
> > 		return -EINVAL;
> I just saw the result of this in v5 and wondered why?
> 
> i is controlled by the for loops stuff only so i never == size.
> I'm not sure what intent of this comment was.

Meant to add 'break;' and move the actual check to outside of the loop.

> I am fairly sure what Andy is suggesting is the following..
> 
>  	for (i = 0; i < size; i++) {
> 		if (ads1100_data_rate[i] == rate)
> 			break;
> 	}
> 
> 	if (i == size)
> 		return -EINVAL;

Yes, that one. Sorry for the language confusion.

> 	PM_RUNTIME_ACQUIRE_AUTOSUSPEND(&data->client->dev, pm);
> 	ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> 	if (ret)
> 		return ret;

> //note that we 'could' do what some other users of ACQUIRE_ERR()
> //have allowed
> 	if ((ret = PM_RUNTIME_ACQUIRE_ERR(&pm)))
> 		return ret;
> 
> I'm open to hear if people think we should allow this or not.

I'm against that. The style is prone for errors and readability issues.

> 	ret = ads1100_set_config_bits(data, ADS1100_DR_MASK,
> 				      FIELD_PREP(ADS1100_DR_MASK, i));
> 	if (ret)
> 		return ret;
> 
> 	return ads1100_poll_data_ready(data);
> }

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-06-30 11:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 22:15 [PATCH v4 0/3] iio: adc: Add support for TI ADS1110 to ti-ads1100 driver Jakub Szczudlo
2026-06-22 22:15 ` [PATCH v4 1/3] iio: adc: Fix incorrect reading when datarate changed in single mode Jakub Szczudlo
2026-06-22 22:33   ` sashiko-bot
2026-06-23  9:16   ` Andy Shevchenko
2026-06-23  9:29     ` Joshua Crofts
2026-06-23  9:39       ` Andy Shevchenko
2026-06-29 18:28         ` Jonathan Cameron
2026-06-29 22:51     ` Jonathan Cameron
2026-06-30 11:36       ` Andy Shevchenko [this message]
2026-06-30 12:08         ` Matti Vaittinen
2026-06-30 12:28           ` Andy Shevchenko
2026-06-30 17:01             ` Jakub Szczudło
2026-06-27 22:31   ` David Lechner
2026-06-29 18:33     ` Jonathan Cameron
2026-06-29 18:55       ` David Lechner
2026-06-22 22:15 ` [PATCH v4 2/3] dt-bindings: iio: adc: ti,ads1100: add support for ADS1110 Jakub Szczudlo
2026-06-22 22:15 ` [PATCH v4 3/3] iio: adc: Add ti-ads1110 support to ti-ads1100 driver Jakub Szczudlo
2026-06-22 22:31   ` sashiko-bot
2026-06-23  9:23   ` Andy Shevchenko
2026-06-23 18:49     ` Jakub Szczudło
2026-06-27 22:42   ` David Lechner

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=akOqIVDibovrbBAK@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=duje@dujemihanovic.xyz \
    --cc=jakubszczudlo40@gmail.com \
    --cc=jic23@kernel.org \
    --cc=jishnu.prakash@oss.qualcomm.com \
    --cc=jorge.marques@analog.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=mazziesaccount@gmail.com \
    --cc=mike.looijmans@topic.nl \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=wens@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.