Re: [PATCH RFC 4/6] iio: light: vcnl4000: Use cleanup.h for IIO locks

From: David Lechner

Date: Wed Dec 03 2025 - 17:19:04 EST


On 12/3/25 1:18 PM, Kurt Borja wrote:
> Use ACQUIRE() for iio_device_claim_direct().
>
> Signed-off-by: Kurt Borja <kuurtb@xxxxxxxxx>
> ---
> drivers/iio/light/vcnl4000.c | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 4dbb2294a843..55e5060ce337 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -25,6 +25,7 @@
> #include <linux/pm_runtime.h>
> #include <linux/interrupt.h>
> #include <linux/units.h>
> +#include <linux/cleanup.h>
>
> #include <linux/iio/buffer.h>
> #include <linux/iio/events.h>
> @@ -1148,36 +1149,27 @@ static int vcnl4010_write_raw(struct iio_dev *indio_dev,
> struct iio_chan_spec const *chan,
> int val, int val2, long mask)
> {
> - int ret;
> struct vcnl4000_data *data = iio_priv(indio_dev);
>
> - if (!iio_device_claim_direct(indio_dev))
> + ACQUIRE(iio_device_claim_direct, busy)(indio_dev);
> + if (ACQUIRE_ERR(iio_device_claim_direct, &busy))

Calling the cleanup variable `busy` seems odd to me since if
we successfully make the claim, busy will be non-null and
therefore `if (busy)` would evaluate as true even though
it wasn't "busy". I would call it `claim` to match
iio_device_claim_direct().