summaryrefslogtreecommitdiff
path: root/driver/mag_bmm150.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2019-03-11 15:57:52 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-26 04:42:55 -0700
commitbb266fc26fc05d4ab22de6ad7bce5b477c9f9140 (patch)
treef6ada087f62246c3a9547e649ac8846b0ed6d5ab /driver/mag_bmm150.c
parent0bfc511527cf2aebfa163c63a1d028419ca0b0c3 (diff)
downloadchrome-ec-bb266fc26fc05d4ab22de6ad7bce5b477c9f9140.tar.gz
common: replace 1 << digits, with BIT(digits)
Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'driver/mag_bmm150.c')
-rw-r--r--driver/mag_bmm150.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/driver/mag_bmm150.c b/driver/mag_bmm150.c
index cb53641c00..9598d85105 100644
--- a/driver/mag_bmm150.c
+++ b/driver/mag_bmm150.c
@@ -149,7 +149,7 @@ void bmm150_temp_compensate_xy(const struct motion_sensor_t *s,
if (r == 0)
inter = 0;
else
- inter = ((int)regs->dig_xyz1 << 14) / r - (1 << 14);
+ inter = ((int)regs->dig_xyz1 << 14) / r - BIT(14);
for (axis = X; axis <= Y; axis++) {
if (raw[axis] == BMM150_FLIP_OVERFLOW_ADCVAL) {
@@ -195,16 +195,16 @@ void bmm150_temp_compensate_z(const struct motion_sensor_t *s,
* ((z - dig_z4) * 131072 - dig_z3 * (r - dig_xyz1)) /
* ((dig_z2 + dig_z1 * r / 32768) * 4);
*
- * We spread 4 so we multiply by 131072 / 4 == (1<<15) only.
+ * We spread 4 so we multiply by 131072 / 4 == BIT(15) only.
*/
dividend = (raw[Z] - (int)regs->dig_z4) << 15;
dividend -= (regs->dig_z3 * (r - (int)regs->dig_xyz1)) >> 2;
- /* add 1 << 15 to round to next integer. */
- divisor = (int)regs->dig_z1 * (r << 1) + (1 << 15);
+ /* add BIT(15) to round to next integer. */
+ divisor = (int)regs->dig_z1 * (r << 1) + BIT(15);
divisor >>= 16;
divisor += (int)regs->dig_z2;
comp[Z] = dividend / divisor;
- if (comp[Z] > (1 << 15) || comp[Z] < -(1 << 15))
+ if (comp[Z] > BIT(15) || comp[Z] < -(BIT(15)))
comp[Z] = BMM150_OVERFLOW_OUTPUT;
}