All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: light: Add raw attribute
@ 2022-08-11 10:14 Shreeya Patel
  2022-08-11 10:43 ` Dmitry Osipenko
  2022-08-11 13:25 ` Jonathan Cameron
  0 siblings, 2 replies; 5+ messages in thread
From: Shreeya Patel @ 2022-08-11 10:14 UTC (permalink / raw)
  To: jic23, lars
  Cc: linux-iio, linux-kernel, krisman, kernel, alvaro.soliverez,
	Shreeya Patel

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-11 14:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11 10:14 [PATCH] iio: light: Add raw attribute Shreeya Patel
2022-08-11 10:43 ` Dmitry Osipenko
2022-08-11 10:51   ` Shreeya Patel
2022-08-11 13:25 ` Jonathan Cameron
2022-08-11 14:18   ` Shreeya Patel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.