public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: invensense: fix odr switching to same value
@ 2024-05-24 12:48 inv.git-commit
  2024-05-25 17:29 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: inv.git-commit @ 2024-05-24 12:48 UTC (permalink / raw)
  To: jic23; +Cc: lars, linux-iio, stable, Jean-Baptiste Maneyrol

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

ODR switching happens in 2 steps, update to store the new value and then
apply when the ODR change flag is received in the data. When switching to
the same ODR value, the ODR change flag is never happening, and frequency
switching is blocked waiting for the never coming apply.

Fix the issue by preventing update to happen when switching to same ODR
value.

Fixes: 0ecc363ccea7 ("iio: make invensense timestamp module generic")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
---
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index fa205f17bd90..f44458c380d9 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -60,11 +60,15 @@ EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_init, IIO_INV_SENSORS_TIMESTAMP);
 int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
 				     uint32_t period, bool fifo)
 {
+	uint32_t mult;
+
 	/* when FIFO is on, prevent odr change if one is already pending */
 	if (fifo && ts->new_mult != 0)
 		return -EAGAIN;
 
-	ts->new_mult = period / ts->chip.clock_period;
+	mult = period / ts->chip.clock_period;
+	if (mult != ts->mult)
+		ts->new_mult = mult;
 
 	return 0;
 }
-- 
2.34.1


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

* Re: [PATCH] iio: invensense: fix odr switching to same value
  2024-05-24 12:48 [PATCH] iio: invensense: fix odr switching to same value inv.git-commit
@ 2024-05-25 17:29 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-05-25 17:29 UTC (permalink / raw)
  To: inv.git-commit; +Cc: lars, linux-iio, stable, Jean-Baptiste Maneyrol

On Fri, 24 May 2024 12:48:51 +0000
inv.git-commit@tdk.com wrote:

> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> 
> ODR switching happens in 2 steps, update to store the new value and then
> apply when the ODR change flag is received in the data. When switching to
> the same ODR value, the ODR change flag is never happening, and frequency
> switching is blocked waiting for the never coming apply.
> 
> Fix the issue by preventing update to happen when switching to same ODR
> value.
> 
> Fixes: 0ecc363ccea7 ("iio: make invensense timestamp module generic")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Applied to the fixes-togreg branch of iio.git

Note I'll rebase that tree on rc1 once available.

> ---
>  drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
> index fa205f17bd90..f44458c380d9 100644
> --- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
> +++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
> @@ -60,11 +60,15 @@ EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_init, IIO_INV_SENSORS_TIMESTAMP);
>  int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
>  				     uint32_t period, bool fifo)
>  {
> +	uint32_t mult;
> +
>  	/* when FIFO is on, prevent odr change if one is already pending */
>  	if (fifo && ts->new_mult != 0)
>  		return -EAGAIN;
>  
> -	ts->new_mult = period / ts->chip.clock_period;
> +	mult = period / ts->chip.clock_period;
> +	if (mult != ts->mult)
> +		ts->new_mult = mult;
>  
>  	return 0;
>  }


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

end of thread, other threads:[~2024-05-25 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-24 12:48 [PATCH] iio: invensense: fix odr switching to same value inv.git-commit
2024-05-25 17:29 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox