Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions
@ 2019-10-23  8:27 Alexandru Ardelean
  2019-10-27 16:58 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandru Ardelean @ 2019-10-23  8:27 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jic23, Alexandru Ardelean

The iio_triggered_buffer_postenable() hook should be called first to
attach the poll function and the iio_triggered_buffer_predisable() hook
should be called last in the predisable hook.

This change updates the driver to attach/detach the poll func in the
correct order.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/humidity/hdc100x.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
index bfe1cdb16846..963ff043eecf 100644
--- a/drivers/iio/humidity/hdc100x.c
+++ b/drivers/iio/humidity/hdc100x.c
@@ -278,31 +278,34 @@ static int hdc100x_buffer_postenable(struct iio_dev *indio_dev)
 	struct hdc100x_data *data = iio_priv(indio_dev);
 	int ret;
 
+	ret = iio_triggered_buffer_postenable(indio_dev);
+	if (ret)
+		return ret;
+
 	/* Buffer is enabled. First set ACQ Mode, then attach poll func */
 	mutex_lock(&data->lock);
 	ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
 				    HDC100X_REG_CONFIG_ACQ_MODE);
 	mutex_unlock(&data->lock);
 	if (ret)
-		return ret;
+		iio_triggered_buffer_predisable(indio_dev);
 
-	return iio_triggered_buffer_postenable(indio_dev);
+	return ret;
 }
 
 static int hdc100x_buffer_predisable(struct iio_dev *indio_dev)
 {
 	struct hdc100x_data *data = iio_priv(indio_dev);
-	int ret;
-
-	/* First detach poll func, then reset ACQ mode. OK to disable buffer */
-	ret = iio_triggered_buffer_predisable(indio_dev);
-	if (ret)
-		return ret;
+	int ret, ret2;
 
 	mutex_lock(&data->lock);
 	ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0);
 	mutex_unlock(&data->lock);
 
+	ret2 = iio_triggered_buffer_predisable(indio_dev);
+	if (ret == 0)
+		ret = ret2;
+
 	return ret;
 }
 
-- 
2.20.1


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

* Re: [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions
  2019-10-23  8:27 [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions Alexandru Ardelean
@ 2019-10-27 16:58 ` Jonathan Cameron
  2019-10-27 18:37   ` Matt Ranostay
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2019-10-27 16:58 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-iio, linux-kernel, Matt Ranostay

On Wed, 23 Oct 2019 11:27:14 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> The iio_triggered_buffer_postenable() hook should be called first to
> attach the poll function and the iio_triggered_buffer_predisable() hook
> should be called last in the predisable hook.
> 
> This change updates the driver to attach/detach the poll func in the
> correct order.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Seems fine, but should have cc'd Matt and I'd like to give him time
to take a quick look.

+CC Matt.

Thanks,

Jonathan

> ---
>  drivers/iio/humidity/hdc100x.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> index bfe1cdb16846..963ff043eecf 100644
> --- a/drivers/iio/humidity/hdc100x.c
> +++ b/drivers/iio/humidity/hdc100x.c
> @@ -278,31 +278,34 @@ static int hdc100x_buffer_postenable(struct iio_dev *indio_dev)
>  	struct hdc100x_data *data = iio_priv(indio_dev);
>  	int ret;
>  
> +	ret = iio_triggered_buffer_postenable(indio_dev);
> +	if (ret)
> +		return ret;
> +
>  	/* Buffer is enabled. First set ACQ Mode, then attach poll func */
>  	mutex_lock(&data->lock);
>  	ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
>  				    HDC100X_REG_CONFIG_ACQ_MODE);
>  	mutex_unlock(&data->lock);
>  	if (ret)
> -		return ret;
> +		iio_triggered_buffer_predisable(indio_dev);
>  
> -	return iio_triggered_buffer_postenable(indio_dev);
> +	return ret;
>  }
>  
>  static int hdc100x_buffer_predisable(struct iio_dev *indio_dev)
>  {
>  	struct hdc100x_data *data = iio_priv(indio_dev);
> -	int ret;
> -
> -	/* First detach poll func, then reset ACQ mode. OK to disable buffer */
> -	ret = iio_triggered_buffer_predisable(indio_dev);
> -	if (ret)
> -		return ret;
> +	int ret, ret2;
>  
>  	mutex_lock(&data->lock);
>  	ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0);
>  	mutex_unlock(&data->lock);
>  
> +	ret2 = iio_triggered_buffer_predisable(indio_dev);
> +	if (ret == 0)
> +		ret = ret2;
> +
>  	return ret;
>  }
>  


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

* Re: [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions
  2019-10-27 16:58 ` Jonathan Cameron
@ 2019-10-27 18:37   ` Matt Ranostay
  2019-10-28  7:11     ` Ardelean, Alexandru
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Ranostay @ 2019-10-27 18:37 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Alexandru Ardelean, open list:IIO SUBSYSTEM AND DRIVERS, open list

On Sun, Oct 27, 2019 at 6:58 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Wed, 23 Oct 2019 11:27:14 +0300
> Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
>
> > The iio_triggered_buffer_postenable() hook should be called first to
> > attach the poll function and the iio_triggered_buffer_predisable() hook
> > should be called last in the predisable hook.
> >
> > This change updates the driver to attach/detach the poll func in the
> > correct order.
> >
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> Seems fine, but should have cc'd Matt and I'd like to give him time
> to take a quick look.
>

Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>

> +CC Matt.
>
> Thanks,
>
> Jonathan
>
> > ---
> >  drivers/iio/humidity/hdc100x.c | 19 +++++++++++--------
> >  1 file changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> > index bfe1cdb16846..963ff043eecf 100644
> > --- a/drivers/iio/humidity/hdc100x.c
> > +++ b/drivers/iio/humidity/hdc100x.c
> > @@ -278,31 +278,34 @@ static int hdc100x_buffer_postenable(struct iio_dev *indio_dev)
> >       struct hdc100x_data *data = iio_priv(indio_dev);
> >       int ret;
> >
> > +     ret = iio_triggered_buffer_postenable(indio_dev);
> > +     if (ret)
> > +             return ret;
> > +
> >       /* Buffer is enabled. First set ACQ Mode, then attach poll func */
> >       mutex_lock(&data->lock);
> >       ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
> >                                   HDC100X_REG_CONFIG_ACQ_MODE);
> >       mutex_unlock(&data->lock);
> >       if (ret)
> > -             return ret;
> > +             iio_triggered_buffer_predisable(indio_dev);
> >
> > -     return iio_triggered_buffer_postenable(indio_dev);
> > +     return ret;
> >  }
> >
> >  static int hdc100x_buffer_predisable(struct iio_dev *indio_dev)
> >  {
> >       struct hdc100x_data *data = iio_priv(indio_dev);
> > -     int ret;
> > -
> > -     /* First detach poll func, then reset ACQ mode. OK to disable buffer */
> > -     ret = iio_triggered_buffer_predisable(indio_dev);
> > -     if (ret)
> > -             return ret;
> > +     int ret, ret2;
> >
> >       mutex_lock(&data->lock);
> >       ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0);
> >       mutex_unlock(&data->lock);
> >
> > +     ret2 = iio_triggered_buffer_predisable(indio_dev);
> > +     if (ret == 0)
> > +             ret = ret2;
> > +
> >       return ret;
> >  }
> >
>

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

* Re: [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions
  2019-10-27 18:37   ` Matt Ranostay
@ 2019-10-28  7:11     ` Ardelean, Alexandru
  2019-11-02 14:40       ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Ardelean, Alexandru @ 2019-10-28  7:11 UTC (permalink / raw)
  To: jic23, matt.ranostay; +Cc: linux-kernel, linux-iio

On Sun, 2019-10-27 at 20:37 +0200, Matt Ranostay wrote:
> [External]
> 
> On Sun, Oct 27, 2019 at 6:58 PM Jonathan Cameron <jic23@kernel.org>
> wrote:
> > On Wed, 23 Oct 2019 11:27:14 +0300
> > Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> > 
> > > The iio_triggered_buffer_postenable() hook should be called first to
> > > attach the poll function and the iio_triggered_buffer_predisable()
> > > hook
> > > should be called last in the predisable hook.
> > > 
> > > This change updates the driver to attach/detach the poll func in the
> > > correct order.
> > > 
> > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > Seems fine, but should have cc'd Matt and I'd like to give him time
> > to take a quick look.
> > 
> 
> Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>

Apologies for not CC-ing Matt.
I guess I wasn't paying [close enough] attention to the output of
get_maintainers.pl

Thanks
Alex

> 
> > +CC Matt.
> > 
> > Thanks,
> > 
> > Jonathan
> > 
> > > ---
> > >  drivers/iio/humidity/hdc100x.c | 19 +++++++++++--------
> > >  1 file changed, 11 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/iio/humidity/hdc100x.c
> > > b/drivers/iio/humidity/hdc100x.c
> > > index bfe1cdb16846..963ff043eecf 100644
> > > --- a/drivers/iio/humidity/hdc100x.c
> > > +++ b/drivers/iio/humidity/hdc100x.c
> > > @@ -278,31 +278,34 @@ static int hdc100x_buffer_postenable(struct
> > > iio_dev *indio_dev)
> > >       struct hdc100x_data *data = iio_priv(indio_dev);
> > >       int ret;
> > > 
> > > +     ret = iio_triggered_buffer_postenable(indio_dev);
> > > +     if (ret)
> > > +             return ret;
> > > +
> > >       /* Buffer is enabled. First set ACQ Mode, then attach poll func
> > > */
> > >       mutex_lock(&data->lock);
> > >       ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
> > >                                   HDC100X_REG_CONFIG_ACQ_MODE);
> > >       mutex_unlock(&data->lock);
> > >       if (ret)
> > > -             return ret;
> > > +             iio_triggered_buffer_predisable(indio_dev);
> > > 
> > > -     return iio_triggered_buffer_postenable(indio_dev);
> > > +     return ret;
> > >  }
> > > 
> > >  static int hdc100x_buffer_predisable(struct iio_dev *indio_dev)
> > >  {
> > >       struct hdc100x_data *data = iio_priv(indio_dev);
> > > -     int ret;
> > > -
> > > -     /* First detach poll func, then reset ACQ mode. OK to disable
> > > buffer */
> > > -     ret = iio_triggered_buffer_predisable(indio_dev);
> > > -     if (ret)
> > > -             return ret;
> > > +     int ret, ret2;
> > > 
> > >       mutex_lock(&data->lock);
> > >       ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
> > > 0);
> > >       mutex_unlock(&data->lock);
> > > 
> > > +     ret2 = iio_triggered_buffer_predisable(indio_dev);
> > > +     if (ret == 0)
> > > +             ret = ret2;
> > > +
> > >       return ret;
> > >  }
> > > 

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

* Re: [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions
  2019-10-28  7:11     ` Ardelean, Alexandru
@ 2019-11-02 14:40       ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-11-02 14:40 UTC (permalink / raw)
  To: Ardelean, Alexandru; +Cc: matt.ranostay, linux-kernel, linux-iio

On Mon, 28 Oct 2019 07:11:51 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Sun, 2019-10-27 at 20:37 +0200, Matt Ranostay wrote:
> > [External]
> > 
> > On Sun, Oct 27, 2019 at 6:58 PM Jonathan Cameron <jic23@kernel.org>
> > wrote:  
> > > On Wed, 23 Oct 2019 11:27:14 +0300
> > > Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> > >   
> > > > The iio_triggered_buffer_postenable() hook should be called first to
> > > > attach the poll function and the iio_triggered_buffer_predisable()
> > > > hook
> > > > should be called last in the predisable hook.
> > > > 
> > > > This change updates the driver to attach/detach the poll func in the
> > > > correct order.
> > > > 
> > > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>  
> > > Seems fine, but should have cc'd Matt and I'd like to give him time
> > > to take a quick look.
> > >   
> > 
> > Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>  
> 
> Apologies for not CC-ing Matt.
> I guess I wasn't paying [close enough] attention to the output of
> get_maintainers.pl
> 
> Thanks
> Alex
> 
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan

> >   
> > > +CC Matt.
> > > 
> > > Thanks,
> > > 
> > > Jonathan
> > >   
> > > > ---
> > > >  drivers/iio/humidity/hdc100x.c | 19 +++++++++++--------
> > > >  1 file changed, 11 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/drivers/iio/humidity/hdc100x.c
> > > > b/drivers/iio/humidity/hdc100x.c
> > > > index bfe1cdb16846..963ff043eecf 100644
> > > > --- a/drivers/iio/humidity/hdc100x.c
> > > > +++ b/drivers/iio/humidity/hdc100x.c
> > > > @@ -278,31 +278,34 @@ static int hdc100x_buffer_postenable(struct
> > > > iio_dev *indio_dev)
> > > >       struct hdc100x_data *data = iio_priv(indio_dev);
> > > >       int ret;
> > > > 
> > > > +     ret = iio_triggered_buffer_postenable(indio_dev);
> > > > +     if (ret)
> > > > +             return ret;
> > > > +
> > > >       /* Buffer is enabled. First set ACQ Mode, then attach poll func
> > > > */
> > > >       mutex_lock(&data->lock);
> > > >       ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
> > > >                                   HDC100X_REG_CONFIG_ACQ_MODE);
> > > >       mutex_unlock(&data->lock);
> > > >       if (ret)
> > > > -             return ret;
> > > > +             iio_triggered_buffer_predisable(indio_dev);
> > > > 
> > > > -     return iio_triggered_buffer_postenable(indio_dev);
> > > > +     return ret;
> > > >  }
> > > > 
> > > >  static int hdc100x_buffer_predisable(struct iio_dev *indio_dev)
> > > >  {
> > > >       struct hdc100x_data *data = iio_priv(indio_dev);
> > > > -     int ret;
> > > > -
> > > > -     /* First detach poll func, then reset ACQ mode. OK to disable
> > > > buffer */
> > > > -     ret = iio_triggered_buffer_predisable(indio_dev);
> > > > -     if (ret)
> > > > -             return ret;
> > > > +     int ret, ret2;
> > > > 
> > > >       mutex_lock(&data->lock);
> > > >       ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
> > > > 0);
> > > >       mutex_unlock(&data->lock);
> > > > 
> > > > +     ret2 = iio_triggered_buffer_predisable(indio_dev);
> > > > +     if (ret == 0)
> > > > +             ret = ret2;
> > > > +
> > > >       return ret;
> > > >  }
> > > >   


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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23  8:27 [PATCH] iio: hdc100x: fix iio_triggered_buffer_{predisable,postenable} positions Alexandru Ardelean
2019-10-27 16:58 ` Jonathan Cameron
2019-10-27 18:37   ` Matt Ranostay
2019-10-28  7:11     ` Ardelean, Alexandru
2019-11-02 14:40       ` 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
	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.git