mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-15 00:56:22 +00:00
driver: kionix: Use base accelgyro structure
Unify get_range/get_datarate by using accelgyro_saved_data_t structure. BUG=none BRANCH=none TEST=compile Change-Id: I0bfa2f06c5dd2021a5af9e6499c97e65988167ce Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961221 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
7ce651d4ca
commit
9e95ac3e0a
@@ -320,14 +320,15 @@ static int set_range(const struct motion_sensor_t *s, int range, int rnd)
|
||||
|
||||
ret = set_value(s, reg, range_val, range_field);
|
||||
if (ret == EC_SUCCESS)
|
||||
data->sensor_range = index;
|
||||
data->base.range = ranges[T(s)][index].val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_range(const struct motion_sensor_t *s)
|
||||
{
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
return ranges[T(s)][data->sensor_range].val;
|
||||
|
||||
return data->base.range;
|
||||
}
|
||||
|
||||
static int set_resolution(const struct motion_sensor_t *s, int res, int rnd)
|
||||
@@ -344,14 +345,15 @@ static int set_resolution(const struct motion_sensor_t *s, int res, int rnd)
|
||||
|
||||
ret = set_value(s, reg, res_val, res_field);
|
||||
if (ret == EC_SUCCESS)
|
||||
data->sensor_resolution = index;
|
||||
data->sensor_resolution = resolutions[T(s)][index].val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_resolution(const struct motion_sensor_t *s)
|
||||
{
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
return resolutions[T(s)][data->sensor_resolution].val;
|
||||
|
||||
return data->sensor_resolution;
|
||||
}
|
||||
|
||||
static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
|
||||
@@ -368,14 +370,15 @@ static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
|
||||
|
||||
ret = set_value(s, reg, odr_val, odr_field);
|
||||
if (ret == EC_SUCCESS)
|
||||
data->sensor_datarate = index;
|
||||
data->base.odr = datarates[T(s)][index].val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_data_rate(const struct motion_sensor_t *s)
|
||||
{
|
||||
struct kionix_accel_data *data = s->drv_data;
|
||||
return datarates[T(s)][data->sensor_datarate].val;
|
||||
|
||||
return data->base.odr;
|
||||
}
|
||||
|
||||
static int set_offset(const struct motion_sensor_t *s, const int16_t *offset,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define __CROS_EC_ACCEL_KIONIX_H
|
||||
|
||||
#include "common.h"
|
||||
#include "accelgyro.h"
|
||||
#include "driver/accel_kx022.h"
|
||||
#include "driver/accel_kxcj9.h"
|
||||
|
||||
@@ -22,11 +23,7 @@ struct accel_param_pair {
|
||||
};
|
||||
|
||||
struct kionix_accel_data {
|
||||
/* Note, the following are indicies into their respective tables. */
|
||||
/* Current range of accelerometer. */
|
||||
int sensor_range;
|
||||
/* Current output data rate of accelerometer. */
|
||||
int sensor_datarate;
|
||||
struct accelgyro_saved_data_t base;
|
||||
/* Current resolution of accelerometer. */
|
||||
int sensor_resolution;
|
||||
int16_t offset[3];
|
||||
|
||||
Reference in New Issue
Block a user