Commit dde56b6d authored by Marek Vasut's avatar Marek Vasut Committed by Jonathan Cameron

iio: light: noa1305: Assign val in noa1305_measure()

Make noa1305_measure() behave similar to noa1305_scale(), make it
assign the 'val' output variable on success and return IIO_VAL_INT.
This further simplifies noa1305_read_raw() and allows removal of
ret variable altogether.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Link: https://patch.msgid.link/20240715183120.143417-2-marex@denx.deSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 0cef1c32
...@@ -48,7 +48,7 @@ struct noa1305_priv { ...@@ -48,7 +48,7 @@ struct noa1305_priv {
struct regmap *regmap; struct regmap *regmap;
}; };
static int noa1305_measure(struct noa1305_priv *priv) static int noa1305_measure(struct noa1305_priv *priv, int *val)
{ {
__le16 data; __le16 data;
int ret; int ret;
...@@ -58,7 +58,9 @@ static int noa1305_measure(struct noa1305_priv *priv) ...@@ -58,7 +58,9 @@ static int noa1305_measure(struct noa1305_priv *priv)
if (ret < 0) if (ret < 0)
return ret; return ret;
return le16_to_cpu(data); *val = le16_to_cpu(data);
return IIO_VAL_INT;
} }
static int noa1305_scale(struct noa1305_priv *priv, int *val, int *val2) static int noa1305_scale(struct noa1305_priv *priv, int *val, int *val2)
...@@ -129,18 +131,13 @@ static int noa1305_read_raw(struct iio_dev *indio_dev, ...@@ -129,18 +131,13 @@ static int noa1305_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask) int *val, int *val2, long mask)
{ {
struct noa1305_priv *priv = iio_priv(indio_dev); struct noa1305_priv *priv = iio_priv(indio_dev);
int ret;
if (chan->type != IIO_LIGHT) if (chan->type != IIO_LIGHT)
return -EINVAL; return -EINVAL;
switch (mask) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
ret = noa1305_measure(priv); return noa1305_measure(priv, val);
if (ret < 0)
return ret;
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
return noa1305_scale(priv, val, val2); return noa1305_scale(priv, val, val2);
default: default:
......
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