diff options
| author | Angelo Dureghello <adureghello@baylibre.com> | 2025-02-10 19:10:57 +0300 |
|---|---|---|
| committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2025-02-11 22:56:25 +0300 |
| commit | 0f65f59e632d942cccffd12c36036c24eb7037eb (patch) | |
| tree | 05c79cbe378a5210517e27eb526f3e7ed09d6945 | |
| parent | 79c47485e438c8ea6e08ed9b6572158500f8c4cd (diff) | |
| download | linux-0f65f59e632d942cccffd12c36036c24eb7037eb.tar.xz | |
iio: adc: ad7606: protect register access
Protect register (and bus) access from concurrent
read / write. Needed in the backend operating mode.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250210-wip-bl-ad7606_add_backend_sw_mode-v4-7-160df18b1da7@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| -rw-r--r-- | drivers/iio/adc/ad7606.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index b88c3e248b7e..612fe73396d7 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -862,7 +862,12 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, } val = (val * MICRO) + val2; i = find_closest(val, scale_avail_uv, cs->num_scales); + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret < 0) + return ret; ret = st->write_scale(indio_dev, ch, i + cs->reg_offset); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; cs->range = i; @@ -873,7 +878,12 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, return -EINVAL; i = find_closest(val, st->oversampling_avail, st->num_os_ratios); + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret < 0) + return ret; ret = st->write_os(indio_dev, i); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; st->oversampling = st->oversampling_avail[i]; |
