summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-14 16:50:44 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-09-18 17:55:31 -0700
commita2ef386ee745f2c34585d50a850afb5087c6325c (patch)
treed2a366b5b556f59b5091930acf1b166d5f8df83c
parent6e96a91f24b0c0d68712cb792abb0840437f300e (diff)
downloadchrome-ec-a2ef386ee745f2c34585d50a850afb5087c6325c.tar.gz
common: motion: print return of drv->init()
In motion_sense_init, gather the result of the sensor init routine. BUG=none BRANCH=smaug TEST=Get the result of init() when calling accelinit. Change-Id: I8d0219a2b81fdf6d512976db5a28646ee5f6b994 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299946 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/motion_sense.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 9add2d1712..737a7b35ac 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -273,7 +273,7 @@ int motion_sense_set_accel_interval(void)
return accel_interval;
}
-static inline void motion_sense_init(struct motion_sensor_t *sensor)
+static inline int motion_sense_init(struct motion_sensor_t *sensor)
{
int ret, cnt = 3;
@@ -291,6 +291,7 @@ static inline void motion_sense_init(struct motion_sensor_t *sensor)
sensor->oversampling = 0;
motion_sense_set_data_rate(sensor);
}
+ return ret;
}
/*
@@ -302,17 +303,23 @@ static inline void motion_sense_init(struct motion_sensor_t *sensor)
*/
static void motion_sense_switch_sensor_rate(void)
{
- int i;
+ int i, ret;
struct motion_sensor_t *sensor;
for (i = 0; i < motion_sensor_count; ++i) {
sensor = &motion_sensors[i];
if (SENSOR_ACTIVE(sensor)) {
/* Initialize or just back the odr previously set. */
- if (sensor->state == SENSOR_INITIALIZED)
+ if (sensor->state == SENSOR_INITIALIZED) {
motion_sense_set_data_rate(sensor);
- else
- motion_sense_init(sensor);
+ } else {
+ ret = motion_sense_init(sensor);
+ if (ret != EC_SUCCESS) {
+ CPRINTS("%s: %d: init failed: %d",
+ sensor->name, i, ret);
+ }
+ }
} else {
+ /* The sensors are being powered off */
if (sensor->state == SENSOR_INITIALIZED)
sensor->state = SENSOR_NOT_INITIALIZED;
}
@@ -1127,7 +1134,7 @@ DECLARE_CONSOLE_COMMAND(accelread, command_accel_read_xyz,
static int command_accel_init(int argc, char **argv)
{
char *e;
- int id;
+ int id, ret;
struct motion_sensor_t *sensor;
if (argc < 2)
@@ -1140,9 +1147,9 @@ static int command_accel_init(int argc, char **argv)
return EC_ERROR_PARAM1;
sensor = &motion_sensors[id];
- motion_sense_init(sensor);
+ ret = motion_sense_init(sensor);
- ccprintf("%s: %d\n", sensor->name, sensor->state);
+ ccprintf("%s: state %d - %d\n", sensor->name, sensor->state, ret);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(accelinit, command_accel_init,