Re: [PATCH v3] staging: iio: frequency: ad9834: use guard(mutex)
From: Jonathan Cameron
Date: Fri Oct 23 2026 - 22:33:49 EST
On Mon, 19 Oct 2026 22:03:40 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> On Mon, Oct 19, 2026 at 05:15:45PM +0300, Amir Atef via B4 Relay wrote:
>
> > Use guard(mutex) to manage the state lock in ad9834_write() and
> > ad9834_store_wavetype(). This simplifies error handling by allowing
> > early returns instead of setting the return code and breaking out of the
> > switch statement to manually unlock the mutex.
>
> If you want to continue improving the code, you can research the use of
> sysfs_match_string() and rather use it as an outer check.
>
> static const char * const wavetypes[] = { "sine", "triangle", "square" };
>
> int wavetype;
> ...
> wavetype = sysfs_match_string(wavetypes);
> if (wavetype < 0)
> return wavetype;
>
> but it might be actually worse than existing. Again, it needs a research to be
> conducted.
>
> As for this change, it's good enough.
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>
Applied