[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c9efd563-9d52-4761-a5f1-be0df0222dff@baylibre.com>
Date: Thu, 4 Dec 2025 11:35:11 -0600
From: David Lechner <dlechner@...libre.com>
To: Kurt Borja <kuurtb@...il.com>,
Andy Shevchenko <andriy.shevchenko@...el.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>, Benson Leung <bleung@...omium.org>,
Antoniu Miclaus <antoniu.miclaus@...log.com>,
Gwendal Grignou <gwendal@...omium.org>,
Shrikant Raskar <raskar.shree97@...il.com>,
Per-Daniel Olsson <perdaniel.olsson@...s.com>
Cc: Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Guenter Roeck <groeck@...omium.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, chrome-platform@...ts.linux.dev
Subject: Re: [PATCH RFC 5/6] iio: health: max30102: Use cleanup.h for IIO
locks
On 12/4/25 11:07 AM, Kurt Borja wrote:
> On Wed Dec 3, 2025 at 4:52 PM -05, David Lechner wrote:
>> On 12/3/25 1:18 PM, Kurt Borja wrote:
...
>> I would write the whole function like this:
>>
>> static int max30102_read_raw(struct iio_dev *indio_dev,
>> struct iio_chan_spec const *chan,
>> int *val, int *val2, long mask)
>> {
>> struct max30102_data *data = iio_priv(indio_dev);
>> int ret;
>>
>> switch (mask) {
>> case IIO_CHAN_INFO_RAW: {
>> /*
>> * Temperature reading can only be acquired when not in
>> * shutdown; leave shutdown briefly when buffer not running
>> */
>> guard(iio_device_claim)(indio_dev);
>
> AFAIK you can't guard() inside switch-case blocks. I don't know the
> exact reason, but it has to be scoped_guard().
You can. You just need the braces like I showed in my suggestion.
The reason is that guard() is declaring local variables and some
compilers like LLVM don't like declaring local variables in a
switch case. By adding the { } scope, the variables are limited
to that scope and the issue goes away.
Powered by blists - more mailing lists