iio: humidity: hdc2010: 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. Acked-by: Eugene Zaikonnikov <ez@norphonic.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Link: https://patch.msgid.link/20250331121317.1694135-13-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>pull/1259/head
parent
0d51e888e0
commit
35a34861ce
|
|
@ -169,13 +169,12 @@ static int hdc2010_read_raw(struct iio_dev *indio_dev,
|
|||
*val = hdc2010_get_heater_status(data);
|
||||
return IIO_VAL_INT;
|
||||
}
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!iio_device_claim_direct(indio_dev))
|
||||
return -EBUSY;
|
||||
mutex_lock(&data->lock);
|
||||
ret = hdc2010_get_prim_measurement_word(data, chan);
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
iio_device_release_direct(indio_dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
*val = ret;
|
||||
|
|
@ -184,13 +183,12 @@ static int hdc2010_read_raw(struct iio_dev *indio_dev,
|
|||
case IIO_CHAN_INFO_PEAK: {
|
||||
int ret;
|
||||
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (!iio_device_claim_direct(indio_dev))
|
||||
return -EBUSY;
|
||||
mutex_lock(&data->lock);
|
||||
ret = hdc2010_get_peak_measurement_byte(data, chan);
|
||||
mutex_unlock(&data->lock);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
iio_device_release_direct(indio_dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
/* Scaling up the value so we can use same offset as RAW */
|
||||
|
|
|
|||
Loading…
Reference in New Issue