diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2019-03-11 16:07:55 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-26 04:42:56 -0700 |
commit | ac77140b7f4f42075d2377fc9d956a636b05aacf (patch) | |
tree | c64c6a30916ff741a2ab235141f7bd071cd54483 /common/keyboard_scan.c | |
parent | bb266fc26fc05d4ab22de6ad7bce5b477c9f9140 (diff) | |
download | chrome-ec-ac77140b7f4f42075d2377fc9d956a636b05aacf.tar.gz |
common: bit change 1 << constants with BIT(constants)
Mechanical replacement of bit operation where operand is a constant.
More bit operation exist, but prone to errors.
Reveal a bug in npcx:
chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow]
BUG=None
BRANCH=None
TEST=None
Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1518660
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'common/keyboard_scan.c')
-rw-r--r-- | common/keyboard_scan.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 24fc7bc73c..a8f843e0a2 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -197,10 +197,10 @@ static void simulate_key(int row, int col, int pressed) { int old_polls; - if ((simulated_key[col] & (1 << row)) == ((pressed ? 1 : 0) << row)) + if ((simulated_key[col] & BIT(row)) == ((pressed ? 1 : 0) << row)) return; /* No change */ - simulated_key[col] ^= (1 << row); + simulated_key[col] ^= BIT(row); /* Keep track of polls now that we've got keys simulated */ old_polls = kbd_polls; @@ -481,7 +481,7 @@ static int check_keys_changed(uint8_t *state) continue; for (i = 0; i < KEYBOARD_ROWS; i++) { - if (diff & (1 << i)) + if (diff & BIT(i)) scan_edge_index[c][i] = scan_time_index; } @@ -601,7 +601,7 @@ static uint32_t check_key_list(const uint8_t *state) k = boot_key_list; for (c = 0; c < ARRAY_SIZE(boot_key_list); c++, k++) { if (curr_state[k->mask_index] & k->mask_value) { - boot_key_mask |= (1 << c); + boot_key_mask |= BIT(c); curr_state[k->mask_index] &= ~k->mask_value; } } @@ -1005,7 +1005,7 @@ static int command_keyboard_press(int argc, char **argv) if (simulated_key[i] == 0) continue; for (j = 0; j < KEYBOARD_ROWS; ++j) - if (simulated_key[i] & (1 << j)) + if (simulated_key[i] & BIT(j)) ccprintf("\t%d %d\n", i, j); } |