Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: light: vcnl4000: Use IIO cleanup helpers

Use IIO_DEV_ACQUIRE_DIRECT_MODE() helper to automatically release direct
mode.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Kurt Borja and committed by
Jonathan Cameron
6a3fe0fc 7a38b75d

+18 -31
+18 -31
drivers/iio/light/vcnl4000.c
··· 1078 1078 1079 1079 switch (mask) { 1080 1080 case IIO_CHAN_INFO_RAW: 1081 - case IIO_CHAN_INFO_SCALE: 1082 - if (!iio_device_claim_direct(indio_dev)) 1081 + case IIO_CHAN_INFO_SCALE: { 1082 + IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim); 1083 + if (IIO_DEV_ACQUIRE_FAILED(claim)) 1083 1084 return -EBUSY; 1084 1085 1085 1086 /* Protect against event capture. */ 1086 - if (vcnl4010_is_in_periodic_mode(data)) { 1087 - ret = -EBUSY; 1088 - } else { 1089 - ret = vcnl4000_read_raw(indio_dev, chan, val, val2, 1090 - mask); 1091 - } 1087 + if (vcnl4010_is_in_periodic_mode(data)) 1088 + return -EBUSY; 1092 1089 1093 - iio_device_release_direct(indio_dev); 1094 - return ret; 1090 + return vcnl4000_read_raw(indio_dev, chan, val, val2, mask); 1091 + } 1095 1092 case IIO_CHAN_INFO_SAMP_FREQ: 1096 1093 switch (chan->type) { 1097 1094 case IIO_PROXIMITY: ··· 1145 1148 struct iio_chan_spec const *chan, 1146 1149 int val, int val2, long mask) 1147 1150 { 1148 - int ret; 1149 1151 struct vcnl4000_data *data = iio_priv(indio_dev); 1150 1152 1151 - if (!iio_device_claim_direct(indio_dev)) 1153 + IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim); 1154 + if (IIO_DEV_ACQUIRE_FAILED(claim)) 1152 1155 return -EBUSY; 1153 1156 1154 1157 /* Protect against event capture. */ 1155 - if (vcnl4010_is_in_periodic_mode(data)) { 1156 - ret = -EBUSY; 1157 - goto end; 1158 - } 1158 + if (vcnl4010_is_in_periodic_mode(data)) 1159 + return -EBUSY; 1159 1160 1160 1161 switch (mask) { 1161 1162 case IIO_CHAN_INFO_SAMP_FREQ: 1162 1163 switch (chan->type) { 1163 1164 case IIO_PROXIMITY: 1164 - ret = vcnl4010_write_proxy_samp_freq(data, val, val2); 1165 - goto end; 1165 + return vcnl4010_write_proxy_samp_freq(data, val, val2); 1166 1166 default: 1167 - ret = -EINVAL; 1168 - goto end; 1167 + return -EINVAL; 1169 1168 } 1170 1169 default: 1171 - ret = -EINVAL; 1172 - goto end; 1170 + return -EINVAL; 1173 1171 } 1174 - 1175 - end: 1176 - iio_device_release_direct(indio_dev); 1177 - return ret; 1178 1172 } 1179 1173 1180 1174 static int vcnl4010_read_event(struct iio_dev *indio_dev, ··· 1426 1438 static int vcnl4010_config_threshold(struct iio_dev *indio_dev, bool state) 1427 1439 { 1428 1440 struct vcnl4000_data *data = iio_priv(indio_dev); 1429 - int ret; 1430 1441 1431 1442 if (state) { 1432 - if (!iio_device_claim_direct(indio_dev)) 1443 + IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim); 1444 + if (IIO_DEV_ACQUIRE_FAILED(claim)) 1433 1445 return -EBUSY; 1434 - ret = vcnl4010_config_threshold_enable(data); 1435 - iio_device_release_direct(indio_dev); 1436 - return ret; 1446 + 1447 + return vcnl4010_config_threshold_enable(data); 1437 1448 } else { 1438 1449 return vcnl4010_config_threshold_disable(data); 1439 1450 }