* [PATCH 1/1] iio: gyro: fxas21002c: Fix missing data update in trigger handler
@ 2024-11-16 15:29 Frank Li
2024-11-23 15:40 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Frank Li @ 2024-11-16 15:29 UTC (permalink / raw)
To: Rui Miguel Silva, Jonathan Cameron, Lars-Peter Clausen,
open list:NXP FXAS21002C DRIVER, open list
Cc: imx
From: Carlos Song <carlos.song@nxp.com>
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")
Signed-off-by: Carlos Song <carlos.song@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/iio/gyro/fxas21002c_core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
index 688966129f704..50b908b2419be 100644
--- a/drivers/iio/gyro/fxas21002c_core.c
+++ b/drivers/iio/gyro/fxas21002c_core.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] iio: gyro: fxas21002c: Fix missing data update in trigger handler
2024-11-16 15:29 [PATCH 1/1] iio: gyro: fxas21002c: Fix missing data update in trigger handler Frank Li
@ 2024-11-23 15:40 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-11-23 15:40 UTC (permalink / raw)
To: Frank Li
Cc: Rui Miguel Silva, Lars-Peter Clausen,
open list:NXP FXAS21002C DRIVER, open list, imx
On Sat, 16 Nov 2024 10:29:45 -0500
Frank Li <Frank.Li@nxp.com> wrote:
> From: Carlos Song <carlos.song@nxp.com>
>
> 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")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
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
> ---
> drivers/iio/gyro/fxas21002c_core.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
> index 688966129f704..50b908b2419be 100644
> --- a/drivers/iio/gyro/fxas21002c_core.c
> +++ b/drivers/iio/gyro/fxas21002c_core.c
> @@ -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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-23 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-16 15:29 [PATCH 1/1] iio: gyro: fxas21002c: Fix missing data update in trigger handler Frank Li
2024-11-23 15:40 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox