From: Marek Vasut <marex@denx.de>
To: linux-iio@vger.kernel.org
Cc: "Marek Vasut" <marex@denx.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Jonathan Cameron" <jic23@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>
Subject: [PATCH 2/5] iio: light: noa1305: Assign val in noa1305_measure()
Date: Mon, 15 Jul 2024 20:28:56 +0200 [thread overview]
Message-ID: <20240715183120.143417-2-marex@denx.de> (raw)
In-Reply-To: <20240715183120.143417-1-marex@denx.de>
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: Marek Vasut <marex@denx.de>
---
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
---
drivers/iio/light/noa1305.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
index a76f158bb50e5..a7e4c68bea09e 100644
--- a/drivers/iio/light/noa1305.c
+++ b/drivers/iio/light/noa1305.c
@@ -48,7 +48,7 @@ struct noa1305_priv {
struct regmap *regmap;
};
-static int noa1305_measure(struct noa1305_priv *priv)
+static int noa1305_measure(struct noa1305_priv *priv, int *val)
{
__le16 data;
int ret;
@@ -58,7 +58,9 @@ static int noa1305_measure(struct noa1305_priv *priv)
if (ret < 0)
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)
@@ -129,18 +131,13 @@ static int noa1305_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask)
{
struct noa1305_priv *priv = iio_priv(indio_dev);
- int ret;
if (chan->type != IIO_LIGHT)
return -EINVAL;
switch (mask) {
case IIO_CHAN_INFO_RAW:
- ret = noa1305_measure(priv);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
+ return noa1305_measure(priv, val);
case IIO_CHAN_INFO_SCALE:
return noa1305_scale(priv, val, val2);
default:
--
2.43.0
next prev parent reply other threads:[~2024-07-15 18:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-15 18:28 [PATCH 1/5] iio: light: noa1305: Simplify noa1305_read_raw() Marek Vasut
2024-07-15 18:28 ` Marek Vasut [this message]
2024-07-15 18:28 ` [PATCH 3/5] iio: light: noa1305: Use static table lookup of scale values Marek Vasut
2024-07-15 18:28 ` [PATCH 4/5] iio: light: noa1305: Report available " Marek Vasut
2024-07-15 18:28 ` [PATCH 5/5] iio: light: noa1305: Make integration time configurable Marek Vasut
2024-07-20 13:29 ` [PATCH 1/5] iio: light: noa1305: Simplify noa1305_read_raw() Jonathan Cameron
2024-07-20 16:22 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240715183120.143417-2-marex@denx.de \
--to=marex@denx.de \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox