Commit 0f65f59e authored by Angelo Dureghello's avatar Angelo Dureghello Committed by Jonathan Cameron
Browse files

iio: adc: ad7606: protect register access



Protect register (and bus) access from concurrent
read / write. Needed in the backend operating mode.

Signed-off-by: default avatarAngelo 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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 79c47485
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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];