iio: cros_ec: add 'id' sysfs entry

This new sysfs entry is used to interpret ring buffer information,
mainly by Android sensor HAL.
It expand to all sensors, the documentation about 'id' we can found
in Documentation/ABI/testing/sysfs-bus-iio-cros-ec.

Also fix typo in docs, I replace 'Septembre' by 'September'.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Gwendal Grignou 2019-04-26 13:39:16 +02:00 committed by Jonathan Cameron
parent d2fc015696
commit 8b7a6a3574
2 changed files with 19 additions and 5 deletions

View File

@ -18,11 +18,11 @@ Description:
values are 'base' and 'lid'. values are 'base' and 'lid'.
What: /sys/bus/iio/devices/iio:deviceX/id What: /sys/bus/iio/devices/iio:deviceX/id
Date: Septembre 2017 Date: September 2017
KernelVersion: 4.14 KernelVersion: 4.14
Contact: linux-iio@vger.kernel.org Contact: linux-iio@vger.kernel.org
Description: Description:
This attribute is exposed by the CrOS EC legacy accelerometer This attribute is exposed by the CrOS EC sensors driver and
driver and represents the sensor ID as exposed by the EC. This represents the sensor ID as exposed by the EC. This ID is used
ID is used by the Android sensor service hardware abstraction by the Android sensor service hardware abstraction layer (sensor
layer (sensor HAL) through the Android container on ChromeOS. HAL) through the Android container on ChromeOS.

View File

@ -125,6 +125,15 @@ static ssize_t cros_ec_sensors_calibrate(struct iio_dev *indio_dev,
return ret ? ret : len; return ret ? ret : len;
} }
static ssize_t cros_ec_sensors_id(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan, char *buf)
{
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
return snprintf(buf, PAGE_SIZE, "%d\n", st->param.info.sensor_num);
}
static ssize_t cros_ec_sensors_loc(struct iio_dev *indio_dev, static ssize_t cros_ec_sensors_loc(struct iio_dev *indio_dev,
uintptr_t private, const struct iio_chan_spec *chan, uintptr_t private, const struct iio_chan_spec *chan,
char *buf) char *buf)
@ -140,6 +149,11 @@ const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = {
.shared = IIO_SHARED_BY_ALL, .shared = IIO_SHARED_BY_ALL,
.write = cros_ec_sensors_calibrate .write = cros_ec_sensors_calibrate
}, },
{
.name = "id",
.shared = IIO_SHARED_BY_ALL,
.read = cros_ec_sensors_id
},
{ {
.name = "location", .name = "location",
.shared = IIO_SHARED_BY_ALL, .shared = IIO_SHARED_BY_ALL,