@@ -230,7 +230,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev)
indio_dev->channels = cros_ec_accel_legacy_channels;
indio_dev->num_channels = ARRAY_SIZE(cros_ec_accel_legacy_channels);
/* The lid sensor needs to be presented inverted. */
- if (state->loc == MOTIONSENSE_LOC_LID) {
+ if (!strcmp(indio_dev->label, "accel-display")) {
state->sign[CROS_EC_SENSOR_X] = -1;
state->sign[CROS_EC_SENSOR_Z] = -1;
}
@@ -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);
@@ -188,8 +188,6 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
indio_dev->info = &cros_ec_light_prox_info;
state = iio_priv(indio_dev);
- state->core.type = state->core.resp->info.type;
- state->core.loc = state->core.resp->info.location;
channel = state->channels;
/* Common part */
@@ -145,8 +145,6 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
indio_dev->info = &cros_ec_baro_info;
state = iio_priv(indio_dev);
- state->core.type = state->core.resp->info.type;
- state->core.loc = state->core.resp->info.location;
channel = state->channels;
/* Common part */
channel->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
@@ -41,7 +41,6 @@ typedef irqreturn_t (*cros_ec_sensors_capture_t)(int irq, void *p);
* @param: motion sensor parameters structure
* @resp: motion sensor response structure
* @type: type of motion sensor
- * @loc: location where the motion sensor is placed
* @range_updated: True if the range of the sensor has been
* updated.
* @curr_range: If updated, the current range value.
@@ -67,7 +66,6 @@ struct cros_ec_sensors_core_state {
struct ec_response_motion_sense *resp;
enum motionsensor_type type;
- enum motionsensor_location loc;
bool range_updated;
int curr_range;
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> --- changes in v2: * Use "accel-camera" define. * remove |location| attribute completely. * remove ->loc field, and duplication of setting ->type field. drivers/iio/accel/cros_ec_accel_legacy.c | 2 +- .../cros_ec_sensors/cros_ec_sensors_core.c | 30 ++++++------------- drivers/iio/light/cros_ec_light_prox.c | 2 -- drivers/iio/pressure/cros_ec_baro.c | 2 -- .../linux/iio/common/cros_ec_sensors_core.h | 2 -- 5 files changed, 10 insertions(+), 28 deletions(-)