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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aSl3pFfXhNVFbjxX@smile.fi.intel.com>
Date: Fri, 28 Nov 2025 12:21:24 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Kurt Borja <kuurtb@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>, Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Tobias Sperling <tobias.sperling@...ting.com>,
	David Lechner <dlechner@...libre.com>,
	Nuno Sá <nuno.sa@...log.com>,
	Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v2 2/2] iio: adc: Add ti-ads1018 driver

On Fri, Nov 28, 2025 at 11:54:18AM +0200, Andy Shevchenko wrote:
> On Thu, Nov 27, 2025 at 10:37:11PM -0500, Kurt Borja wrote:

...

> 		for (unsigned int i = 0; i < info->num_pga_mode_to_gain; i++) {
> 			if (val == info->pga_mode_to_gain[i][0] ||
> 			    val2 == info->pga_mode_to_gain[i][1])
> 				break;
> 		}
> 		if (i == info->num_pga_mode_to_gain)
> 			return -EINVAL;
> 
> 		ads1018_set_pga_mode(ads1018, chan->scan_index, i);
> 		return 0;
> 
> This also will follow the traditional pattern: Check for the error cases first.

Just noticed that in this case the scope of iterator should be out of the loop.
Since you have it used more than once, move it to the top of the function.

> > +	case IIO_CHAN_INFO_SAMP_FREQ:
> > +		for (int i = 0; i < info->num_data_rate_mode_to_hz; i++) {
> 
> Ditto, same comments as per previous loop.
> 
> > +			if (val != info->data_rate_mode_to_hz[i])
> > +				continue;
> > +
> > +			ads1018_set_data_rate_mode(ads1018, chan->scan_index, i);
> > +			return 0;
> > +		}
> > +
> > +		return -EINVAL;

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ