mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 12:53:04 -04:00
iio: adc: ti-ads1015: 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: Marek Vasut <marex@denx.de> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250309165819.1346684-7-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
@@ -569,11 +569,10 @@ static int ads1015_read_raw(struct iio_dev *indio_dev,
|
||||
guard(mutex)(&data->lock);
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!iio_device_claim_direct(indio_dev))
|
||||
return -EBUSY;
|
||||
ret = __ads1015_read_info_raw(data, chan, val);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
iio_device_release_direct(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -786,16 +785,15 @@ static int ads1015_write_event_config(struct iio_dev *indio_dev,
|
||||
guard(mutex)(&data->lock);
|
||||
|
||||
/* Prevent from enabling both buffer and event at a time */
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!iio_device_claim_direct(indio_dev))
|
||||
return -EBUSY;
|
||||
|
||||
if (state)
|
||||
ret = ads1015_enable_event_config(data, chan, comp_mode);
|
||||
else
|
||||
ret = ads1015_disable_event_config(data, chan, comp_mode);
|
||||
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
iio_device_release_direct(indio_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user