]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: humidity: ens210: remove compiler warning workaround
authorDavid Lechner <dlechner@baylibre.com>
Fri, 22 May 2026 01:25:29 +0000 (20:25 -0500)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2026 10:01:47 +0000 (11:01 +0100)
Rewrite IIO_CHAN_INFO_RAW case to avoid needing to add unreachable code
to work around a compiler warning.

When scoped_guard() was first introduced, compilers could not see when
it returned unconditionally from inside the hidden for loop. This has
since been fixed in the macro definition. So removing the `return
-EINVAL` should be enough. Still, we can improve readability, decrease
indentation and avoid the hidden for loop by rewriting the case without
scoped_guard().

Signed-off-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/humidity/ens210.c

index 22ad208e6aa69a0dc0b7154f01fae52dba246421..49543fc389bf4861dda6b4a069437db09a429729 100644 (file)
@@ -149,15 +149,16 @@ static int ens210_read_raw(struct iio_dev *indio_dev,
        int ret;
 
        switch (mask) {
-       case IIO_CHAN_INFO_RAW:
-               scoped_guard(mutex, &data->lock) {
-                       ret = ens210_get_measurement(
-                               indio_dev, channel->type == IIO_TEMP, val);
-                       if (ret)
-                               return ret;
-                       return IIO_VAL_INT;
-               }
-               return -EINVAL; /* compiler warning workaround */
+       case IIO_CHAN_INFO_RAW: {
+               guard(mutex)(&data->lock);
+
+               ret = ens210_get_measurement(indio_dev, channel->type == IIO_TEMP,
+                                            val);
+               if (ret)
+                       return ret;
+
+               return IIO_VAL_INT;
+       }
        case IIO_CHAN_INFO_SCALE:
                if (channel->type == IIO_TEMP) {
                        *val = 15;