Re: [PATCH v2 23/27] iio: dac: ad8460: Stop using iio_device_claim_direct_scoped()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2025-02-09 at 18:06 +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> ---

Reviewed-by: Nuno Sa <nuno.sa@xxxxxxxxxx>

>  drivers/iio/dac/ad8460.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad8460.c b/drivers/iio/dac/ad8460.c
> index 535ee3105af6..6e45686902dd 100644
> --- a/drivers/iio/dac/ad8460.c
> +++ b/drivers/iio/dac/ad8460.c
> @@ -264,9 +264,12 @@ static ssize_t ad8460_write_toggle_en(struct iio_dev
> *indio_dev, uintptr_t priva
>  	if (ret)
>  		return ret;
>  
> -	iio_device_claim_direct_scoped(return -EBUSY, indio_dev)
> -		return ad8460_enable_apg_mode(state, toggle_en);
> -	unreachable();
> +	if (!iio_device_claim_direct(indio_dev))
> +		return -EBUSY;
> +
> +	ret = ad8460_enable_apg_mode(state, toggle_en);
> +	iio_device_release_direct(indio_dev);
> +	return ret;
>  }
>  
>  static ssize_t ad8460_read_powerdown(struct iio_dev *indio_dev, uintptr_t
> private,
> @@ -421,14 +424,17 @@ static int ad8460_write_raw(struct iio_dev *indio_dev,
>  			    long mask)
>  {
>  	struct ad8460_state *state = iio_priv(indio_dev);
> +	int ret;
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_RAW:
>  		switch (chan->type) {
>  		case IIO_VOLTAGE:
> -			iio_device_claim_direct_scoped(return -EBUSY,
> indio_dev)
> -				return ad8460_set_sample(state, val);
> -			unreachable();
> +			if (!iio_device_claim_direct(indio_dev))
> +				return -EBUSY;
> +			ret = ad8460_set_sample(state, val);
> +			iio_device_release_direct(indio_dev);
> +			return ret;
>  		case IIO_CURRENT:
>  			return regmap_write(state->regmap,
> AD8460_CTRL_REG(0x04),
>  					   
> FIELD_PREP(AD8460_QUIESCENT_CURRENT_MSK, val));






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux