Commit 9e182654 authored by Matt Ranostay's avatar Matt Ranostay Committed by Jonathan Cameron
Browse files

iio: proximity: lidar: switch to iio_device_claim_*_mode helpers



Switch from using indio_dev->mlock to the iio_device_claim_*_mode
helper functions.

Signed-off-by: default avatarMatt Ranostay <mranostay@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent bc2e1126
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -203,22 +203,19 @@ static int lidar_read_raw(struct iio_dev *indio_dev,
	struct lidar_data *data = iio_priv(indio_dev);
	int ret = -EINVAL;

	mutex_lock(&indio_dev->mlock);

	if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) {
		ret = -EBUSY;
		goto error_busy;
	}

	switch (mask) {
	case IIO_CHAN_INFO_RAW: {
		u16 reg;

		if (iio_device_claim_direct_mode(indio_dev))
			return -EBUSY;

		ret = lidar_get_measurement(data, &reg);
		if (!ret) {
			*val = reg;
			ret = IIO_VAL_INT;
		}
		iio_device_release_direct_mode(indio_dev);
		break;
	}
	case IIO_CHAN_INFO_SCALE:
@@ -228,9 +225,6 @@ static int lidar_read_raw(struct iio_dev *indio_dev,
		break;
	}

error_busy:
	mutex_unlock(&indio_dev->mlock);

	return ret;
}