Skip to contentSkip to conversation

iio: invensense: fix odr switching to same value

PATCH Applied [email protected] 2 participants 2 messages May 24, 2024 – May 25, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: invensense: fix odr switching to same value

From: Jean-Baptiste Maneyrol <[email protected]>

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")
---
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +5 -1
index fa205f17bd90..f44458c380d9 100644
@@ -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;
 }
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 7 lines · On Fri, 24 May 2024 12:48:51 +0000 [email protected] wrote:

From: Jean-Baptiste Maneyrol <[email protected]>

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.

Quoted 6 lines

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

Fixes 0ecc363ccea7 ("iio: make invensense timestamp module generic")

Applied to the fixes-togreg branch of iio.git

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

Quoted 25 lines
---
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +5 -1
index fa205f17bd90..f44458c380d9 100644
@@ -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;
 }