summaryrefslogtreecommitdiff
path: root/driver/mag_lis2mdl.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/mag_lis2mdl.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/mag_lis2mdl.c')
-rw-r--r--driver/mag_lis2mdl.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/driver/mag_lis2mdl.c b/driver/mag_lis2mdl.c
index a9a00cc7c9..c0f7dff90d 100644
--- a/driver/mag_lis2mdl.c
+++ b/driver/mag_lis2mdl.c
@@ -66,25 +66,16 @@ void lis2mdl_normalize(const struct motion_sensor_t *s,
v[Z] += cal->bias[Z];
}
-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)
{
- struct stprivate_data *data = s->drv_data;
-
/* Range is fixed by hardware */
if (range != s->default_range)
return EC_ERROR_INVAL;
- data->base.range = range;
+ s->current_range = range;
return EC_SUCCESS;
}
-static int get_range(const struct motion_sensor_t *s)
-{
- struct stprivate_data *data = s->drv_data;
-
- return data->base.range;
-}
-
/**
* set_offset - Set data offset
* @s: Motion sensor pointer
@@ -140,7 +131,7 @@ int lis2mdl_thru_lsm6dsm_read(const struct motion_sensor_t *s, intv3_t v)
return ret;
}
-int lis2mdl_thru_lsm6dsm_init(const struct motion_sensor_t *s)
+int lis2mdl_thru_lsm6dsm_init(struct motion_sensor_t *s)
{
int ret = EC_ERROR_UNIMPLEMENTED;
struct mag_cal_t *cal = LIS2MDL_CAL(s);
@@ -261,7 +252,7 @@ int lis2mdl_read(const struct motion_sensor_t *s, intv3_t v)
/**
* Initialize the sensor. This function will verify the who-am-I register
*/
-int lis2mdl_init(const struct motion_sensor_t *s)
+int lis2mdl_init(struct motion_sensor_t *s)
{
int ret = EC_ERROR_UNKNOWN, who_am_i, count = LIS2MDL_STARTUP_MS;
struct stprivate_data *data = s->drv_data;
@@ -405,7 +396,6 @@ const struct accelgyro_drv lis2mdl_drv = {
.set_data_rate = lis2mdl_set_data_rate,
#endif /* !CONFIG_MAG_LSM6DSM_LIS2MDL */
.set_range = set_range,
- .get_range = get_range,
.get_data_rate = st_get_data_rate,
.get_resolution = st_get_resolution,
.set_offset = set_offset,