diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2022-04-27 12:08:04 -0700 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2022-06-11 14:35:26 +0100 |
commit | 7cbb6681d7e5b88688234ad370e027a9346ff7a9 (patch) | |
tree | 09dddb1df50413005ce43054c96efef798a2b67f /drivers/iio/common | |
parent | cc0bb2f106cb6293997e9114caa7887d91d22b26 (diff) | |
download | linux-7cbb6681d7e5b88688234ad370e027a9346ff7a9.tar.gz linux-7cbb6681d7e5b88688234ad370e027a9346ff7a9.tar.bz2 linux-7cbb6681d7e5b88688234ad370e027a9346ff7a9.zip |
iio: common: cros_ec_sensors: Add label attribute
When sensor location is known, populate iio sysfs "label" attribute:
* "accel-base" : the sensor is in the base of the convertible (2-1)
device.
* "accel-display" : the sensor is in the lid/display plane of the
device.
* "accel-camera" : the sensor is in the swivel camera subassembly.
The non-standard |location| attribute is removed, the field |loc| in
cros_ec_sensors_core_state is removed.
It apply to standalone accelerometer as well as IMU (accelerometer +
gyroscope) and sensors where the location is known (light).
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20220427190804.961697-3-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/common')
-rw-r--r-- | drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index 5976aca48e3b..e5ccedef13a8 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -29,12 +29,6 @@ */ #define CROS_EC_FIFO_SIZE (2048 * 2 / 3) -static char *cros_ec_loc[] = { - [MOTIONSENSE_LOC_BASE] = "base", - [MOTIONSENSE_LOC_LID] = "lid", - [MOTIONSENSE_LOC_MAX] = "unknown", -}; - static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev, u16 cmd_offset, u16 cmd, u32 *mask) { @@ -287,6 +281,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, indio_dev->name = pdev->name; if (physical_device) { + enum motionsensor_location loc; + state->param.cmd = MOTIONSENSE_CMD_INFO; state->param.info.sensor_num = sensor_platform->sensor_num; ret = cros_ec_motion_send_host_cmd(state, 0); @@ -295,7 +291,13 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, return ret; } state->type = state->resp->info.type; - state->loc = state->resp->info.location; + loc = state->resp->info.location; + if (loc == MOTIONSENSE_LOC_BASE) + indio_dev->label = "accel-base"; + else if (loc == MOTIONSENSE_LOC_LID) + indio_dev->label = "accel-display"; + else if (loc == MOTIONSENSE_LOC_CAMERA) + indio_dev->label = "accel-camera"; /* Set sign vector, only used for backward compatibility. */ memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS); @@ -442,15 +444,6 @@ static ssize_t cros_ec_sensors_id(struct iio_dev *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, - 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, "%s\n", cros_ec_loc[st->loc]); -} - const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = { { .name = "calibrate", @@ -462,11 +455,6 @@ const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = { .shared = IIO_SHARED_BY_ALL, .read = cros_ec_sensors_id }, - { - .name = "location", - .shared = IIO_SHARED_BY_ALL, - .read = cros_ec_sensors_loc - }, { }, }; EXPORT_SYMBOL_GPL(cros_ec_sensors_ext_info); |