From: Tabrez Ahmed <tabreztalks@gmail.com>
To: jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Tabrez Ahmed <tabreztalks@gmail.com>
Subject: [PATCH] iio: adc: ti-ads1015: Use scoped_guard() in trigger handler
Date: Sat, 21 Feb 2026 19:55:00 +0530 [thread overview]
Message-ID: <20260221142500.87016-1-tabreztalks@gmail.com> (raw)
Replace the manual mutex_lock() and mutex_unlock() calls with the
scoped_guard() macro in ads1015_trigger_handler(). This simplifies
the locking logic by ensuring the mutex is always properly released
out of scope, while maintaining the trigger notification on the
error path.
Signed-off-by: Tabrez Ahmed <tabreztalks@gmail.com>
---
Compile-tested only.
drivers/iio/adc/ti-ads1015.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index f2a93c63ca14..582d30c07874 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -451,18 +451,16 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
} scan = { };
int chan, ret, res;
- mutex_lock(&data->lock);
- chan = find_first_bit(indio_dev->active_scan_mask,
- iio_get_masklength(indio_dev));
- ret = ads1015_get_adc_result(data, chan, &res);
- if (ret < 0) {
- mutex_unlock(&data->lock);
- goto err;
+ scoped_guard(mutex, &data->lock) {
+ chan = find_first_bit(indio_dev->active_scan_mask,
+ iio_get_masklength(indio_dev));
+ ret = ads1015_get_adc_result(data, chan, &res);
+ if (ret < 0)
+ goto err;
+
+ scan.chan = res;
}
- scan.chan = res;
- mutex_unlock(&data->lock);
-
iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan),
iio_get_time_ns(indio_dev));
--
2.43.0
next reply other threads:[~2026-02-21 14:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-21 14:25 Tabrez Ahmed [this message]
2026-02-22 15:58 ` [PATCH] iio: adc: ti-ads1015: Use scoped_guard() in trigger handler Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260221142500.87016-1-tabreztalks@gmail.com \
--to=tabreztalks@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.