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:   Sun, 12 Mar 2023 14:57:47 +0000
From:   Jonathan Cameron <jic23@...nel.org>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Mike Looijmans <mike.looijmans@...ic.nl>,
        devicetree@...r.kernel.org, linux-iio@...r.kernel.org,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        Caleb Connolly <caleb.connolly@...aro.org>,
        ChiYuan Huang <cy_huang@...htek.com>,
        ChiaEn Wu <chiaen_wu@...htek.com>,
        Cosmin Tanislav <demonsingur@...il.com>,
        Ibrahim Tilki <Ibrahim.Tilki@...log.com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Marcus Folkesson <marcus.folkesson@...il.com>,
        Ramona Bolboaca <ramona.bolboaca@...log.com>,
        William Breathitt Gray <william.gray@...aro.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 2/2] iio: adc: Add TI ADS1100 and ADS1000

On Tue, 7 Mar 2023 14:24:44 +0200
Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:

> On Tue, Mar 07, 2023 at 07:55:34AM +0100, Mike Looijmans wrote:
> > The ADS1100 is a 16-bit ADC (at 8 samples per second).
> > The ADS1000 is similar, but has a fixed data rate.  
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> 
> But see below.

I tidied that up and made a few other trivial whitespace tweaks whilst
applying.

Applied to the togreg branch of iio.git and pushed out as testing for 0-day
to see if it can find anything we missed.

Thanks,

Jonathan

> 
> > Signed-off-by: Mike Looijmans <mike.looijmans@...ic.nl>

> > +
> > +static int ads1100_set_scale(struct ads1100_data *data, int val, int val2)
> > +{
> > +	int microvolts;
> > +	int gain;
> > +
> > +	/* With Vdd between 2.7 and 5V, the scale is always below 1 */
> > +	if (val)
> > +		return -EINVAL;
> > +
> > +	if (!val2)
> > +		return -EINVAL;
> > +
> > +	microvolts = regulator_get_voltage(data->reg_vdd);
> > +	/*
> > +	 * val2 is in 'micro' units, n = val2 / 1000000
> > +	 * result must be millivolts, d = microvolts / 1000
> > +	 * the full-scale value is d/n, corresponds to 2^15,
> > +	 * hence the gain = (d / n) >> 15, factoring out the 1000 and moving the
> > +	 * bitshift so everything fits in 32-bits yields this formula.
> > +	 */
> > +	gain = DIV_ROUND_CLOSEST(microvolts, BIT(15)) * MILLI / val2;
> > +	if (gain < BIT(0) || gain > BIT(3))
> > +		return -EINVAL;
> > +
> > +	ads1100_set_config_bits(data, ADS1100_PGA_MASK, ffs(gain) - 1);

I added a blank line here and in one other place for consistency + I like
them before simple return statements.

> > +	return 0;
> > +}
> > +
> > +static int ads1100_set_data_rate(struct ads1100_data *data, int chan, int rate)
> > +{
> > +	unsigned int i;
> > +	unsigned int size;
> > +
> > +	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));  
> 
> This is better on a single line.

Fixed up whilst applying.

> 
> > +	}
> > +
> > +	return -EINVAL;
> > +}
> > +


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ