From: Matt Ranostay <matt.ranostay@konsulko.com>
To: jic23@kernel.org, lars@metafoo.de
Cc: linux-iio@vger.kernel.org, Matt Ranostay <matt.ranostay@konsulko.com>
Subject: [PATCH] iio: chemical: atlas-ezo-sensor: refactor IIO_CHAN_INFO_SCALE checks
Date: Fri, 2 Dec 2022 14:23:05 -0800 [thread overview]
Message-ID: <20221202222305.8828-1-matt.ranostay@konsulko.com> (raw)
Additional modifiers in IIO_CHAN_INFO_SCALE check will mostly have a ppm
unit and the switch statement is more confusing, and adds unneeded code.
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
drivers/iio/chemical/atlas-ezo-sensor.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c
index 307c3488f4bd..5fae1c4087ee 100644
--- a/drivers/iio/chemical/atlas-ezo-sensor.c
+++ b/drivers/iio/chemical/atlas-ezo-sensor.c
@@ -165,17 +165,19 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
return -EINVAL;
}
- /* IIO_CONCENTRATION modifiers */
- switch (chan->channel2) {
- case IIO_MOD_CO2:
- *val = 0;
- *val2 = 100; /* 0.0001 */
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_MOD_O2:
+ if (chan->channel2 == IIO_NO_MOD)
+ return -EINVAL;
+
+ // IIO_CONCENTRATION modifier for percent
+ if (chan->channel2 == IIO_MOD_O2) {
*val = 100;
return IIO_VAL_INT;
}
- return -EINVAL;
+
+ // IIO_CONCENTRATION modifier for PPM - 0.0001
+ *val = 0;
+ *val2 = 100;
+ return IIO_VAL_INT_PLUS_MICRO;
}
return 0;
--
2.30.2
next reply other threads:[~2022-12-02 22:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 22:23 Matt Ranostay [this message]
2022-12-03 17:34 ` [PATCH] iio: chemical: atlas-ezo-sensor: refactor IIO_CHAN_INFO_SCALE checks Jonathan Cameron
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=20221202222305.8828-1-matt.ranostay@konsulko.com \
--to=matt.ranostay@konsulko.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/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