[v2,5/8] iio: adc: stm32-dfsdm: enable hw consumer
diff mbox series

Message ID 1553186849-6261-6-git-send-email-fabrice.gasnier@st.com
State New
Headers show
Series
  • iio: adc: stm32-dfsdm: add buffer modes
Related show

Commit Message

Fabrice Gasnier March 21, 2019, 4:47 p.m. UTC
Optionally enable IIO hw consumer, when provided (e.g. for DFSDM_IIO type).
This is precursor patch to introduce buffer modes.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 drivers/iio/adc/stm32-dfsdm-adc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron March 24, 2019, 4:45 p.m. UTC | #1
On Thu, 21 Mar 2019 17:47:26 +0100
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:

> Optionally enable IIO hw consumer, when provided (e.g. for DFSDM_IIO type).
> This is precursor patch to introduce buffer modes.
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied, 
Thanks,

Jonathan
> ---
>  drivers/iio/adc/stm32-dfsdm-adc.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
> index 66e2ea0..b491424 100644
> --- a/drivers/iio/adc/stm32-dfsdm-adc.c
> +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
> @@ -630,9 +630,15 @@ static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
>  	/* Reset adc buffer index */
>  	adc->bufi = 0;
>  
> +	if (adc->hwc) {
> +		ret = iio_hw_consumer_enable(adc->hwc);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
>  	ret = stm32_dfsdm_start_dfsdm(adc->dfsdm);
>  	if (ret < 0)
> -		return ret;
> +		goto err_stop_hwc;
>  
>  	ret = stm32_dfsdm_adc_dma_start(indio_dev);
>  	if (ret) {
> @@ -652,6 +658,9 @@ static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
>  	stm32_dfsdm_adc_dma_stop(indio_dev);
>  stop_dfsdm:
>  	stm32_dfsdm_stop_dfsdm(adc->dfsdm);
> +err_stop_hwc:
> +	if (adc->hwc)
> +		iio_hw_consumer_disable(adc->hwc);
>  
>  	return ret;
>  }
> @@ -667,6 +676,9 @@ static int stm32_dfsdm_predisable(struct iio_dev *indio_dev)
>  
>  	stm32_dfsdm_stop_dfsdm(adc->dfsdm);
>  
> +	if (adc->hwc)
> +		iio_hw_consumer_disable(adc->hwc);
> +
>  	return 0;
>  }
>

Patch
diff mbox series

diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index 66e2ea0..b491424 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -630,9 +630,15 @@  static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
 	/* Reset adc buffer index */
 	adc->bufi = 0;
 
+	if (adc->hwc) {
+		ret = iio_hw_consumer_enable(adc->hwc);
+		if (ret < 0)
+			return ret;
+	}
+
 	ret = stm32_dfsdm_start_dfsdm(adc->dfsdm);
 	if (ret < 0)
-		return ret;
+		goto err_stop_hwc;
 
 	ret = stm32_dfsdm_adc_dma_start(indio_dev);
 	if (ret) {
@@ -652,6 +658,9 @@  static int stm32_dfsdm_postenable(struct iio_dev *indio_dev)
 	stm32_dfsdm_adc_dma_stop(indio_dev);
 stop_dfsdm:
 	stm32_dfsdm_stop_dfsdm(adc->dfsdm);
+err_stop_hwc:
+	if (adc->hwc)
+		iio_hw_consumer_disable(adc->hwc);
 
 	return ret;
 }
@@ -667,6 +676,9 @@  static int stm32_dfsdm_predisable(struct iio_dev *indio_dev)
 
 	stm32_dfsdm_stop_dfsdm(adc->dfsdm);
 
+	if (adc->hwc)
+		iio_hw_consumer_disable(adc->hwc);
+
 	return 0;
 }