summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/imx7d_adc.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2023-01-03 10:32:12 +0300
committerMaxime Ripard <maxime@cerno.tech>2023-01-03 10:32:12 +0300
commit2c55d703391acf7e9101da596d0c15ee03b318a3 (patch)
tree422ef671343624b56d333b47d20a538eeedbfe10 /drivers/iio/adc/imx7d_adc.c
parent92d43bd3bc9728c1fb114d7011d46f5ea9489e28 (diff)
parent88603b6dc419445847923fcb7fe5080067a30f98 (diff)
downloadlinux-2c55d703391acf7e9101da596d0c15ee03b318a3.tar.xz
Merge drm/drm-fixes into drm-misc-fixes
Let's start the fixes cycle. Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Diffstat (limited to 'drivers/iio/adc/imx7d_adc.c')
-rw-r--r--drivers/iio/adc/imx7d_adc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 86caff1d006b..22da81bac97f 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
@@ -108,7 +109,8 @@ struct imx7d_adc {
struct device *dev;
void __iomem *regs;
struct clk *clk;
-
+ /* lock to protect against multiple access to the device */
+ struct mutex lock;
u32 vref_uv;
u32 value;
u32 channel;
@@ -293,7 +295,7 @@ static int imx7d_adc_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
- mutex_lock(&indio_dev->mlock);
+ mutex_lock(&info->lock);
reinit_completion(&info->completion);
channel = chan->channel & 0x03;
@@ -303,16 +305,16 @@ static int imx7d_adc_read_raw(struct iio_dev *indio_dev,
ret = wait_for_completion_interruptible_timeout
(&info->completion, IMX7D_ADC_TIMEOUT);
if (ret == 0) {
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&info->lock);
return -ETIMEDOUT;
}
if (ret < 0) {
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&info->lock);
return ret;
}
*val = info->value;
- mutex_unlock(&indio_dev->mlock);
+ mutex_unlock(&info->lock);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
@@ -531,6 +533,8 @@ static int imx7d_adc_probe(struct platform_device *pdev)
if (ret)
return ret;
+ mutex_init(&info->lock);
+
ret = devm_iio_device_register(dev, indio_dev);
if (ret) {
dev_err(&pdev->dev, "Couldn't register the device.\n");