* [PATCH] iio: resolver: ad2s1210: refactor trigger handler
@ 2026-05-16 15:09 David Lechner
2026-05-16 15:24 ` Stepan Ionichev
0 siblings, 1 reply; 3+ messages in thread
From: David Lechner @ 2026-05-16 15:09 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Nuno Sá, Andy Shevchenko
Cc: Stepan Ionichev, linux-iio, linux-kernel, David Lechner
Refactor the trigger handler to avoid use of goto in a guard() scope.
Ideally, we should not be mixing goto and automatic cleanup.
iio_trigger_notify_done() was not part of the critical section anyway,
so is not moved to the new function.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
Following up from [1]. This depends on a fix, so will have to wait a bit
before this can be applied.
[1]: https://lore.kernel.org/linux-iio/20260516122838.163a77d3@jic23-huawei/
---
drivers/iio/resolver/ad2s1210.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/resolver/ad2s1210.c b/drivers/iio/resolver/ad2s1210.c
index 1be19fe8aa3f..59c035311691 100644
--- a/drivers/iio/resolver/ad2s1210.c
+++ b/drivers/iio/resolver/ad2s1210.c
@@ -1276,10 +1276,8 @@ static int ad2s1210_debugfs_reg_access(struct iio_dev *indio_dev,
return regmap_write(st->regmap, reg, writeval);
}
-static irqreturn_t ad2s1210_trigger_handler(int irq, void *p)
+static void ad2s1210_scan_to_buffers(struct iio_dev *indio_dev, s64 timestamp)
{
- struct iio_poll_func *pf = p;
- struct iio_dev *indio_dev = pf->indio_dev;
struct ad2s1210_state *st = iio_priv(indio_dev);
size_t chan = 0;
int ret;
@@ -1295,15 +1293,15 @@ static irqreturn_t ad2s1210_trigger_handler(int irq, void *p)
AD2S1210_REG_POSITION_MSB,
&st->sample.raw, 2);
if (ret < 0)
- goto error_ret;
+ return;
} else {
ret = ad2s1210_set_mode(st, MOD_POS);
if (ret < 0)
- goto error_ret;
+ return;
ret = spi_read(st->sdev, &st->sample, 3);
if (ret < 0)
- goto error_ret;
+ return;
}
memcpy(&st->scan.chan[chan++], &st->sample.raw, 2);
@@ -1315,15 +1313,15 @@ static irqreturn_t ad2s1210_trigger_handler(int irq, void *p)
AD2S1210_REG_VELOCITY_MSB,
&st->sample.raw, 2);
if (ret < 0)
- goto error_ret;
+ return;
} else {
ret = ad2s1210_set_mode(st, MOD_VEL);
if (ret < 0)
- goto error_ret;
+ return;
ret = spi_read(st->sdev, &st->sample, 3);
if (ret < 0)
- goto error_ret;
+ return;
}
memcpy(&st->scan.chan[chan++], &st->sample.raw, 2);
@@ -1334,16 +1332,22 @@ static irqreturn_t ad2s1210_trigger_handler(int irq, void *p)
ret = regmap_read(st->regmap, AD2S1210_REG_FAULT, ®_val);
if (ret < 0)
- goto error_ret;
+ return;
st->sample.fault = reg_val;
}
- ad2s1210_push_events(indio_dev, st->sample.fault, pf->timestamp);
+ ad2s1210_push_events(indio_dev, st->sample.fault, timestamp);
iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan),
- pf->timestamp);
+ timestamp);
+}
+
+static irqreturn_t ad2s1210_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
-error_ret:
+ ad2s1210_scan_to_buffers(indio_dev, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
---
base-commit: 0eb0ac8b282b273c254dcda52d29b06a92840252
change-id: 20260516-iio-resolver-refactor-trigger-handler-af38933d7a42
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] iio: resolver: ad2s1210: refactor trigger handler
2026-05-16 15:09 [PATCH] iio: resolver: ad2s1210: refactor trigger handler David Lechner
@ 2026-05-16 15:24 ` Stepan Ionichev
2026-07-03 19:08 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Stepan Ionichev @ 2026-05-16 15:24 UTC (permalink / raw)
To: dlechner
Cc: lars, Michael.Hennerich, jic23, nuno.sa, andy, linux-iio,
linux-kernel, Stepan Ionichev
On Sat, May 16, 2026, David Lechner wrote:
> Refactor the trigger handler to avoid use of goto in a guard() scope.
> Ideally, we should not be mixing goto and automatic cleanup.
>
> iio_trigger_notify_done() was not part of the critical section anyway,
> so is not moved to the new function.
Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: resolver: ad2s1210: refactor trigger handler
2026-05-16 15:24 ` Stepan Ionichev
@ 2026-07-03 19:08 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-07-03 19:08 UTC (permalink / raw)
To: Stepan Ionichev
Cc: dlechner, lars, Michael.Hennerich, nuno.sa, andy, linux-iio,
linux-kernel
On Sat, 16 May 2026 20:24:08 +0500
Stepan Ionichev <sozdayvek@gmail.com> wrote:
> On Sat, May 16, 2026, David Lechner wrote:
> > Refactor the trigger handler to avoid use of goto in a guard() scope.
> > Ideally, we should not be mixing goto and automatic cleanup.
> >
> > iio_trigger_notify_done() was not part of the critical section anyway,
> > so is not moved to the new function.
>
> Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
Applied. Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-03 19:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-16 15:09 [PATCH] iio: resolver: ad2s1210: refactor trigger handler David Lechner
2026-05-16 15:24 ` Stepan Ionichev
2026-07-03 19:08 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox