mirror of
https://github.com/torvalds/linux.git
synced 2026-05-22 06:01:53 +02:00
iio: accel: kx022a: Switch to sparse friendly iio_device_claim/release_direct()
These new functions allow sparse to find failures to release direct mode reducing chances of bugs over the claim_direct_mode() functions that are deprecated. Cc: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250217140135.896574-6-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
305f655d05
commit
6c21fc09c3
|
|
@ -577,13 +577,12 @@ static int kx022a_write_raw(struct iio_dev *idev,
|
|||
* issues if users trust the watermark to be reached within known
|
||||
* time-limit).
|
||||
*/
|
||||
ret = iio_device_claim_direct_mode(idev);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!iio_device_claim_direct(idev))
|
||||
return -EBUSY;
|
||||
|
||||
ret = __kx022a_write_raw(idev, chan, val, val2, mask);
|
||||
|
||||
iio_device_release_direct_mode(idev);
|
||||
iio_device_release_direct(idev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -624,15 +623,14 @@ static int kx022a_read_raw(struct iio_dev *idev,
|
|||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = iio_device_claim_direct_mode(idev);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!iio_device_claim_direct(idev))
|
||||
return -EBUSY;
|
||||
|
||||
mutex_lock(&data->mutex);
|
||||
ret = kx022a_get_axis(data, chan, val);
|
||||
mutex_unlock(&data->mutex);
|
||||
|
||||
iio_device_release_direct_mode(idev);
|
||||
iio_device_release_direct(idev);
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user