All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: accel: bmc150: Always restore device to normal mode after suspend-resume
@ 2017-07-13 13:13 Hans de Goede
  2017-07-15 11:39 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2017-07-13 13:13 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hans de Goede, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio

After probe we would put the device in normal mode, after a runtime
suspend-resume we would put it back in normal mode. But for a regular
suspend-resume we would only put it back in normal mode if triggers
or events have been requested.  This is not consistent and breaks
reading raw values after a suspend-resume.

This commit changes the regular resume path to also unconditionally put
the device back in normal mode, fixing reading of raw values not working
after a regular suspend-resume cycle.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/bmc150-accel-core.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 6b5d3be283c4..807299dd45eb 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -193,7 +193,6 @@ struct bmc150_accel_data {
 	struct regmap *regmap;
 	int irq;
 	struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
-	atomic_t active_intr;
 	struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
 	struct mutex mutex;
 	u8 fifo_mode, watermark;
@@ -493,11 +492,6 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
 		goto out_fix_power_state;
 	}
 
-	if (state)
-		atomic_inc(&data->active_intr);
-	else
-		atomic_dec(&data->active_intr);
-
 	return 0;
 
 out_fix_power_state:
@@ -1710,8 +1704,7 @@ static int bmc150_accel_resume(struct device *dev)
 	struct bmc150_accel_data *data = iio_priv(indio_dev);
 
 	mutex_lock(&data->mutex);
-	if (atomic_read(&data->active_intr))
-		bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
+	bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
 	bmc150_accel_fifo_set_mode(data);
 	mutex_unlock(&data->mutex);
 
-- 
2.13.0

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

* Re: [PATCH] iio: accel: bmc150: Always restore device to normal mode after suspend-resume
  2017-07-13 13:13 [PATCH] iio: accel: bmc150: Always restore device to normal mode after suspend-resume Hans de Goede
@ 2017-07-15 11:39 ` Jonathan Cameron
  2017-07-17 19:50   ` Srinivas Pandruvada
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2017-07-15 11:39 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio,
	Srinivas Pandruvada

On Thu, 13 Jul 2017 15:13:41 +0200
Hans de Goede <hdegoede@redhat.com> wrote:

> After probe we would put the device in normal mode, after a runtime
> suspend-resume we would put it back in normal mode. But for a regular
> suspend-resume we would only put it back in normal mode if triggers
> or events have been requested.  This is not consistent and breaks
> reading raw values after a suspend-resume.
> 
> This commit changes the regular resume path to also unconditionally put
> the device back in normal mode, fixing reading of raw values not working
> after a regular suspend-resume cycle.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Looks right to me, but I'd like to send this for stable so would
like a second opinion, say from Srinivas as the original author.
Other comments obviously welcome as well!
> ---
>  drivers/iio/accel/bmc150-accel-core.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
> index 6b5d3be283c4..807299dd45eb 100644
> --- a/drivers/iio/accel/bmc150-accel-core.c
> +++ b/drivers/iio/accel/bmc150-accel-core.c
> @@ -193,7 +193,6 @@ struct bmc150_accel_data {
>  	struct regmap *regmap;
>  	int irq;
>  	struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
> -	atomic_t active_intr;
>  	struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
>  	struct mutex mutex;
>  	u8 fifo_mode, watermark;
> @@ -493,11 +492,6 @@ static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
>  		goto out_fix_power_state;
>  	}
>  
> -	if (state)
> -		atomic_inc(&data->active_intr);
> -	else
> -		atomic_dec(&data->active_intr);
> -
>  	return 0;
>  
>  out_fix_power_state:
> @@ -1710,8 +1704,7 @@ static int bmc150_accel_resume(struct device *dev)
>  	struct bmc150_accel_data *data = iio_priv(indio_dev);
>  
>  	mutex_lock(&data->mutex);
> -	if (atomic_read(&data->active_intr))
> -		bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
> +	bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
>  	bmc150_accel_fifo_set_mode(data);
>  	mutex_unlock(&data->mutex);
>  


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

* Re: [PATCH] iio: accel: bmc150: Always restore device to normal mode after suspend-resume
  2017-07-15 11:39 ` Jonathan Cameron
@ 2017-07-17 19:50   ` Srinivas Pandruvada
  2017-07-17 20:41     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2017-07-17 19:50 UTC (permalink / raw)
  To: Jonathan Cameron, Hans de Goede
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio

On Sat, 2017-07-15 at 12:39 +0100, Jonathan Cameron wrote:
> On Thu, 13 Jul 2017 15:13:41 +0200
> Hans de Goede <hdegoede@redhat.com> wrote:
> 
> > 
> > After probe we would put the device in normal mode, after a runtime
> > suspend-resume we would put it back in normal mode. But for a
> > regular
> > suspend-resume we would only put it back in normal mode if triggers
> > or events have been requested.  This is not consistent and breaks
> > reading raw values after a suspend-resume.
> > 
> > This commit changes the regular resume path to also unconditionally
> > put
> > the device back in normal mode, fixing reading of raw values not
> > working
> > after a regular suspend-resume cycle.
> > 
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> Looks right to me, but I'd like to send this for stable so would
> like a second opinion, say from Srinivas as the original author.
> Other comments obviously welcome as well!
> > 
> > ---
> >  drivers/iio/accel/bmc150-accel-core.c | 9 +--------
> >  1 file changed, 1 insertion(+), 8 deletions(-)
> > 
> > diff --git a/drivers/iio/accel/bmc150-accel-core.c
> > b/drivers/iio/accel/bmc150-accel-core.c
> > index 6b5d3be283c4..807299dd45eb 100644
> > --- a/drivers/iio/accel/bmc150-accel-core.c
> > +++ b/drivers/iio/accel/bmc150-accel-core.c
> > @@ -193,7 +193,6 @@ struct bmc150_accel_data {
> >  	struct regmap *regmap;
> >  	int irq;
> >  	struct bmc150_accel_interrupt
> > interrupts[BMC150_ACCEL_INTERRUPTS];
> > -	atomic_t active_intr;
> >  	struct bmc150_accel_trigger
> > triggers[BMC150_ACCEL_TRIGGERS];
> >  	struct mutex mutex;
> >  	u8 fifo_mode, watermark;
> > @@ -493,11 +492,6 @@ static int bmc150_accel_set_interrupt(struct
> > bmc150_accel_data *data, int i,
> >  		goto out_fix_power_state;
> >  	}
> >  
> > -	if (state)
> > -		atomic_inc(&data->active_intr);
> > -	else
> > -		atomic_dec(&data->active_intr);
> > -
> >  	return 0;
> >  
> >  out_fix_power_state:
> > @@ -1710,8 +1704,7 @@ static int bmc150_accel_resume(struct device
> > *dev)
> >  	struct bmc150_accel_data *data = iio_priv(indio_dev);
> >  
> >  	mutex_lock(&data->mutex);
> > -	if (atomic_read(&data->active_intr))
> > -		bmc150_accel_set_mode(data,
> > BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
> > +	bmc150_accel_set_mode(data,
> > BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
> >  	bmc150_accel_fifo_set_mode(data);
> >  	mutex_unlock(&data->mutex);
> >  

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

* Re: [PATCH] iio: accel: bmc150: Always restore device to normal mode after suspend-resume
  2017-07-17 19:50   ` Srinivas Pandruvada
@ 2017-07-17 20:41     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-07-17 20:41 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Hans de Goede, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio

On Mon, 17 Jul 2017 12:50:55 -0700
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> wrote:

> On Sat, 2017-07-15 at 12:39 +0100, Jonathan Cameron wrote:
> > On Thu, 13 Jul 2017 15:13:41 +0200
> > Hans de Goede <hdegoede@redhat.com> wrote:
> >   
> > > 
> > > After probe we would put the device in normal mode, after a runtime
> > > suspend-resume we would put it back in normal mode. But for a
> > > regular
> > > suspend-resume we would only put it back in normal mode if triggers
> > > or events have been requested.  This is not consistent and breaks
> > > reading raw values after a suspend-resume.
> > > 
> > > This commit changes the regular resume path to also unconditionally
> > > put
> > > the device back in normal mode, fixing reading of raw values not
> > > working
> > > after a regular suspend-resume cycle.
> > > 
> > > Signed-off-by: Hans de Goede <hdegoede@redhat.com>  
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
This bit of code goes back a long way.  I've taken the view
that it should be relevant as long as it applies (so back to
the i2c / spi split)   Hence I've not added a fixes tag but
just marked it for stable.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> 
> > Looks right to me, but I'd like to send this for stable so would
> > like a second opinion, say from Srinivas as the original author.
> > Other comments obviously welcome as well!  
> > > 
> > > ---
> > >  drivers/iio/accel/bmc150-accel-core.c | 9 +--------
> > >  1 file changed, 1 insertion(+), 8 deletions(-)
> > > 
> > > diff --git a/drivers/iio/accel/bmc150-accel-core.c
> > > b/drivers/iio/accel/bmc150-accel-core.c
> > > index 6b5d3be283c4..807299dd45eb 100644
> > > --- a/drivers/iio/accel/bmc150-accel-core.c
> > > +++ b/drivers/iio/accel/bmc150-accel-core.c
> > > @@ -193,7 +193,6 @@ struct bmc150_accel_data {
> > >  	struct regmap *regmap;
> > >  	int irq;
> > >  	struct bmc150_accel_interrupt
> > > interrupts[BMC150_ACCEL_INTERRUPTS];
> > > -	atomic_t active_intr;
> > >  	struct bmc150_accel_trigger
> > > triggers[BMC150_ACCEL_TRIGGERS];
> > >  	struct mutex mutex;
> > >  	u8 fifo_mode, watermark;
> > > @@ -493,11 +492,6 @@ static int bmc150_accel_set_interrupt(struct
> > > bmc150_accel_data *data, int i,
> > >  		goto out_fix_power_state;
> > >  	}
> > >  
> > > -	if (state)
> > > -		atomic_inc(&data->active_intr);
> > > -	else
> > > -		atomic_dec(&data->active_intr);
> > > -
> > >  	return 0;
> > >  
> > >  out_fix_power_state:
> > > @@ -1710,8 +1704,7 @@ static int bmc150_accel_resume(struct device
> > > *dev)
> > >  	struct bmc150_accel_data *data = iio_priv(indio_dev);
> > >  
> > >  	mutex_lock(&data->mutex);
> > > -	if (atomic_read(&data->active_intr))
> > > -		bmc150_accel_set_mode(data,
> > > BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
> > > +	bmc150_accel_set_mode(data,
> > > BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
> > >  	bmc150_accel_fifo_set_mode(data);
> > >  	mutex_unlock(&data->mutex);
> > >    


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

end of thread, other threads:[~2017-07-17 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 13:13 [PATCH] iio: accel: bmc150: Always restore device to normal mode after suspend-resume Hans de Goede
2017-07-15 11:39 ` Jonathan Cameron
2017-07-17 19:50   ` Srinivas Pandruvada
2017-07-17 20:41     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.