* [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers
@ 2026-10-03 21:45 Rupesh Majhi
2026-10-04 8:42 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Rupesh Majhi @ 2026-10-03 21:45 UTC (permalink / raw)
To: Andy Shevchenko, David Lechner, Jishnu Prakash, Jonathan Cameron,
Nuno Sá
Cc: linux-arm-msm, linux-iio, linux-kernel, Rupesh Majhi
The __acquires() and __releases() on adc5_gen3_mutex_lock() and
adc5_gen3_mutex_unlock() name adc, a local declared in the body. With
context analysis enabled for this file, the build fails:
error: use of undeclared identifier 'adc'
The lock and unlock are split across these two helpers for the ADC_TM
driver, so mark them __context_unsafe() instead.
Fixes: baff45179e90 ("iio: adc: Add support for QCOM PMIC5 Gen3 ADC")
Assisted-by: LLM
Signed-off-by: Rupesh Majhi <zoone.rupert@gmail.com>
---
Found by building with CONTEXT_ANALYSIS_qcom-spmi-adc5-gen3.o=y, which the
driver does not set today. Build tested only, no hardware here.
drivers/iio/adc/qcom-spmi-adc5-gen3.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
index c68c6c5f6aca..6a3cabedf4e8 100644
--- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
+++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
@@ -663,7 +663,7 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
}
void adc5_gen3_mutex_lock(struct device *dev)
- __acquires(&adc->lock)
+ __context_unsafe(/* returns with adc->lock held */)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct adc5_chip *adc = iio_priv(indio_dev);
@@ -673,7 +673,7 @@ void adc5_gen3_mutex_lock(struct device *dev)
EXPORT_SYMBOL_NS_GPL(adc5_gen3_mutex_lock, "QCOM_SPMI_ADC5_GEN3");
void adc5_gen3_mutex_unlock(struct device *dev)
- __releases(&adc->lock)
+ __context_unsafe(/* releases adc->lock */)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct adc5_chip *adc = iio_priv(indio_dev);
base-commit: 04434a1d0f311d76b1f15fa987918b471a0b8c6a
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers
2026-10-03 21:45 [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers Rupesh Majhi
@ 2026-10-04 8:42 ` Andy Shevchenko
2026-10-18 21:38 ` Rupesh Majhi
2026-10-18 23:45 ` Jonathan Cameron
0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-10-04 8:42 UTC (permalink / raw)
To: Rupesh Majhi
Cc: Andy Shevchenko, David Lechner, Jishnu Prakash, Jonathan Cameron,
Nuno Sá,
linux-arm-msm, linux-iio, linux-kernel
On Sun, Oct 04, 2026 at 12:45:16AM +0300, Rupesh Majhi wrote:
> The __acquires() and __releases() on adc5_gen3_mutex_lock() and
> adc5_gen3_mutex_unlock() name adc, a local declared in the body. With
> context analysis enabled for this file, the build fails:
>
> error: use of undeclared identifier 'adc'
>
> The lock and unlock are split across these two helpers for the ADC_TM
> driver, so mark them __context_unsafe() instead.
Doesn't sound right to me. The __acquires() and __releases() IIRC are sparse
annotations. If clang has something special, it needs to be addressed in
the compiler-clang.h, no?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers
2026-10-04 8:42 ` Andy Shevchenko
@ 2026-10-18 21:38 ` Rupesh Majhi
2026-10-19 10:01 ` Andy Shevchenko
2026-10-18 23:45 ` Jonathan Cameron
1 sibling, 1 reply; 5+ messages in thread
From: Rupesh Majhi @ 2026-10-18 21:38 UTC (permalink / raw)
To: andriy.shevchenko
Cc: Andy Shevchenko, David Lechner, Jishnu Prakash, Jonathan Cameron,
Nuno Sá,
linux-arm-msm, linux-iio, linux-kernel
On Sun, Oct 04, 2026 at 11:42:56AM +0300, Andy Shevchenko wrote:
> On Sun, Oct 04, 2026 at 12:45:16AM +0300, Rupesh Majhi wrote:
> > The __acquires() and __releases() on adc5_gen3_mutex_lock() and
> > adc5_gen3_mutex_unlock() name adc, a local declared in the body. With
> > context analysis enabled for this file, the build fails:
> >
> > error: use of undeclared identifier 'adc'
> >
> > The lock and unlock are split across these two helpers for the ADC_TM
> > driver, so mark them __context_unsafe() instead.
>
> Doesn't sound right to me. The __acquires() and __releases() IIRC are sparse
> annotations. If clang has something special, it needs to be addressed in
> the compiler-clang.h, no?
Sparse support for them went away in v7.0 with 5b63d0ae94cc
("compiler-context-analysis: Remove Sparse support"). They are now
defined in compiler-context-analysis.h and expand to clang's
acquire_capability() and release_capability(), or to nothing.
The argument is parsed at the declaration, where only dev is in scope,
so no header change can make adc visible there.
Sorry for the slow reply.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers
2026-10-18 21:38 ` Rupesh Majhi
@ 2026-10-19 10:01 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-10-19 10:01 UTC (permalink / raw)
To: Rupesh Majhi
Cc: Andy Shevchenko, David Lechner, Jishnu Prakash, Jonathan Cameron,
Nuno Sá,
linux-arm-msm, linux-iio, linux-kernel
On Mon, Oct 19, 2026 at 12:38:12AM +0300, Rupesh Majhi wrote:
> On Sun, Oct 04, 2026 at 11:42:56AM +0300, Andy Shevchenko wrote:
> > On Sun, Oct 04, 2026 at 12:45:16AM +0300, Rupesh Majhi wrote:
> > > The __acquires() and __releases() on adc5_gen3_mutex_lock() and
> > > adc5_gen3_mutex_unlock() name adc, a local declared in the body. With
> > > context analysis enabled for this file, the build fails:
> > >
> > > error: use of undeclared identifier 'adc'
> > >
> > > The lock and unlock are split across these two helpers for the ADC_TM
> > > driver, so mark them __context_unsafe() instead.
> >
> > Doesn't sound right to me. The __acquires() and __releases() IIRC are sparse
> > annotations. If clang has something special, it needs to be addressed in
> > the compiler-clang.h, no?
>
> Sparse support for them went away in v7.0 with 5b63d0ae94cc
> ("compiler-context-analysis: Remove Sparse support"). They are now
> defined in compiler-context-analysis.h and expand to clang's
> acquire_capability() and release_capability(), or to nothing.
>
> The argument is parsed at the declaration, where only dev is in scope,
> so no header change can make adc visible there.
You need to summarise that in the commit message.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers
2026-10-04 8:42 ` Andy Shevchenko
2026-10-18 21:38 ` Rupesh Majhi
@ 2026-10-18 23:45 ` Jonathan Cameron
1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-10-18 23:45 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rupesh Majhi, Andy Shevchenko, David Lechner, Jishnu Prakash,
Nuno Sá,
linux-arm-msm, linux-iio, linux-kernel, Marco Elver,
Bart Van Assche
On Sun, 4 Oct 2026 11:42:56 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Sun, Oct 04, 2026 at 12:45:16AM +0300, Rupesh Majhi wrote:
> > The __acquires() and __releases() on adc5_gen3_mutex_lock() and
> > adc5_gen3_mutex_unlock() name adc, a local declared in the body. With
> > context analysis enabled for this file, the build fails:
> >
> > error: use of undeclared identifier 'adc'
> >
> > The lock and unlock are split across these two helpers for the ADC_TM
> > driver, so mark them __context_unsafe() instead.
>
> Doesn't sound right to me. The __acquires() and __releases() IIRC are sparse
> annotations. If clang has something special, it needs to be addressed in
> the compiler-clang.h, no?
>
It's in compiler-context-analysis.h and for now I believe is clang
only. Reuses the older sparse definitions. I think the intent is to avoid
churn.
I currently have no idea if this is the right fix. The only users
today are places where a lock is intentionally skipped.
+CC Marco and Bart and putting back the patch content for context.
> diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
> index c68c6c5f6aca..6a3cabedf4e8 100644
> --- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c
> +++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c
> @@ -663,7 +663,7 @@ static int adc5_gen3_add_aux_tm_device(struct adc5_chip *adc)
> }
>
> void adc5_gen3_mutex_lock(struct device *dev)
> - __acquires(&adc->lock)
> + __context_unsafe(/* returns with adc->lock held */)
> {
> struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
> struct adc5_chip *adc = iio_priv(indio_dev);
> @@ -673,7 +673,7 @@ void adc5_gen3_mutex_lock(struct device *dev)
> EXPORT_SYMBOL_NS_GPL(adc5_gen3_mutex_lock, "QCOM_SPMI_ADC5_GEN3");
>
> void adc5_gen3_mutex_unlock(struct device *dev)
> - __releases(&adc->lock)
> + __context_unsafe(/* releases adc->lock */)
> {
> struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
> struct adc5_chip *adc = iio_priv(indio_dev);
>
> base-commit: 04434a1d0f311d76b1f15fa987918b471a0b8c6a
> --
> 2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-19 10:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03 21:45 [PATCH] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers Rupesh Majhi
2026-10-04 8:42 ` Andy Shevchenko
2026-10-18 21:38 ` Rupesh Majhi
2026-10-19 10:01 ` Andy Shevchenko
2026-10-18 23:45 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®