Skip to content

Commit f9f9919

Browse files
dlechjic23
authored andcommitted
iio: humidity: ens210: remove compiler warning workaround
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>
1 parent f68afce commit f9f9919

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/iio/humidity/ens210.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,16 @@ static int ens210_read_raw(struct iio_dev *indio_dev,
149149
int ret;
150150

151151
switch (mask) {
152-
case IIO_CHAN_INFO_RAW:
153-
scoped_guard(mutex, &data->lock) {
154-
ret = ens210_get_measurement(
155-
indio_dev, channel->type == IIO_TEMP, val);
156-
if (ret)
157-
return ret;
158-
return IIO_VAL_INT;
159-
}
160-
return -EINVAL; /* compiler warning workaround */
152+
case IIO_CHAN_INFO_RAW: {
153+
guard(mutex)(&data->lock);
154+
155+
ret = ens210_get_measurement(indio_dev, channel->type == IIO_TEMP,
156+
val);
157+
if (ret)
158+
return ret;
159+
160+
return IIO_VAL_INT;
161+
}
161162
case IIO_CHAN_INFO_SCALE:
162163
if (channel->type == IIO_TEMP) {
163164
*val = 15;

0 commit comments

Comments
 (0)