Commit 0cef1c32 authored by Marek Vasut's avatar Marek Vasut Committed by Jonathan Cameron

iio: light: noa1305: Simplify noa1305_read_raw()

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: default avatarMarek Vasut <marex@denx.de>
Link: https://patch.msgid.link/20240715183120.143417-1-marex@denx.deSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent d5cbe150
...@@ -125,38 +125,27 @@ static const struct iio_chan_spec noa1305_channels[] = { ...@@ -125,38 +125,27 @@ static const struct iio_chan_spec noa1305_channels[] = {
}; };
static int noa1305_read_raw(struct iio_dev *indio_dev, static int noa1305_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, struct iio_chan_spec const *chan,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
int ret = -EINVAL;
struct noa1305_priv *priv = iio_priv(indio_dev); struct noa1305_priv *priv = iio_priv(indio_dev);
int ret;
if (chan->type != IIO_LIGHT)
return -EINVAL;
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
switch (chan->type) { ret = noa1305_measure(priv);
case IIO_LIGHT: if (ret < 0)
ret = noa1305_measure(priv); return ret;
if (ret < 0) *val = ret;
return ret; return IIO_VAL_INT;
*val = ret;
return IIO_VAL_INT;
default:
break;
}
break;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
switch (chan->type) { return noa1305_scale(priv, val, val2);
case IIO_LIGHT:
return noa1305_scale(priv, val, val2);
default:
break;
}
break;
default: default:
break; return -EINVAL;
} }
return ret;
} }
static const struct iio_info noa1305_info = { static const struct iio_info noa1305_info = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment