Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] iio: pressure: zpa2326: fix iio_triggered_buffer_postenable position
@ 2019-09-20  8:03 Alexandru Ardelean
  2019-10-05 15:14 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Ardelean @ 2019-09-20  8:03 UTC (permalink / raw)
  To: linux-iio; +Cc: gregor.boirie, jic23, Alexandru Ardelean

The iio_triggered_buffer_{predisable,postenable} functions attach/detach
the poll functions.

The iio_triggered_buffer_postenable() should be called before (to attach
the poll func) and then the

The iio_triggered_buffer_predisable() function is hooked directly without
anything, which is probably fine, as the postenable() version seems to also
do some reset/wake-up of the device.
This will mean it will be easier when removing it; i.e. it just gets
removed.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/pressure/zpa2326.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
index 9d0d07930236..99dfe33ee402 100644
--- a/drivers/iio/pressure/zpa2326.c
+++ b/drivers/iio/pressure/zpa2326.c
@@ -1243,6 +1243,11 @@ static int zpa2326_postenable_buffer(struct iio_dev *indio_dev)
 	const struct zpa2326_private *priv = iio_priv(indio_dev);
 	int                           err;
 
+	/* Plug our own trigger event handler. */
+	err = iio_triggered_buffer_postenable(indio_dev);
+	if (err)
+		goto err;
+
 	if (!priv->waken) {
 		/*
 		 * We were already power supplied. Just clear hardware FIFO to
@@ -1250,7 +1255,7 @@ static int zpa2326_postenable_buffer(struct iio_dev *indio_dev)
 		 */
 		err = zpa2326_clear_fifo(indio_dev, 0);
 		if (err)
-			goto err;
+			goto err_buffer_predisable;
 	}
 
 	if (!iio_trigger_using_own(indio_dev) && priv->waken) {
@@ -1260,16 +1265,13 @@ static int zpa2326_postenable_buffer(struct iio_dev *indio_dev)
 		 */
 		err = zpa2326_config_oneshot(indio_dev, priv->irq);
 		if (err)
-			goto err;
+			goto err_buffer_predisable;
 	}
 
-	/* Plug our own trigger event handler. */
-	err = iio_triggered_buffer_postenable(indio_dev);
-	if (err)
-		goto err;
-
 	return 0;
 
+err_buffer_predisable:
+	iio_triggered_buffer_predisable(indio_dev);
 err:
 	zpa2326_err(indio_dev, "failed to enable buffering (%d)", err);
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: pressure: zpa2326: fix iio_triggered_buffer_postenable position
  2019-09-20  8:03 [PATCH] iio: pressure: zpa2326: fix iio_triggered_buffer_postenable position Alexandru Ardelean
@ 2019-10-05 15:14 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-10-05 15:14 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-iio, gregor.boirie

On Fri, 20 Sep 2019 11:03:48 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> The iio_triggered_buffer_{predisable,postenable} functions attach/detach
> the poll functions.
> 
> The iio_triggered_buffer_postenable() should be called before (to attach
> the poll func) and then the
> 
> The iio_triggered_buffer_predisable() function is hooked directly without
> anything, which is probably fine, as the postenable() version seems to also
> do some reset/wake-up of the device.
> This will mean it will be easier when removing it; i.e. it just gets
> removed.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Seems straight forward but I've often been wrong before.
Not heard from Gregor for a while, but we should give him a little more
time to spot this one.  If nothing for another week I'll just take a
gamble and apply it.  If I seem to have forgotten any of these give
me a bump.

Thanks,

Jonathan

> ---
>  drivers/iio/pressure/zpa2326.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
> index 9d0d07930236..99dfe33ee402 100644
> --- a/drivers/iio/pressure/zpa2326.c
> +++ b/drivers/iio/pressure/zpa2326.c
> @@ -1243,6 +1243,11 @@ static int zpa2326_postenable_buffer(struct iio_dev *indio_dev)
>  	const struct zpa2326_private *priv = iio_priv(indio_dev);
>  	int                           err;
>  
> +	/* Plug our own trigger event handler. */
> +	err = iio_triggered_buffer_postenable(indio_dev);
> +	if (err)
> +		goto err;
> +
>  	if (!priv->waken) {
>  		/*
>  		 * We were already power supplied. Just clear hardware FIFO to
> @@ -1250,7 +1255,7 @@ static int zpa2326_postenable_buffer(struct iio_dev *indio_dev)
>  		 */
>  		err = zpa2326_clear_fifo(indio_dev, 0);
>  		if (err)
> -			goto err;
> +			goto err_buffer_predisable;
>  	}
>  
>  	if (!iio_trigger_using_own(indio_dev) && priv->waken) {
> @@ -1260,16 +1265,13 @@ static int zpa2326_postenable_buffer(struct iio_dev *indio_dev)
>  		 */
>  		err = zpa2326_config_oneshot(indio_dev, priv->irq);
>  		if (err)
> -			goto err;
> +			goto err_buffer_predisable;
>  	}
>  
> -	/* Plug our own trigger event handler. */
> -	err = iio_triggered_buffer_postenable(indio_dev);
> -	if (err)
> -		goto err;
> -
>  	return 0;
>  
> +err_buffer_predisable:
> +	iio_triggered_buffer_predisable(indio_dev);
>  err:
>  	zpa2326_err(indio_dev, "failed to enable buffering (%d)", err);
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20  8:03 [PATCH] iio: pressure: zpa2326: fix iio_triggered_buffer_postenable position Alexandru Ardelean
2019-10-05 15:14 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox