Skip to contentSkip to conversation

iio: gyro: fxas21002c: Fix missing data update in trigger handler

PATCH Applied Frank Li 2 participants 2 messages Nov 16, 2024 – Nov 23, 2024

Subsystems (3)
lore
Share & tools
lore

Frank Li

author maintainer
#0 lore raw

PATCH 1/1 iio: gyro: fxas21002c: Fix missing data update in trigger handler

From: Carlos Song <[email protected]>

The fxas21002c_trigger_handler() may fail to acquire sample data because the runtime PM enters the autosuspend state and sensor can not return sample data in standby mode..

Resume the sensor before reading the sample data into the buffer within the trigger handler. After the data is read, place the sensor back into the autosuspend state.

Fixes a0701b6263ae ("iio: gyro: add core driver for fxas21002c")
---
 drivers/iio/gyro/fxas21002c_core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iio/gyro/fxas21002c_core.c +8 -1
index 688966129f704..50b908b2419be 100644
@@ -730,14 +730,21 @@ static irqreturn_t fxas21002c_trigger_handler(int irq, void *p)
 	int ret;
 
 	mutex_lock(&data->lock);
+	ret = fxas21002c_pm_get(data);
+	if (ret < 0)
+		goto out_unlock;
+
 	ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB,
 			       data->buffer, CHANNEL_SCAN_MAX * sizeof(s16));
 	if (ret < 0)
-		goto out_unlock;
+		goto out_pm_put;
 
 	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
 					   data->timestamp);
 
+out_pm_put:
+	fxas21002c_pm_put(data);
+
 out_unlock:
 	mutex_unlock(&data->lock);
 
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 6 lines · On Sat, 16 Nov 2024 10:29:45 -0500 Frank Li <[email protected]> wrote:

From: Carlos Song <[email protected]>

The fxas21002c_trigger_handler() may fail to acquire sample data because the runtime PM enters the autosuspend state and sensor can not return sample data in standby mode..

Quoted 7 lines

Resume the sensor before reading the sample data into the buffer within the trigger handler. After the data is read, place the sensor back into the autosuspend state.

Fixes a0701b6263ae ("iio: gyro: add core driver for fxas21002c")

Applied to the fixes-togreg branch of iio.git and marked for stable. Note I'll rebase on rc1 once available before sending a pull request with this in.

Thanks,

Jonathan

Quoted 31 lines
---
 drivers/iio/gyro/fxas21002c_core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iio/gyro/fxas21002c_core.c +8 -1
index 688966129f704..50b908b2419be 100644
@@ -730,14 +730,21 @@ static irqreturn_t fxas21002c_trigger_handler(int irq, void *p)
 	int ret;
 
 	mutex_lock(&data->lock);
+	ret = fxas21002c_pm_get(data);
+	if (ret < 0)
+		goto out_unlock;
+
 	ret = regmap_bulk_read(data->regmap, FXAS21002C_REG_OUT_X_MSB,
 			       data->buffer, CHANNEL_SCAN_MAX * sizeof(s16));
 	if (ret < 0)
-		goto out_unlock;
+		goto out_pm_put;
 
 	iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
 					   data->timestamp);
 
+out_pm_put:
+	fxas21002c_pm_put(data);
+
 out_unlock:
 	mutex_unlock(&data->lock);