Re: [PATCH v2] staging: iio: frequency: ad9834: use guard(mutex)

From: Andy Shevchenko

Date: Mon Oct 19 2026 - 03:48:32 EST


On Sat, Oct 17, 2026 at 08:54:54PM +0100, Jonathan Cameron wrote:
> On Sat, 17 Oct 2026 02:45:52 +0300
> Amir Atef via B4 Relay <devnull+amiratefabdallah1122.gmail.com@xxxxxxxxxx> wrote:

...

> > ret = spi_sync(st->spi, &st->msg);
>
> I'd rather see all error handled at point where they originate, rather
> than only some (with special case for the last call) so here and similar places, do
> if (ret)
> return ret;
>
> break;
>
> Or you could even do a return len; here if you prefer.

I'm definitely against this. return len is a common non-error case, that's
better to be at one place.

> > break;
> > default:
> > - ret = -ENODEV;
> > + return -ENODEV;
> > }
> > - mutex_unlock(&st->lock);
> >
> > return ret ? ret : len;

So, if got the above way, use

return len;

here at the end, and 'break;' statements in the respective cases.

--
With Best Regards,
Andy Shevchenko