Skip to content

Commit 12bf745

Browse files
gwendalcrjic23
authored andcommitted
iio: cros_ec: Add sign vector in core for backward compatibility
To allow cros_ec iio core library to be used with legacy device, add a vector to rotate sensor data if necessary: legacy devices are not reporting data in HTML5/Android sensor referential. Check the data is not rotated on recent chromebooks that use the HTML5 standard to present sensor data. Signed-off-by: Gwendal Grignou <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 3cf9df0 commit 12bf745

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
101101
}
102102
state->type = state->resp->info.type;
103103
state->loc = state->resp->info.location;
104+
105+
/* Set sign vector, only used for backward compatibility. */
106+
memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
104107
}
105108

106109
return 0;
@@ -303,6 +306,7 @@ static int cros_ec_sensors_read_data_unsafe(struct iio_dev *indio_dev,
303306
if (ret < 0)
304307
return ret;
305308

309+
*data *= st->sign[i];
306310
data++;
307311
}
308312

include/linux/iio/common/cros_ec_sensors_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct cros_ec_sensors_core_state {
6666
s16 offset;
6767
u16 scale;
6868
} calib[CROS_EC_SENSOR_MAX_AXIS];
69-
69+
s8 sign[CROS_EC_SENSOR_MAX_AXIS];
7070
u8 samples[CROS_EC_SAMPLE_SIZE];
7171

7272
int (*read_ec_sensors_data)(struct iio_dev *indio_dev,

0 commit comments

Comments
 (0)