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 /board | |
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 'board')
-rw-r--r-- | board/ampton/board.h | 2 | ||||
-rw-r--r-- | board/atlas/board.h | 2 | ||||
-rw-r--r-- | board/bobba/board.h | 2 | ||||
-rw-r--r-- | board/cheza/board.h | 2 | ||||
-rw-r--r-- | board/coral/board.h | 2 | ||||
-rw-r--r-- | board/eve/board.h | 4 | ||||
-rw-r--r-- | board/fizz/board.c | 6 | ||||
-rw-r--r-- | board/flapjack/board.h | 2 | ||||
-rw-r--r-- | board/fleex/board.h | 2 | ||||
-rw-r--r-- | board/hatch/board.h | 2 | ||||
-rw-r--r-- | board/meep/board.h | 2 | ||||
-rw-r--r-- | board/nami/board.c | 2 | ||||
-rw-r--r-- | board/nami/board.h | 2 | ||||
-rw-r--r-- | board/nautilus/board.c | 2 | ||||
-rw-r--r-- | board/nautilus/board.h | 2 | ||||
-rw-r--r-- | board/nocturne/board.h | 2 | ||||
-rw-r--r-- | board/oak/board.c | 2 | ||||
-rw-r--r-- | board/phaser/board.h | 2 | ||||
-rw-r--r-- | board/poppy/board.c | 2 | ||||
-rw-r--r-- | board/poppy/board.h | 2 | ||||
-rw-r--r-- | board/rainier/board.h | 2 | ||||
-rw-r--r-- | board/rammus/board.c | 2 | ||||
-rw-r--r-- | board/rammus/board.h | 2 | ||||
-rw-r--r-- | board/reef/board.h | 2 | ||||
-rw-r--r-- | board/reef_mchp/board.h | 2 | ||||
-rw-r--r-- | board/servo_v4/board.c | 4 | ||||
-rw-r--r-- | board/twinkie/sniffer.c | 2 | ||||
-rw-r--r-- | board/yorp/board.h | 2 |
28 files changed, 32 insertions, 32 deletions
diff --git a/board/ampton/board.h b/board/ampton/board.h index 58b4844402..96b135d774 100644 --- a/board/ampton/board.h +++ b/board/ampton/board.h @@ -39,7 +39,7 @@ #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE diff --git a/board/atlas/board.h b/board/atlas/board.h index e37f72cd2f..aa94013c9d 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -215,7 +215,7 @@ enum sensor_id { }; /* LID_ALS needs to be polled */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS) enum adc_channel { ADC_AMON_BMON, diff --git a/board/bobba/board.h b/board/bobba/board.h index 1c508a2039..f210664f58 100644 --- a/board/bobba/board.h +++ b/board/bobba/board.h @@ -29,7 +29,7 @@ #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) /* Motion Sense Task Events */ #define CONFIG_ACCELGYRO_BMI160_INT_EVENT \ diff --git a/board/cheza/board.h b/board/cheza/board.h index 63aa937f0f..f9adee2690 100644 --- a/board/cheza/board.h +++ b/board/cheza/board.h @@ -214,7 +214,7 @@ void board_reset_pd_mcu(void); void base_detect_interrupt(enum gpio_signal signal); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS) #endif /* !defined(__ASSEMBLER__) */ diff --git a/board/coral/board.h b/board/coral/board.h index db16a7d538..3a93a88e7c 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -319,7 +319,7 @@ int board_get_version(void); void board_set_tcpc_power_mode(int port, int mode); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #endif /* !__ASSEMBLER__ */ diff --git a/board/eve/board.h b/board/eve/board.h index 5eed5b7613..fce7c0de91 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -150,7 +150,7 @@ #define CONFIG_GESTURE_TAP_THRES_MG 100 #define CONFIG_GESTURE_TAP_MAX_INTERSTICE_T 500 #define CONFIG_GESTURE_DETECTION_MASK \ - (1 << CONFIG_GESTURE_SENSOR_BATTERY_TAP) + BIT(CONFIG_GESTURE_SENSOR_BATTERY_TAP) /* USB */ #define CONFIG_USB_CHARGER @@ -299,7 +299,7 @@ void led_register_double_tap(void); void board_update_ac_status(void); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK ((1 << LID_ACCEL) | (1 << LID_LIGHT)) +#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_LIGHT)) #endif /* !__ASSEMBLER__ */ diff --git a/board/fizz/board.c b/board/fizz/board.c index e200c4722e..be1c65a8f0 100644 --- a/board/fizz/board.c +++ b/board/fizz/board.c @@ -711,7 +711,7 @@ static void setup_bj(void) switch (oem) { case OEM_KENCH: - bj = (BJ_ADAPTER_90W_MASK & (1 << sku)) ? + bj = (BJ_ADAPTER_90W_MASK & BIT(sku)) ? BJ_90W_19P5V : BJ_65W_19P5V; break; case OEM_TEEMO: @@ -720,14 +720,14 @@ static void setup_bj(void) case OEM_WUKONG_N: case OEM_WUKONG_A: case OEM_WUKONG_M: - bj = (BJ_ADAPTER_90W_MASK & (1 << sku)) ? + bj = (BJ_ADAPTER_90W_MASK & BIT(sku)) ? BJ_90W_19V : BJ_65W_19V; break; case OEM_JAX: bj = BJ_65W_19V; break; default: - bj = (BJ_ADAPTER_90W_MASK & (1 << sku)) ? + bj = (BJ_ADAPTER_90W_MASK & BIT(sku)) ? BJ_90W_19P5V : BJ_65W_19P5V; break; } diff --git a/board/flapjack/board.h b/board/flapjack/board.h index 3cf5bacc64..9877d2c1c9 100644 --- a/board/flapjack/board.h +++ b/board/flapjack/board.h @@ -94,7 +94,7 @@ #define ALS_COUNT 1 #define CONFIG_ALS_OPT3001 /* LID_ALS needs to be polled */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS) /* Camera VSYNC */ #define CONFIG_SYNC diff --git a/board/fleex/board.h b/board/fleex/board.h index 9184f85bd6..6ff03fd4c0 100644 --- a/board/fleex/board.h +++ b/board/fleex/board.h @@ -24,7 +24,7 @@ #define CONFIG_ACCEL_LIS2DE /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT /* Volume button */ diff --git a/board/hatch/board.h b/board/hatch/board.h index ee4ea2fd1f..0548147c94 100644 --- a/board/hatch/board.h +++ b/board/hatch/board.h @@ -38,7 +38,7 @@ #define CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT /* BMA253 Lid accel */ #define CONFIG_ACCEL_BMA255 -#define CONFIG_ACCEL_FORCE_MODE_MASK ((1 << LID_ACCEL) | (1 << LID_ALS)) +#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_ALS)) #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL #define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL diff --git a/board/meep/board.h b/board/meep/board.h index 7515a2ea40..39782aeaf8 100644 --- a/board/meep/board.h +++ b/board/meep/board.h @@ -29,7 +29,7 @@ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT diff --git a/board/nami/board.c b/board/nami/board.c index c21fb2338a..87771912f1 100644 --- a/board/nami/board.c +++ b/board/nami/board.c @@ -990,7 +990,7 @@ static void board_init(void) * floating SPI buffer input (MISO), which causes power leakage (see * b/64797021). */ - NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN); + NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN); /* Provide AC status to the PCH */ gpio_set_level(GPIO_PCH_ACPRESENT, extpower_is_present()); diff --git a/board/nami/board.h b/board/nami/board.h index 45e58d49bc..27f8358a99 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -327,7 +327,7 @@ void board_reset_pd_mcu(void); void board_set_tcpc_power_mode(int port, int mode); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK ((1 << LID_ACCEL) | (1 << LID_ALS)) +#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(LID_ACCEL) | BIT(LID_ALS)) /* These should be referenced only after HOOK_INIT:HOOK_PRIO_INIT_I2C+1. */ extern uint16_t board_version; diff --git a/board/nautilus/board.c b/board/nautilus/board.c index b87ff0ed37..dd79aebf27 100644 --- a/board/nautilus/board.c +++ b/board/nautilus/board.c @@ -428,7 +428,7 @@ static void board_init(void) * floating SPI buffer input (MISO), which causes power leakage (see * b/64797021). */ - NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN); + NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN); /* Provide AC status to the PCH */ gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); diff --git a/board/nautilus/board.h b/board/nautilus/board.h index acbed5897e..1d72270566 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -252,7 +252,7 @@ void board_reset_pd_mcu(void); void board_set_tcpc_power_mode(int port, int mode); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #endif /* !__ASSEMBLER__ */ diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 99984ae3ea..26dab74e0a 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -256,7 +256,7 @@ enum sensor_id { VSYNC, }; -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS) void base_pwr_fault_interrupt(enum gpio_signal s); int board_get_version(void); diff --git a/board/oak/board.c b/board/oak/board.c index 4fd49330d1..6639202654 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -485,7 +485,7 @@ void vbus_task(void) if (vbus) bc12[port].vbus |= 1 << port; else - bc12[port].vbus &= ~(1 << port); + bc12[port].vbus &= ~BIT(port); wake = 0; reg = pi3usb9281_get_interrupts(port); diff --git a/board/phaser/board.h b/board/phaser/board.h index 56e07ee863..b035268b1c 100644 --- a/board/phaser/board.h +++ b/board/phaser/board.h @@ -32,7 +32,7 @@ #define CONFIG_ACCEL_LIS2DE /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE diff --git a/board/poppy/board.c b/board/poppy/board.c index 235389fc89..36ba4561eb 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -521,7 +521,7 @@ static void board_init(void) * floating SPI buffer input (MISO), which causes power leakage (see * b/64797021). */ - NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN); + NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN); /* Provide AC status to the PCH */ gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); diff --git a/board/poppy/board.h b/board/poppy/board.h index 92d15ce0f7..a79216bb63 100644 --- a/board/poppy/board.h +++ b/board/poppy/board.h @@ -269,7 +269,7 @@ void board_set_tcpc_power_mode(int port, int mode); void base_detect_interrupt(enum gpio_signal signal); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ALS) #endif /* !__ASSEMBLER__ */ diff --git a/board/rainier/board.h b/board/rainier/board.h index 3b31b2079d..334d481732 100644 --- a/board/rainier/board.h +++ b/board/rainier/board.h @@ -82,7 +82,7 @@ #define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3) /* Sensors without hardware FIFO are in forced mode. */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_BARO) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_BARO) /* USB PD config */ #define CONFIG_CHARGE_MANAGER diff --git a/board/rammus/board.c b/board/rammus/board.c index 7497ac8aa5..31b0a3fb10 100644 --- a/board/rammus/board.c +++ b/board/rammus/board.c @@ -441,7 +441,7 @@ static void board_init(void) * floating SPI buffer input (MISO), which causes power leakage (see * b/64797021). */ - NPCX_PUPD_EN1 |= (1 << NPCX_DEVPU1_F_SPI_PUD_EN); + NPCX_PUPD_EN1 |= BIT(NPCX_DEVPU1_F_SPI_PUD_EN); /* Provide AC status to the PCH */ gpio_set_level(GPIO_PCH_ACPRESENT, extpower_is_present()); diff --git a/board/rammus/board.h b/board/rammus/board.h index da8f311fca..66c79f9317 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -278,7 +278,7 @@ void board_reset_pd_mcu(void); void board_set_tcpc_power_mode(int port, int mode); /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #endif /* !__ASSEMBLER__ */ diff --git a/board/reef/board.h b/board/reef/board.h index b166d24c8b..6847d82c5b 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -320,7 +320,7 @@ void board_set_tcpc_power_mode(int port, int mode); /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK \ - ((1 << LID_ACCEL) | (1 << BASE_BARO) | (1 << LID_ALS)) + (BIT(LID_ACCEL) | BIT(BASE_BARO) | BIT(LID_ALS)) #endif /* !__ASSEMBLER__ */ diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h index 1250689d0d..4526946070 100644 --- a/board/reef_mchp/board.h +++ b/board/reef_mchp/board.h @@ -343,7 +343,7 @@ uint16_t board_i2c_slave_addrs(int controller); */ /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK \ - ((1 << LID_ACCEL) | (1 << BASE_BARO) | (1 << LID_ALS)) + (BIT(LID_ACCEL) | BIT(BASE_BARO) | BIT(LID_ALS)) #endif /* !__ASSEMBLER__ */ diff --git a/board/servo_v4/board.c b/board/servo_v4/board.c index 6890027346..15a5fcdd42 100644 --- a/board/servo_v4/board.c +++ b/board/servo_v4/board.c @@ -214,9 +214,9 @@ static void write_ioexpander(int bank, int gpio, int val) /* Read output port register */ i2c_read8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A + bank, &tmp); if (val) - tmp |= (1 << gpio); + tmp |= BIT(gpio); else - tmp &= ~(1 << gpio); + tmp &= ~BIT(gpio); /* Write back modified output port register */ i2c_write8(1, GPIOX_I2C_ADDR, GPIOX_OUT_PORT_A + bank, tmp); } diff --git a/board/twinkie/sniffer.c b/board/twinkie/sniffer.c index e35b457ff7..72cd4e1348 100644 --- a/board/twinkie/sniffer.c +++ b/board/twinkie/sniffer.c @@ -301,7 +301,7 @@ void sniffer_task(void) task_wait_event(-1); /* send the available samples over USB if we have a buffer*/ while (filled_dma && free_usb) { - while (!(filled_dma & (1 << d))) { + while (!(filled_dma & BIT(d))) { d = (d + 1) & 31; off += EP_PAYLOAD_SIZE; if (off >= RX_COUNT) diff --git a/board/yorp/board.h b/board/yorp/board.h index 5a1e152b2a..01f701184a 100644 --- a/board/yorp/board.h +++ b/board/yorp/board.h @@ -27,7 +27,7 @@ #define CONFIG_ACCEL_KX022 /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ /* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE |