Re: [PATCH v5 3/3] iio: accel: sca3000: use guard(mutex)() for handling mutex lock

From: Andrew Ijano
Date: Sat Jun 14 2025 - 17:21:56 EST


On Thu, Jun 12, 2025 at 1:06 PM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
>
> On 6/12/25 10:52 AM, kernel test robot wrote:
> > Hi Andrew,
...
>
> These error messages aren't particularity helpful, but what I think
> this is try to say is that you have to be careful with guard() in
> switch statements.
>
> The guard() macro is declaring a new local variable, which shouldn't
> be done in a case: statement without enclosing it in a separate scope.
> Some compilers complain and some don't so even if it worked for you
> locally, we need to make it work for all supported compilers.
>
> So the code needs to looks something like this:
>
> case IIO_CHAN_INFO_SAMP_FREQ: {
> guard(mutex)(&st->lock);
> ret = sca3000_read_raw_samp_freq(st, val);
> return ret ? ret : IIO_VAL_INT;
> }
Hi, David! Thanks a lot for the explanation. I'll make this change right away.

Thanks,
Andrew