]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: light: noa1305: Simplify noa1305_read_raw()
authorMarek Vasut <marex@denx.de>
Mon, 15 Jul 2024 18:28:55 +0000 (20:28 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 3 Aug 2024 09:13:38 +0000 (10:13 +0100)
The only channel this hardware supports is IIO_LIGHT, if the channel
is anything else, exit right away. The 'ret' variable is now always
only assigned by noa1305_measure(), do not initialize it anymore.
Update function parameter indent. No functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://patch.msgid.link/20240715183120.143417-1-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/noa1305.c

index 596cc48c4c3415c57376c7f9a42c2068b0417df2..a76f158bb50e5e3e4b29f19579c9bdb06c3a4334 100644 (file)
@@ -125,38 +125,27 @@ static const struct iio_chan_spec noa1305_channels[] = {
 };
 
 static int noa1305_read_raw(struct iio_dev *indio_dev,
-                               struct iio_chan_spec const *chan,
-                               int *val, int *val2, long mask)
+                           struct iio_chan_spec const *chan,
+                           int *val, int *val2, long mask)
 {
-       int ret = -EINVAL;
        struct noa1305_priv *priv = iio_priv(indio_dev);
+       int ret;
+
+       if (chan->type != IIO_LIGHT)
+               return -EINVAL;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-               switch (chan->type) {
-               case IIO_LIGHT:
-                       ret = noa1305_measure(priv);
-                       if (ret < 0)
-                               return ret;
-                       *val = ret;
-                       return IIO_VAL_INT;
-               default:
-                       break;
-               }
-               break;
+               ret = noa1305_measure(priv);
+               if (ret < 0)
+                       return ret;
+               *val = ret;
+               return IIO_VAL_INT;
        case IIO_CHAN_INFO_SCALE:
-               switch (chan->type) {
-               case IIO_LIGHT:
-                       return noa1305_scale(priv, val, val2);
-               default:
-                       break;
-               }
-               break;
+               return noa1305_scale(priv, val, val2);
        default:
-               break;
+               return -EINVAL;
        }
-
-       return ret;
 }
 
 static const struct iio_info noa1305_info = {