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] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 12 Nov 2022 17:33:30 +0000
From:   Jonathan Cameron <jic23@...nel.org>
To:     Mitja Spes <mitja@...av.com>
Cc:     Lars-Peter Clausen <lars@...afoo.de>,
        Angelo Compagnucci <angelo.compagnucci@...il.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] iio: adc: mcp3422: reduce sleep for fast sampling
 rates

On Fri, 11 Nov 2022 12:26:56 +0100
Mitja Spes <mitja@...av.com> wrote:

> - reduced sleep time for 240 & 60 sps rates
> - minor roundup fix for sleep times
> 
> Signed-off-by: Mitja Spes <mitja@...av.com>
This patch looks fine to me.

Jonathan

> ---
>  drivers/iio/adc/mcp3422.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
> index eef35fb2fc22..dbcc8fe91aaa 100644
> --- a/drivers/iio/adc/mcp3422.c
> +++ b/drivers/iio/adc/mcp3422.c
> @@ -70,10 +70,11 @@ static const int mcp3422_scales[MCP3422_SRATE_COUNT][MCP3422_PGA_COUNT] = {
>  
>  /* Constant msleep times for data acquisitions */
>  static const int mcp3422_read_times[MCP3422_SRATE_COUNT] = {
> -	[MCP3422_SRATE_240] = 1000 / 240,
> -	[MCP3422_SRATE_60] = 1000 / 60,
> -	[MCP3422_SRATE_15] = 1000 / 15,
> -	[MCP3422_SRATE_3] = 1000 / 3 };
> +	[MCP3422_SRATE_240] = DIV_ROUND_UP(1000, 240),
> +	[MCP3422_SRATE_60] = DIV_ROUND_UP(1000, 60),
> +	[MCP3422_SRATE_15] = DIV_ROUND_UP(1000, 15),
> +	[MCP3422_SRATE_3] = (100000 + 375 - 100) / 375 /* real rate is 3.75 sps */
> +};
>  
>  /* sample rates to integer conversion table */
>  static const int mcp3422_sample_rates[MCP3422_SRATE_COUNT] = {
> @@ -137,6 +138,7 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
>  				struct iio_chan_spec const *channel, int *value)
>  {
>  	int ret;
> +	int sleep_duration;
>  	u8 config;
>  	u8 req_channel = channel->channel;
>  
> @@ -148,7 +150,11 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
>  			mutex_unlock(&adc->lock);
>  			return ret;
>  		}
> -		msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->active_config)]);
> +		sleep_duration = mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->active_config)];
> +		if (sleep_duration < 20)
> +			usleep_range(sleep_duration * 1000, sleep_duration * 1300);
> +		else
> +			msleep(sleep_duration);
>  	}
>  
>  	ret = mcp3422_read(adc, value, &config);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ