Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: meson_saradc: do not use internal iio_dev lock

The iio_device lock is only meant for internal use. Hence define a
device local lock to protect against concurrent accesses.

While at it, properly include "mutex.h" for mutex related APIs.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20221004134909.1692021-7-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sá and committed by
Jonathan Cameron
d0c09264 da8091f8

+8 -3
+8 -3
drivers/iio/adc/meson_saradc.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/iio/iio.h> 14 14 #include <linux/module.h> 15 + #include <linux/mutex.h> 15 16 #include <linux/nvmem-consumer.h> 16 17 #include <linux/interrupt.h> 17 18 #include <linux/of.h> ··· 277 276 struct clk *adc_div_clk; 278 277 struct clk_divider clk_div; 279 278 struct completion done; 279 + /* lock to protect against multiple access to the device */ 280 + struct mutex lock; 280 281 int calibbias; 281 282 int calibscale; 282 283 struct regmap *tsc_regmap; ··· 489 486 struct meson_sar_adc_priv *priv = iio_priv(indio_dev); 490 487 int val, ret; 491 488 492 - mutex_lock(&indio_dev->mlock); 489 + mutex_lock(&priv->lock); 493 490 494 491 if (priv->param->has_bl30_integration) { 495 492 /* prevent BL30 from using the SAR ADC while we are using it */ ··· 507 504 !(val & MESON_SAR_ADC_DELAY_BL30_BUSY), 508 505 1, 10000); 509 506 if (ret) { 510 - mutex_unlock(&indio_dev->mlock); 507 + mutex_unlock(&priv->lock); 511 508 return ret; 512 509 } 513 510 } ··· 524 521 regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, 525 522 MESON_SAR_ADC_DELAY_KERNEL_BUSY, 0); 526 523 527 - mutex_unlock(&indio_dev->mlock); 524 + mutex_unlock(&priv->lock); 528 525 } 529 526 530 527 static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev) ··· 1252 1249 ret = meson_sar_adc_init(indio_dev); 1253 1250 if (ret) 1254 1251 goto err; 1252 + 1253 + mutex_init(&priv->lock); 1255 1254 1256 1255 ret = meson_sar_adc_hw_enable(indio_dev); 1257 1256 if (ret)