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

From: Joshua Crofts

Date: Mon Oct 05 2026 - 09:13:30 EST


On Mon, 5 Oct 2026 15:11:56 +0530
Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@xxxxxxx> 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@xxxxxxx>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@xxxxxxx>
> Signed-off-by: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@xxxxxxx>
> ---

...

> @@ -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