* [PATCH] iio: cros_ec: set calibscale for 3d MEMS to unit vector
@ 2019-08-20 5:10 Gwendal Grignou
2019-08-25 18:12 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Gwendal Grignou @ 2019-08-20 5:10 UTC (permalink / raw)
To: jic23
Cc: enric.balletbo, linux-iio, Gwendal Grignou, Nick Vaccaro,
Guenter Roeck, Hartmut Knaack, Fabien Lahoudere, Benson Leung,
Lars-Peter Clausen, Peter Meerwald-Stadler, linux-kernel
By default, set the calibscale vector to unit vector.
It prevents sending 0 as calibscale when not initialized.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
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) {
--
2.23.0.rc1.153.gdeed80330f-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: cros_ec: set calibscale for 3d MEMS to unit vector
2019-08-20 5:10 [PATCH] iio: cros_ec: set calibscale for 3d MEMS to unit vector Gwendal Grignou
@ 2019-08-25 18:12 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-08-25 18:12 UTC (permalink / raw)
To: Gwendal Grignou
Cc: enric.balletbo, linux-iio, Nick Vaccaro, Guenter Roeck,
Hartmut Knaack, Fabien Lahoudere, Benson Leung,
Lars-Peter Clausen, Peter Meerwald-Stadler, linux-kernel
On Mon, 19 Aug 2019 22:10:29 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:
> By default, set the calibscale vector to unit vector.
> It prevents sending 0 as calibscale when not initialized.
>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Fix for a real case or paranoia?
If a fix, then fixes tag and preferably which hardware it applies to.
Thanks,
Jonathan
> ---
>
> 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) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-25 18:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 5:10 [PATCH] iio: cros_ec: set calibscale for 3d MEMS to unit vector Gwendal Grignou
2019-08-25 18:12 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).