diff mbox series

[v2] iio: cros_ec: set calibscale for 3d MEMS to unit vector

Message ID 20190826230258.203235-1-gwendal@chromium.org (mailing list archive)
State New, archived
Headers show
Series [v2] iio: cros_ec: set calibscale for 3d MEMS to unit vector | expand

Commit Message

Gwendal Grignou Aug. 26, 2019, 11:02 p.m. UTC
By default, set the calibscale vector to unit vector.
When calibrating one axis, the other axis calibrations  are sent as well.
If left to 0, sensor data from uncalibrated axis are zero'ed out until
all axis are calibrated.

Fixes: ed1f2e85da79 ("iio: cros_ec: Add calibscale for 3d MEMS ")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
Changes in v2:
- Add fixes tag.
- Improve description.

 drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jonathan Cameron Aug. 27, 2019, 8:06 p.m. UTC | #1
On Mon, 26 Aug 2019 16:02:58 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> By default, set the calibscale vector to unit vector.
> When calibrating one axis, the other axis calibrations  are sent as well.
> If left to 0, sensor data from uncalibrated axis are zero'ed out until
> all axis are calibrated.
> 
> Fixes: ed1f2e85da79 ("iio: cros_ec: Add calibscale for 3d MEMS ")
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>

Just made it before what will probably be the last pull request from
me for this cycle.

Applied to the togreg branch of iio.git.

Thanks,

Jonathan

> ---
> Changes in v2:
> - Add fixes tag.
> - Improve description.
> 
>  drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 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 fd833295bb173..d44ae126f4578 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
> @@ -90,7 +90,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>  	struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
>  	struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
>  	u32 ver_mask;
> -	int ret;
> +	int ret, i;
>  
>  	platform_set_drvdata(pdev, indio_dev);
>  
> @@ -136,6 +136,9 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>  		/* Set sign vector, only used for backward compatibility. */
>  		memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
>  
> +		for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
> +			state->calib[i].scale = MOTION_SENSE_DEFAULT_SCALE;
> +
>  		/* 0 is a correct value used to stop the device */
>  		state->frequencies[0] = 0;
>  		if (state->msg->version < 3) {
diff mbox series

Patch

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 fd833295bb173..d44ae126f4578 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
@@ -90,7 +90,7 @@  int cros_ec_sensors_core_init(struct platform_device *pdev,
 	struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
 	struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
 	u32 ver_mask;
-	int ret;
+	int ret, i;
 
 	platform_set_drvdata(pdev, indio_dev);
 
@@ -136,6 +136,9 @@  int cros_ec_sensors_core_init(struct platform_device *pdev,
 		/* Set sign vector, only used for backward compatibility. */
 		memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
 
+		for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
+			state->calib[i].scale = MOTION_SENSE_DEFAULT_SCALE;
+
 		/* 0 is a correct value used to stop the device */
 		state->frequencies[0] = 0;
 		if (state->msg->version < 3) {