[PATCH v4 1/9] iio: adc: qcom-spmi-adc5-gen3: fix lock annotations on mutex helpers
Rupesh Majhi
zoone.rupert at gmail.com
Tue Oct 27 05:49:46 PDT 2026
Since commit 5b63d0ae94cc ("compiler-context-analysis: Remove Sparse
support"), __acquires() and __releases() only feed context analysis.
Their argument is parsed before the function body, where only dev is in
scope, so with analysis enabled for this file the build fails:
error: use of undeclared identifier 'adc'
Name the lock through dev, the same way the bodies find it. The analysis
then also checks that the helpers really take and drop it.
Suggested-by: Bart Van Assche <bvanassche at acm.org>
Signed-off-by: Rupesh Majhi <zoone.rupert at gmail.com>
---
Cc: Marco Elver <elver at google.com>
Cc: Bart Van Assche <bvanassche at acm.org>
Cc: Jishnu Prakash <jishnu.prakash at oss.qualcomm.com>
v4: name the lock through dev instead of __context_unsafe() (Bart),
now the first patch of the series that enables the analysis (Jonathan)
v3: drop Fixes tag (Jonathan), trailer cleanup (Andy)
https://lore.kernel.org/linux-iio/20261025191510.22261-1-zoone.rupert@gmail.com/
v2: __context_unsafe() explained in commit message (Andy)
https://lore.kernel.org/linux-iio/20261021052435.112686-1-zoone.rupert@gmail.com/
v1: https://lore.kernel.org/linux-iio/20261003214516.128573-1-zoone.rupert@gmail.com/
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..09013c6e44a0 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)
+ __acquires(&((struct adc5_chip *)iio_priv(dev_get_drvdata(dev->parent)))->lock)
{
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)
+ __releases(&((struct adc5_chip *)iio_priv(dev_get_drvdata(dev->parent)))->lock)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev->parent);
struct adc5_chip *adc = iio_priv(indio_dev);
--
2.43.0
More information about the linux-arm-kernel
mailing list