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-01 16:19:11 +0000
commit056a0fb14a133a2ea82b8c5b445a3d6ef45b8072 (patch)
tree7f863661d9912588e45f7701a7d327edb8ababe4
parent199536ff7a77b3dc7284df96fd5c4d1a809d8821 (diff)
downloadchrome-ec-056a0fb14a133a2ea82b8c5b445a3d6ef45b8072.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>
-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;