summaryrefslogtreecommitdiff
path: root/drivers/iio/light
diff options
context:
space:
mode:
authorFabien Lahoudere <fabien.lahoudere@collabora.com>2019-07-16 12:11:06 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-07-28 01:15:08 +0300
commitae7b02ad2f32d39d1434655f346c04a16c1aa703 (patch)
tree9230bbf83261b35be0da7a9e185316742f172d86 /drivers/iio/light
parent9566cb1ddb81c4f232d08cb2c7aff5b947959381 (diff)
downloadlinux-ae7b02ad2f32d39d1434655f346c04a16c1aa703.tar.xz
iio: common: cros_ec_sensors: Expose cros_ec_sensors frequency range via iio sysfs
Embedded controller return minimum and maximum frequencies, unfortunately we have no way to know the step for all available frequencies. Even if not complete, we can return a list of known values using the standard read_avail callback (IIO_CHAN_INFO_SAMP_FREQ) to provide them to userland. Now cros_ec_* sensors provides frequencies values in sysfs like this: "0 min max". 0 is always true to disable the sensor. Default frequencies are provided for earlier protocol. Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com> [rebased on top of iio/testing and solved conflicts] Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/light')
-rw-r--r--drivers/iio/light/cros_ec_light_prox.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 965f346d7d64..44313a009928 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -162,6 +162,7 @@ static int cros_ec_light_prox_write(struct iio_dev *indio_dev,
static const struct iio_info cros_ec_light_prox_info = {
.read_raw = &cros_ec_light_prox_read,
.write_raw = &cros_ec_light_prox_write,
+ .read_avail = &cros_ec_sensors_core_read_avail,
};
static int cros_ec_light_prox_probe(struct platform_device *pdev)
@@ -196,6 +197,8 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
channel->info_mask_shared_by_all =
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
BIT(IIO_CHAN_INFO_FREQUENCY);
+ channel->info_mask_shared_by_all_available =
+ BIT(IIO_CHAN_INFO_SAMP_FREQ);
channel->scan_type.realbits = CROS_EC_SENSOR_BITS;
channel->scan_type.storagebits = CROS_EC_SENSOR_BITS;
channel->scan_type.shift = 0;