summaryrefslogtreecommitdiff
path: root/driver/accel_lis2dw12.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-05-17 16:43:02 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-12 03:23:26 +0000
commitd28c10498cdbf007b97b5c0a9a951373574d4eea (patch)
tree3d66ca06837aae98ff747fff85b439976e563045 /driver/accel_lis2dw12.c
parent9676f9291f60efdfb31373aeb77385ebb6e9f6e5 (diff)
downloadchrome-ec-d28c10498cdbf007b97b5c0a9a951373574d4eea.tar.gz
motion_sense: Make change in range permanent
When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'driver/accel_lis2dw12.c')
-rw-r--r--driver/accel_lis2dw12.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/driver/accel_lis2dw12.c b/driver/accel_lis2dw12.c
index e67489956a..dbc3dcac03 100644
--- a/driver/accel_lis2dw12.c
+++ b/driver/accel_lis2dw12.c
@@ -307,11 +307,10 @@ static int set_power_mode(const struct motion_sensor_t *s,
* @range: Range
* @rnd: Round up/down flag
*/
-static int set_range(const struct motion_sensor_t *s, int range, int rnd)
+static int set_range(struct motion_sensor_t *s, int range, int rnd)
{
int err = EC_SUCCESS;
uint8_t reg_val;
- struct stprivate_data *data = s->drv_data;
int newrange = range;
/* Adjust and check rounded value. */
@@ -338,7 +337,7 @@ static int set_range(const struct motion_sensor_t *s, int range, int rnd)
err = st_write_data_with_mask(s, LIS2DW12_FS_ADDR, LIS2DW12_FS_MASK,
reg_val);
if (err == EC_SUCCESS)
- data->base.range = newrange;
+ s->current_range = newrange;
else
goto unlock_rate;
@@ -352,13 +351,6 @@ unlock_rate:
return err;
}
-static int get_range(const struct motion_sensor_t *s)
-{
- struct stprivate_data *data = s->drv_data;
-
- return data->base.range;
-}
-
/**
* ODR reg value from selected data rate in mHz.
*/
@@ -498,7 +490,7 @@ static int read(const struct motion_sensor_t *s, intv3_t v)
return EC_SUCCESS;
}
-static int init(const struct motion_sensor_t *s)
+static int init(struct motion_sensor_t *s)
{
int ret = 0, tmp, timeout = 0, status;
struct stprivate_data *data = s->drv_data;
@@ -592,7 +584,6 @@ const struct accelgyro_drv lis2dw12_drv = {
.init = init,
.read = read,
.set_range = set_range,
- .get_range = get_range,
.get_resolution = st_get_resolution,
.set_data_rate = set_data_rate,
.get_data_rate = st_get_data_rate,