[PATCH v4 06/15] iio: adc: xilinx-xadc: Use guard()/scoped_guard() for spinlock locking

Joshua Crofts joshua.crofts1 at gmail.com
Mon Oct 5 06:13:17 PDT 2026


On Mon, 5 Oct 2026 15:11:56 +0530
Dileep Kumar Nagavarapu <dileepkumar.nagavarapu at amd.com> wrote:

> Use guard() and scoped_guard() helpers for spinlock handling
> instead of spin_lock/spin_unlock sequences.
> 
> This removes the need for explicit spin_unlock()
> 
> No functional change intended.
> 
> Co-developed-by: Sai Krishna Potthuri <sai.krishna.potthuri at amd.com>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri at amd.com>
> Signed-off-by: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu at amd.com>
> ---

...

> @@ -677,15 +670,15 @@ static int xadc_trigger_set_state(struct iio_trigger *trigger, bool state)
>  		xadc->trigger = NULL;
>  	}
>  
> -	spin_lock_irqsave(&xadc->lock, flags);
> -	xadc_read_reg(xadc, XADC_AXI_REG_IPIER, &val);
> -	xadc_write_reg(xadc, XADC_AXI_REG_IPISR, XADC_AXI_INT_EOS);
> -	if (state)
> -		val |= XADC_AXI_INT_EOS;
> -	else
> -		val &= ~XADC_AXI_INT_EOS;
> -	xadc_write_reg(xadc, XADC_AXI_REG_IPIER, val);
> -	spin_unlock_irqrestore(&xadc->lock, flags);
> +	scoped_guard(spinlock_irqsave, &xadc->lock) {
> +		xadc_read_reg(xadc, XADC_AXI_REG_IPIER, &val);
> +		xadc_write_reg(xadc, XADC_AXI_REG_IPISR, XADC_AXI_INT_EOS);
> +		if (state)
> +			val |= XADC_AXI_INT_EOS;
> +		else
> +			val &= ~XADC_AXI_INT_EOS;
> +		xadc_write_reg(xadc, XADC_AXI_REG_IPIER, val);
> +	}
>  
>  err_out:
>  	mutex_unlock(&xadc->mutex);

Since you've moved the spinlocks to use guard, what about replacing
mutex_lock/unlock as well?

Otherwise this seems fine.

-- 
Kind regards,
Joshua Crofts



More information about the linux-arm-kernel mailing list