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

From: Andy Shevchenko

Date: Mon Oct 19 2026 - 15:43:38 EST


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>

--
With Best Regards,
Andy Shevchenko