summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-03-31 17:44:41 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-05 03:25:50 +0000
commite3579f43d8e9bf90f9df1ffb1f927f52fdef212b (patch)
treebb122c737ed90fe86db0b3da631c233d8f5b9b39
parent529548208cad436232cfba2c0b802523ddaf5383 (diff)
downloadchrome-ec-e3579f43d8e9bf90f9df1ffb1f927f52fdef212b.tar.gz
accel: changed motion sense host command to be more permissive with data args
Changed the ec_rate sub-command of the motion sense command. Now it permits any value for the rate as an argument and then bounds that to within the min and max. This matches the behavior of the other sub-commands such that for any argument the command will return success, but if the arg is not valid, it finds the closest valid value. BUG=none BRANCH=rambi TEST=Tested on a glimmer by using the ectool motionsense command. Made sure if you give it a value outside of the range [5, 1000], then it simply bounds it to the closest value in that range: > ectool motionsense ec_rate 0 5 > ectool motionsense ec_rate 100 100 > ectool motionsense ec_rate 1100 1000 Change-Id: If71299e3ab27bcfac87103c672793ac61f88100e Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/192525 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193308
-rw-r--r--common/motion_sense.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 8629fa7588..e94604fae5 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -378,15 +378,15 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args)
* has a value.
*/
if (in->ec_rate.data != EC_MOTION_SENSE_NO_VALUE) {
- if (in->ec_rate.data >= MIN_POLLING_INTERVAL_MS &&
- in->ec_rate.data <= MAX_POLLING_INTERVAL_MS) {
- accel_interval_ap_on_ms = in->ec_rate.data;
- accel_interval_ms = accel_interval_ap_on_ms;
- } else {
- CPRINTF("[%T MS bad EC sampling rate %d]\n",
- in->ec_rate.data);
- return EC_RES_INVALID_PARAM;
- }
+ /* Bound the new sampling rate. */
+ data = in->ec_rate.data;
+ if (data < MIN_POLLING_INTERVAL_MS)
+ data = MIN_POLLING_INTERVAL_MS;
+ if (data > MAX_POLLING_INTERVAL_MS)
+ data = MAX_POLLING_INTERVAL_MS;
+
+ accel_interval_ap_on_ms = data;
+ accel_interval_ms = data;
}
out->ec_rate.ret = accel_interval_ap_on_ms;