summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-10-19 14:36:10 -0700
committerCommit Bot <commit-bot@chromium.org>2020-10-20 20:15:03 +0000
commit512823a8aa87d4b6a83f88bab05fe586de6c14aa (patch)
tree5be9dc89304498414d1e33e0b578e9c53b990b41 /common
parent28fe21716cdacac0ecc025407b727eaf5a99b720 (diff)
downloadchrome-ec-512823a8aa87d4b6a83f88bab05fe586de6c14aa.tar.gz
common: online_calibration: Fix compilation issue
- Fix compilation error: sizeof() of an input array was not calculated properly. - Fix calling convention: use sensor pointer instead of sensor number - Use common formula to calculate sensor number. BUG=none BRANCH=none TEST=compile, unittest, load on eve with online calibration added. Change-Id: I06ff30eb5710cbe8f91c939b2ccc084c20a37847 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486304 Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/motion_sense.c4
-rw-r--r--common/online_calibration.c12
2 files changed, 8 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index e739bc8f75..a283ce7346 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -1354,9 +1354,7 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args)
args->response_size =
- online_calibration_read(
- (int)(sensor - motion_sensors),
- out->online_calib_read.data)
+ online_calibration_read(sensor, &out->online_calib_read)
? sizeof(struct ec_response_online_calibration_data)
: 0;
break;
diff --git a/common/online_calibration.c b/common/online_calibration.c
index ca7a5a620d..5cef26fd00 100644
--- a/common/online_calibration.c
+++ b/common/online_calibration.c
@@ -104,7 +104,7 @@ static void check_gyro_cal_new_bias(struct motion_sensor_t *sensor)
(struct online_calib_data *)sensor->online_calib_data;
struct gyro_cal_data *data =
(struct gyro_cal_data *)calib_data->type_specific_data;
- size_t sensor_num = motion_sensors - sensor;
+ int sensor_num = sensor - motion_sensors;
int temp_out;
fpv3_t bias_out;
uint32_t timestamp_out;
@@ -228,16 +228,18 @@ bool online_calibration_has_new_values(void)
return has_dirty;
}
-bool online_calibration_read(int sensor_num, int16_t out[3])
+bool online_calibration_read(struct motion_sensor_t *sensor,
+ struct ec_response_online_calibration_data *out)
{
+ int sensor_num = sensor - motion_sensors;
bool has_valid;
mutex_lock(&g_calib_cache_mutex);
has_valid = (sensor_calib_cache_valid_map & BIT(sensor_num)) != 0;
if (has_valid) {
/* Update data in out */
- memcpy(out, motion_sensors[sensor_num].online_calib_data->cache,
- sizeof(out));
+ memcpy(out->data, sensor->online_calib_data->cache,
+ sizeof(out->data));
/* Clear dirty bit */
sensor_calib_cache_dirty_map &= ~(1 << sensor_num);
}
@@ -250,7 +252,7 @@ int online_calibration_process_data(struct ec_response_motion_sensor_data *data,
struct motion_sensor_t *sensor,
uint32_t timestamp)
{
- size_t sensor_num = motion_sensors - sensor;
+ int sensor_num = sensor - motion_sensors;
int rc;
int temperature;
struct online_calib_data *calib_data;