summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2024-07-15 20:28:58 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-08-03 10:13:39 +0100
commit98077d34d05b4c8a7263ad9bf0b1677e19499c31 (patch)
tree8ca4d2d31e63c7669a470da6e7ffcfb827b3f3fd
parent968a3bed1c96baa4e701de308fc1f78a9515ba0c (diff)
iio: light: noa1305: Report available scale values
Make use of the new static table of scale values and expose available scale values via sysfs attribute of the IIO device. Signed-off-by: Marek Vasut <marex@denx.de> Link: https://patch.msgid.link/20240715183120.143417-4-marex@denx.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/light/noa1305.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
index 202a5c1bbf79..e778714a942a 100644
--- a/drivers/iio/light/noa1305.c
+++ b/drivers/iio/light/noa1305.c
@@ -102,9 +102,29 @@ static const struct iio_chan_spec noa1305_channels[] = {
.type = IIO_LIGHT,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
+ .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE),
}
};
+static int noa1305_read_avail(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ const int **vals, int *type,
+ int *length, long mask)
+{
+ if (chan->type != IIO_LIGHT)
+ return -EINVAL;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ *vals = noa1305_scale_available;
+ *length = ARRAY_SIZE(noa1305_scale_available);
+ *type = IIO_VAL_FRACTIONAL;
+ return IIO_AVAIL_LIST;
+ default:
+ return -EINVAL;
+ }
+}
+
static int noa1305_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
@@ -125,6 +145,7 @@ static int noa1305_read_raw(struct iio_dev *indio_dev,
}
static const struct iio_info noa1305_info = {
+ .read_avail = noa1305_read_avail,
.read_raw = noa1305_read_raw,
};