linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
@ 2020-03-04  8:24 Alexandru Ardelean
  2020-03-25 11:42 ` Ardelean, Alexandru
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2020-03-04  8:24 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jic23, pmeerw, Alexandru Ardelean

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

For the predisable hook, the disable code should occur before detaching
the poll func, and for the postenable hook, the poll func should be
attached before the enable code.

This change reworks the predisable/postenable hooks so that the pollfunc is
attached/detached in the correct position.
It also balances the calls a bit, by grouping the preenable and the
iio_triggered_buffer_postenable() into a single
isl29125_buffer_postenable() function.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/light/isl29125.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
index e37894f0ae0b..95611f5eff01 100644
--- a/drivers/iio/light/isl29125.c
+++ b/drivers/iio/light/isl29125.c
@@ -213,13 +213,24 @@ static const struct iio_info isl29125_info = {
 	.attrs = &isl29125_attribute_group,
 };
 
-static int isl29125_buffer_preenable(struct iio_dev *indio_dev)
+static int isl29125_buffer_postenable(struct iio_dev *indio_dev)
 {
 	struct isl29125_data *data = iio_priv(indio_dev);
+	int err;
+
+	err = iio_triggered_buffer_postenable(indio_dev);
+	if (err)
+		return err;
 
 	data->conf1 |= ISL29125_MODE_RGB;
-	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
+	err = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
 		data->conf1);
+	if (err) {
+		iio_triggered_buffer_predisable(indio_dev);
+		return err;
+	}
+
+	return 0;
 }
 
 static int isl29125_buffer_predisable(struct iio_dev *indio_dev)
@@ -227,19 +238,18 @@ static int isl29125_buffer_predisable(struct iio_dev *indio_dev)
 	struct isl29125_data *data = iio_priv(indio_dev);
 	int ret;
 
-	ret = iio_triggered_buffer_predisable(indio_dev);
-	if (ret < 0)
-		return ret;
-
 	data->conf1 &= ~ISL29125_MODE_MASK;
 	data->conf1 |= ISL29125_MODE_PD;
-	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
+	ret = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
 		data->conf1);
+
+	iio_triggered_buffer_predisable(indio_dev);
+
+	return ret;
 }
 
 static const struct iio_buffer_setup_ops isl29125_buffer_setup_ops = {
-	.preenable = isl29125_buffer_preenable,
-	.postenable = &iio_triggered_buffer_postenable,
+	.postenable = isl29125_buffer_postenable,
 	.predisable = isl29125_buffer_predisable,
 };
 
-- 
2.20.1


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

* Re: [PATCH] iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
  2020-03-04  8:24 [PATCH] iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions Alexandru Ardelean
@ 2020-03-25 11:42 ` Ardelean, Alexandru
  2020-04-13 17:04   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Ardelean, Alexandru @ 2020-03-25 11:42 UTC (permalink / raw)
  To: linux-kernel, linux-iio; +Cc: jic23, pmeerw

On Wed, 2020-03-04 at 10:24 +0200, Alexandru Ardelean wrote:
> The iio_triggered_buffer_{predisable,postenable} functions attach/detach
> the poll functions.
> 
> For the predisable hook, the disable code should occur before detaching
> the poll func, and for the postenable hook, the poll func should be
> attached before the enable code.
> 
> This change reworks the predisable/postenable hooks so that the pollfunc is
> attached/detached in the correct position.
> It also balances the calls a bit, by grouping the preenable and the
> iio_triggered_buffer_postenable() into a single
> isl29125_buffer_postenable() function.

ping on this patch

> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>  drivers/iio/light/isl29125.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
> index e37894f0ae0b..95611f5eff01 100644
> --- a/drivers/iio/light/isl29125.c
> +++ b/drivers/iio/light/isl29125.c
> @@ -213,13 +213,24 @@ static const struct iio_info isl29125_info = {
>  	.attrs = &isl29125_attribute_group,
>  };
>  
> -static int isl29125_buffer_preenable(struct iio_dev *indio_dev)
> +static int isl29125_buffer_postenable(struct iio_dev *indio_dev)
>  {
>  	struct isl29125_data *data = iio_priv(indio_dev);
> +	int err;
> +
> +	err = iio_triggered_buffer_postenable(indio_dev);
> +	if (err)
> +		return err;
>  
>  	data->conf1 |= ISL29125_MODE_RGB;
> -	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
> +	err = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
>  		data->conf1);
> +	if (err) {
> +		iio_triggered_buffer_predisable(indio_dev);
> +		return err;
> +	}
> +
> +	return 0;
>  }
>  
>  static int isl29125_buffer_predisable(struct iio_dev *indio_dev)
> @@ -227,19 +238,18 @@ static int isl29125_buffer_predisable(struct iio_dev
> *indio_dev)
>  	struct isl29125_data *data = iio_priv(indio_dev);
>  	int ret;
>  
> -	ret = iio_triggered_buffer_predisable(indio_dev);
> -	if (ret < 0)
> -		return ret;
> -
>  	data->conf1 &= ~ISL29125_MODE_MASK;
>  	data->conf1 |= ISL29125_MODE_PD;
> -	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
> +	ret = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
>  		data->conf1);
> +
> +	iio_triggered_buffer_predisable(indio_dev);
> +
> +	return ret;
>  }
>  
>  static const struct iio_buffer_setup_ops isl29125_buffer_setup_ops = {
> -	.preenable = isl29125_buffer_preenable,
> -	.postenable = &iio_triggered_buffer_postenable,
> +	.postenable = isl29125_buffer_postenable,
>  	.predisable = isl29125_buffer_predisable,
>  };
>  

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

* Re: [PATCH] iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
  2020-03-25 11:42 ` Ardelean, Alexandru
@ 2020-04-13 17:04   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2020-04-13 17:04 UTC (permalink / raw)
  To: Ardelean, Alexandru; +Cc: linux-kernel, linux-iio, pmeerw

On Wed, 25 Mar 2020 11:42:31 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Wed, 2020-03-04 at 10:24 +0200, Alexandru Ardelean wrote:
> > The iio_triggered_buffer_{predisable,postenable} functions attach/detach
> > the poll functions.
> > 
> > For the predisable hook, the disable code should occur before detaching
> > the poll func, and for the postenable hook, the poll func should be
> > attached before the enable code.
> > 
> > This change reworks the predisable/postenable hooks so that the pollfunc is
> > attached/detached in the correct position.
> > It also balances the calls a bit, by grouping the preenable and the
> > iio_triggered_buffer_postenable() into a single
> > isl29125_buffer_postenable() function.  
> 
> ping on this patch

Long enough.  Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> 
> > 
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >  drivers/iio/light/isl29125.c | 28 +++++++++++++++++++---------
> >  1 file changed, 19 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
> > index e37894f0ae0b..95611f5eff01 100644
> > --- a/drivers/iio/light/isl29125.c
> > +++ b/drivers/iio/light/isl29125.c
> > @@ -213,13 +213,24 @@ static const struct iio_info isl29125_info = {
> >  	.attrs = &isl29125_attribute_group,
> >  };
> >  
> > -static int isl29125_buffer_preenable(struct iio_dev *indio_dev)
> > +static int isl29125_buffer_postenable(struct iio_dev *indio_dev)
> >  {
> >  	struct isl29125_data *data = iio_priv(indio_dev);
> > +	int err;
> > +
> > +	err = iio_triggered_buffer_postenable(indio_dev);
> > +	if (err)
> > +		return err;
> >  
> >  	data->conf1 |= ISL29125_MODE_RGB;
> > -	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
> > +	err = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
> >  		data->conf1);
> > +	if (err) {
> > +		iio_triggered_buffer_predisable(indio_dev);
> > +		return err;
> > +	}
> > +
> > +	return 0;
> >  }
> >  
> >  static int isl29125_buffer_predisable(struct iio_dev *indio_dev)
> > @@ -227,19 +238,18 @@ static int isl29125_buffer_predisable(struct iio_dev
> > *indio_dev)
> >  	struct isl29125_data *data = iio_priv(indio_dev);
> >  	int ret;
> >  
> > -	ret = iio_triggered_buffer_predisable(indio_dev);
> > -	if (ret < 0)
> > -		return ret;
> > -
> >  	data->conf1 &= ~ISL29125_MODE_MASK;
> >  	data->conf1 |= ISL29125_MODE_PD;
> > -	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
> > +	ret = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
> >  		data->conf1);
> > +
> > +	iio_triggered_buffer_predisable(indio_dev);
> > +
> > +	return ret;
> >  }
> >  
> >  static const struct iio_buffer_setup_ops isl29125_buffer_setup_ops = {
> > -	.preenable = isl29125_buffer_preenable,
> > -	.postenable = &iio_triggered_buffer_postenable,
> > +	.postenable = isl29125_buffer_postenable,
> >  	.predisable = isl29125_buffer_predisable,
> >  };
> >    


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

end of thread, other threads:[~2020-04-13 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04  8:24 [PATCH] iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions Alexandru Ardelean
2020-03-25 11:42 ` Ardelean, Alexandru
2020-04-13 17:04   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).