From: sashiko-bot@kernel.org
To: "Rupesh Majhi" <zoone.rupert@gmail.com>
Cc: linux-amlogic@lists.infradead.org, neil.armstrong@linaro.org
Subject: Re: [PATCH v4 5/9] iio: adc: meson_saradc: annotate the lock helpers
Date: Tue, 27 Oct 2026 13:08:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-186603@kernel.org> (raw)
In-Reply-To: <20261027124954.110697-6-zoone.rupert@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] iio: adc: meson_saradc: context analysis warning in meson_sar_adc_hw_disable()
--
commit ab37c3948447f440afeebef2fb0a7a0fdf5e9e63
Author: Rupesh Majhi <zoone.rupert@gmail.com>
iio: adc: meson_saradc: annotate the lock helpers
This patch adds __cond_acquires() and __releases() context analysis
annotations to meson_sar_adc_lock() and meson_sar_adc_unlock() so that
compiler context analysis tracks priv->lock across their callers.
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 2b003fd5afeba..3c1bc22741296 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -578,6 +578,7 @@ static void meson_sar_adc_stop_sample_engine(struct iio_dev *indio_dev)
> }
>
> static int meson_sar_adc_lock(struct iio_dev *indio_dev)
> + __cond_acquires(0, &((struct meson_sar_adc_priv *)iio_priv(indio_dev))->lock)
> {
> struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
> int val, ret;
> @@ -608,6 +609,7 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
> }
>
> static void meson_sar_adc_unlock(struct iio_dev *indio_dev)
> + __releases(&((struct meson_sar_adc_priv *)iio_priv(indio_dev))->lock)
[Severity: Medium]
Does adding these annotations trigger a -Wthread-safety-analysis warning in
meson_sar_adc_hw_disable() when context analysis is enabled?
In drivers/iio/adc/meson_saradc.c:meson_sar_adc_hw_disable(), the caller logs
an error if meson_sar_adc_lock() fails, but continues execution rather than
returning early:
ret = meson_sar_adc_lock(indio_dev);
if (ret)
dev_err(indio_dev->dev.parent, "Failed to lock ADC (%pE)\n", ERR_PTR(ret));
clk_disable_unprepare(priv->adc_clk);
regmap_clear_bits(priv->regmap, MESON_SAR_ADC_REG3,
MESON_SAR_ADC_REG3_ADC_EN);
meson_sar_adc_set_bandgap(indio_dev, false);
regulator_disable(priv->vref);
if (!ret)
meson_sar_adc_unlock(indio_dev);
Because the error branch falls through, the locked (ret == 0) and unlocked
(ret != 0) control-flow paths merge at clk_disable_unprepare(priv->adc_clk)
with mismatched lock sets, followed by a conditional unlock at if (!ret).
When building with CONFIG_MESON_SARADC=y and CONFIG_WARN_CONTEXT_ANALYSIS=y
(and CONTEXT_ANALYSIS := y enabled for IIO drivers), wouldn't Clang warn that
priv->lock is not held on every path through here and on the conditional
release in meson_sar_adc_unlock(), unless meson_sar_adc_hw_disable() is also
annotated with __context_unsafe() or its control flow is restructured?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027124954.110697-1-zoone.rupert@gmail.com?part=5
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-10-27 13:08 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 12:49 [PATCH v4 0/9] iio: enable context analysis for all drivers Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 12:49 ` [PATCH v4 1/9] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 12:49 ` [PATCH v4 2/9] iio: core: annotate the conditional mode claims Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-28 3:18 ` Jonathan Cameron
2026-10-28 3:18 ` Jonathan Cameron
2026-10-28 3:25 ` Jonathan Cameron
2026-10-28 3:25 ` Jonathan Cameron
2026-10-27 12:49 ` [PATCH v4 3/9] iio: core: mark the mode lock helpers __context_unsafe Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 12:49 ` [PATCH v4 4/9] iio: accel: kionix-kx022a: annotate the lock helpers Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-28 6:16 ` Matti Vaittinen
2026-10-28 6:16 ` Matti Vaittinen
2026-10-27 12:49 ` [PATCH v4 5/9] iio: adc: meson_saradc: " Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 13:08 ` sashiko-bot [this message]
2026-10-27 12:49 ` [PATCH v4 6/9] iio: buffer-dma: annotate the queue " Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 12:49 ` [PATCH v4 7/9] iio: light: opt3001: mark the interrupt handler __context_unsafe Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 12:49 ` [PATCH v4 8/9] iio: light: veml6031x00: annotate the event enable helpers Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 16:52 ` Javier Carrasco
2026-10-27 16:52 ` Javier Carrasco
2026-10-27 12:49 ` [PATCH v4 9/9] iio: enable context analysis for all drivers Rupesh Majhi
2026-10-27 12:49 ` Rupesh Majhi
2026-10-27 15:09 ` Kim Jinseob
2026-10-27 15:09 ` Kim Jinseob
2026-10-27 16:14 ` Andy Shevchenko
2026-10-27 16:14 ` Andy Shevchenko
2026-10-27 17:21 ` Marco Elver
2026-10-27 17:21 ` Marco Elver
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=sashiko-outbox-186603@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zoone.rupert@gmail.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.