From ac77140b7f4f42075d2377fc9d956a636b05aacf Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Mon, 11 Mar 2019 16:07:55 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri --- common/usb_pd_protocol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common/usb_pd_protocol.c') 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) */ -- cgit v1.2.1