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]
Message-ID: <20190324171242.67d7a486@archlinux>
Date:   Sun, 24 Mar 2019 17:12:42 +0000
From:   Jonathan Cameron <jic23@...nel.org>
To:     Fabrice Gasnier <fabrice.gasnier@...com>
Cc:     <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <mcoquelin.stm32@...il.com>,
        <alexandre.torgue@...com>, <linux-iio@...r.kernel.org>,
        <lars@...afoo.de>, <knaack.h@....de>, <pmeerw@...erw.net>,
        <linux-stm32@...md-mailman.stormreply.com>,
        <arnaud.pouliquen@...com>, <olivier.moysan@...com>
Subject: Re: [PATCH v2 8/8] iio: adc: stm32-dfsdm: claim direct mode for raw
 read and settings

On Thu, 21 Mar 2019 17:47:29 +0100
Fabrice Gasnier <fabrice.gasnier@...com> wrote:

> Claim direct mode to ensure no buffer mode is in use for:
> - single conversion
> - sample rate setting (must be set when filter isn't enabled).
> - oversampling ratio (must be set when filter isn't enabled).
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@...com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/stm32-dfsdm-adc.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
> index 51688eb..ca42946 100644
> --- a/drivers/iio/adc/stm32-dfsdm-adc.c
> +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
> @@ -1039,16 +1039,23 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
> +		ret = iio_device_claim_direct_mode(indio_dev);
> +		if (ret)
> +			return ret;
>  		ret = stm32_dfsdm_set_osrs(fl, 0, val);
>  		if (!ret)
>  			adc->oversamp = val;
> -
> +		iio_device_release_direct_mode(indio_dev);
>  		return ret;
>  
>  	case IIO_CHAN_INFO_SAMP_FREQ:
>  		if (!val)
>  			return -EINVAL;
>  
> +		ret = iio_device_claim_direct_mode(indio_dev);
> +		if (ret)
> +			return ret;
> +
>  		switch (ch->src) {
>  		case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL:
>  			spi_freq = adc->dfsdm->spi_master_freq;
> @@ -1070,9 +1077,11 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev,
>  		if (ret < 0) {
>  			dev_err(&indio_dev->dev,
>  				"Not able to find parameter that match!\n");
> +			iio_device_release_direct_mode(indio_dev);
>  			return ret;
>  		}
>  		adc->sample_freq = val;
> +		iio_device_release_direct_mode(indio_dev);
>  
>  		return 0;
>  	}
> @@ -1089,11 +1098,15 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev,
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:
> +		ret = iio_device_claim_direct_mode(indio_dev);
> +		if (ret)
> +			return ret;
>  		ret = iio_hw_consumer_enable(adc->hwc);
>  		if (ret < 0) {
>  			dev_err(&indio_dev->dev,
>  				"%s: IIO enable failed (channel %d)\n",
>  				__func__, chan->channel);
> +			iio_device_release_direct_mode(indio_dev);
>  			return ret;
>  		}
>  		ret = stm32_dfsdm_single_conv(indio_dev, chan, val);
> @@ -1102,8 +1115,10 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev,
>  			dev_err(&indio_dev->dev,
>  				"%s: Conversion failed (channel %d)\n",
>  				__func__, chan->channel);
> +			iio_device_release_direct_mode(indio_dev);
>  			return ret;
>  		}
> +		iio_device_release_direct_mode(indio_dev);
>  		return IIO_VAL_INT;
>  
>  	case IIO_CHAN_INFO_OVERSAMPLING_RATIO:

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ