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] [day] [month] [year] [list]
Date: Tue, 11 Jun 2024 18:29:10 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: João Paulo Gonçalves
	<jpaulo.silvagoncalves@...il.com>
CC: Jonathan Cameron <jic23@...nel.org>, Francesco Dolcini
	<francesco@...cini.it>, Lars-Peter Clausen <lars@...afoo.de>, Liam Girdwood
	<lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>, João Paulo Gonçalves
	<joao.goncalves@...adex.com>, <linux-kernel@...r.kernel.org>,
	<linux-iio@...r.kernel.org>, Francesco Dolcini
	<francesco.dolcini@...adex.com>
Subject: Re: [PATCH v2 2/2] iio: adc: ti-ads1119: Add driver

On Mon, 10 Jun 2024 10:26:29 -0300
João Paulo Gonçalves <jpaulo.silvagoncalves@...il.com> wrote:

> Hi Jonathan,
> 
> Thanks for the review!
> 
> > > +
> > > +static int ads1119_validate_gain(struct ads1119_state *st, int scale, int uscale)
> > > +{
> > > +	int gain = 1000000 / ((scale * 1000000) + uscale);
> > > +
> > > +	switch (gain) {
> > > +	case 1:
> > > +	case 4:
> > > +		return gain;  
> > Odd to calculate it if we don't need it
> > 		return MICRO / (scale * MICRO + uscale);
> > use constants as it's easy to drop a 0 in these without anyone noticing.
> >  
> > > +	default:
> > > +		return -EINVAL;
> > > +	}
> > > +}
> > > +  
> 
> Just a minor. I do use the calculated value on write_raw() by storing it as the
> new channel gain and would still need to validate it as scale/uscale comes from
> userspace. Maybe I can just remove the validate_gain function and do the check
> directly on write_raw(). What do you think?

If that's the only caller, sure, move it to write raw.

Jonathan

> 
> Regards,
> João Paulo Gonçalves
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ