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

iio: dac: ad8460: Stop using iio_device_claim_direct_scoped()

This complex cleanup.h use case of conditional guards has proved
to be more trouble that it is worth in terms of false positive compiler
warnings and hard to read code.

Move directly to the new claim/release_direct() that allow sparse
to check for unbalanced context.

Cc: Mariel Tinaco <Mariel.Tinaco@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250209180624.701140-24-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

+12 -6
+12 -6
drivers/iio/dac/ad8460.c
··· 264 264 if (ret) 265 265 return ret; 266 266 267 - iio_device_claim_direct_scoped(return -EBUSY, indio_dev) 268 - return ad8460_enable_apg_mode(state, toggle_en); 269 - unreachable(); 267 + if (!iio_device_claim_direct(indio_dev)) 268 + return -EBUSY; 269 + 270 + ret = ad8460_enable_apg_mode(state, toggle_en); 271 + iio_device_release_direct(indio_dev); 272 + return ret; 270 273 } 271 274 272 275 static ssize_t ad8460_read_powerdown(struct iio_dev *indio_dev, uintptr_t private, ··· 424 421 long mask) 425 422 { 426 423 struct ad8460_state *state = iio_priv(indio_dev); 424 + int ret; 427 425 428 426 switch (mask) { 429 427 case IIO_CHAN_INFO_RAW: 430 428 switch (chan->type) { 431 429 case IIO_VOLTAGE: 432 - iio_device_claim_direct_scoped(return -EBUSY, indio_dev) 433 - return ad8460_set_sample(state, val); 434 - unreachable(); 430 + if (!iio_device_claim_direct(indio_dev)) 431 + return -EBUSY; 432 + ret = ad8460_set_sample(state, val); 433 + iio_device_release_direct(indio_dev); 434 + return ret; 435 435 case IIO_CURRENT: 436 436 return regmap_write(state->regmap, AD8460_CTRL_REG(0x04), 437 437 FIELD_PREP(AD8460_QUIESCENT_CURRENT_MSK, val));