Commit 160b37f4 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron
Browse files

iio: gyro: adis16260: replace mlock with ADIS lib's state_lock



This change uses the ADIS library's state_lock to protect the state of the
`max_speed_hz` change that is done during the set of the sampling
frequency.

Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent d693845d
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -293,7 +293,7 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
		addr = adis16260_addresses[chan->scan_index][1];
		addr = adis16260_addresses[chan->scan_index][1];
		return adis_write_reg_16(adis, addr, val);
		return adis_write_reg_16(adis, addr, val);
	case IIO_CHAN_INFO_SAMP_FREQ:
	case IIO_CHAN_INFO_SAMP_FREQ:
		mutex_lock(&indio_dev->mlock);
		mutex_lock(&adis->state_lock);
		if (spi_get_device_id(adis->spi)->driver_data)
		if (spi_get_device_id(adis->spi)->driver_data)
			t = 256 / val;
			t = 256 / val;
		else
		else
@@ -308,9 +308,9 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
			adis->spi->max_speed_hz = ADIS16260_SPI_SLOW;
			adis->spi->max_speed_hz = ADIS16260_SPI_SLOW;
		else
		else
			adis->spi->max_speed_hz = ADIS16260_SPI_FAST;
			adis->spi->max_speed_hz = ADIS16260_SPI_FAST;
		ret = adis_write_reg_8(adis, ADIS16260_SMPL_PRD, t);
		ret = __adis_write_reg_8(adis, ADIS16260_SMPL_PRD, t);


		mutex_unlock(&indio_dev->mlock);
		mutex_unlock(&adis->state_lock);
		return ret;
		return ret;
	}
	}
	return -EINVAL;
	return -EINVAL;