From: Shreeya Patel <shreeya.patel@collabora.com>
To: jic23@kernel.org, lars@metafoo.de
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
krisman@collabora.com, kernel@collabora.com,
alvaro.soliverez@collabora.com,
Shreeya Patel <shreeya.patel@collabora.com>
Subject: [PATCH] iio: light: Add raw attribute
Date: Thu, 11 Aug 2022 15:44:43 +0530 [thread overview]
Message-ID: <20220811101443.499761-1-shreeya.patel@collabora.com> (raw)
Add IIO_CHAN_INFO_RAW to the mask to be able to read raw values
from the light sensor.
Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
---
drivers/iio/light/ltrf216a.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/iio/light/ltrf216a.c b/drivers/iio/light/ltrf216a.c
index e6e24e70d2b9..a717bf99bd2a 100644
--- a/drivers/iio/light/ltrf216a.c
+++ b/drivers/iio/light/ltrf216a.c
@@ -93,6 +93,7 @@ static const struct iio_chan_spec ltrf216a_channels[] = {
{
.type = IIO_LIGHT,
.info_mask_separate =
+ BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PROCESSED) |
BIT(IIO_CHAN_INFO_INT_TIME),
.info_mask_separate_available =
@@ -259,6 +260,18 @@ static int ltrf216a_read_raw(struct iio_dev *indio_dev,
int ret;
switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ ret = ltrf216a_set_power_state(data, true);
+ if (ret)
+ return ret;
+ mutex_lock(&data->lock);
+ ret = ltrf216a_read_data(data, LTRF216A_ALS_DATA_0);
+ mutex_unlock(&data->lock);
+ if (ret < 0)
+ return ret;
+ *val = ret;
+ ltrf216a_set_power_state(data, false);
+ return IIO_VAL_INT;
case IIO_CHAN_INFO_PROCESSED:
mutex_lock(&data->lock);
ret = ltrf216a_get_lux(data);
--
2.30.2
next reply other threads:[~2022-08-11 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 10:14 Shreeya Patel [this message]
2022-08-11 10:43 ` [PATCH] iio: light: Add raw attribute Dmitry Osipenko
2022-08-11 10:51 ` Shreeya Patel
2022-08-11 13:25 ` Jonathan Cameron
2022-08-11 14:18 ` Shreeya Patel
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=20220811101443.499761-1-shreeya.patel@collabora.com \
--to=shreeya.patel@collabora.com \
--cc=alvaro.soliverez@collabora.com \
--cc=jic23@kernel.org \
--cc=kernel@collabora.com \
--cc=krisman@collabora.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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