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/usb_pd_protocol.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/usb_pd_protocol.c')
-rw-r--r-- | common/usb_pd_protocol.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index ebac69b209..730281c9b5 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -477,7 +477,7 @@ static int reset_device_and_notify(int port) /* Wake up all waiting tasks. */ while (waiting_tasks) { task = __fls(waiting_tasks); - waiting_tasks &= ~(1 << task); + waiting_tasks &= ~BIT(task); task_set_event(task, TASK_EVENT_PD_AWAKE, 0); } @@ -4366,7 +4366,7 @@ static void resume_pd_port(void) while (suspended_ports) { port = __builtin_ctz(suspended_ports); - suspended_ports &= ~(1 << port); + suspended_ports &= ~BIT(port); pd_set_suspend(port, 0); } } @@ -4574,7 +4574,7 @@ static void re_enable_ports(void) while (ports) { int port = __fls(ports); - ports &= ~(1 << port); + ports &= ~BIT(port); /* * Let the board know that the overcurrent is @@ -4605,7 +4605,7 @@ void pd_handle_overcurrent(int port) board_overcurrent_event(port, 1); /* Wait 1s before trying to re-enable the port. */ - atomic_or(&port_oc_reset_req, (1 << port)); + atomic_or(&port_oc_reset_req, BIT(port)); hook_call_deferred(&re_enable_ports_data, SECOND); } #endif /* defined(CONFIG_USBC_PPC) */ |