Re: [PATCH v5 07/16] iio: adc: xilinx-xadc: Use guard() for mutex locking
From: Andy Shevchenko
Date: Tue Nov 10 2026 - 11:18:06 EST
On Tue, Nov 10, 2026 at 10:31:52AM +0530, Dileep Kumar Nagavarapu wrote:
> Use guard() helper for mutex handling instead of explicit
> mutex_lock()/mutex_unlock() sequences.
>
> This removes the need for explicit unlocks and the
> error-path labels that only existed to release the mutex,
> simplifying the control flow
>
> No functional change intended
...
> {
> int ret;
>
> - mutex_lock(&xadc->mutex);
> + guard(mutex)(&xadc->mutex);
> ret = _xadc_update_adc_reg(xadc, reg, mask, val);
> - mutex_unlock(&xadc->mutex);
>
> return ret;
> }
I believe somebody already told you two things on this:
1) make guard()() be delimited by blank lines, so it's visible at a glance;
2) don't leave unneeded variables, like 'ret' in this case.
...
> @@ -101,9 +101,8 @@ static inline int xadc_read_adc_reg(struct xadc *xadc, unsigned int reg, u16 *va
> {
> int ret;
>
> - mutex_lock(&xadc->mutex);
> + guard(mutex)(&xadc->mutex);
> ret = _xadc_read_adc_reg(xadc, reg, val);
> - mutex_unlock(&xadc->mutex);
> return ret;
> }
Same story and so on...
--
With Best Regards,
Andy Shevchenko