mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 07:59:42 -04:00
iio: temp: maxim_thermocouple: 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. Tidy up a few direct returns whilst here. Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Link: https://patch.msgid.link/20250331121317.1694135-35-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
@@ -183,40 +183,35 @@ static int maxim_thermocouple_read_raw(struct iio_dev *indio_dev,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
struct maxim_thermocouple_data *data = iio_priv(indio_dev);
|
||||
int ret = -EINVAL;
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
ret = iio_device_claim_direct_mode(indio_dev);
|
||||
if (!iio_device_claim_direct(indio_dev))
|
||||
return -EBUSY;
|
||||
|
||||
ret = maxim_thermocouple_read(data, chan, val);
|
||||
iio_device_release_direct(indio_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = maxim_thermocouple_read(data, chan, val);
|
||||
iio_device_release_direct_mode(indio_dev);
|
||||
|
||||
if (!ret)
|
||||
return IIO_VAL_INT;
|
||||
|
||||
break;
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
switch (chan->channel2) {
|
||||
case IIO_MOD_TEMP_AMBIENT:
|
||||
*val = 62;
|
||||
*val2 = 500000; /* 1000 * 0.0625 */
|
||||
ret = IIO_VAL_INT_PLUS_MICRO;
|
||||
break;
|
||||
return IIO_VAL_INT_PLUS_MICRO;
|
||||
default:
|
||||
*val = 250; /* 1000 * 0.25 */
|
||||
ret = IIO_VAL_INT;
|
||||
return IIO_VAL_INT;
|
||||
}
|
||||
break;
|
||||
case IIO_CHAN_INFO_THERMOCOUPLE_TYPE:
|
||||
*val = data->tc_type;
|
||||
ret = IIO_VAL_CHAR;
|
||||
break;
|
||||
return IIO_VAL_CHAR;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct iio_info maxim_thermocouple_info = {
|
||||
|
||||
Reference in New Issue
Block a user