summaryrefslogtreecommitdiff
path: root/chip/lm4
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2019-03-11 16:07:55 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-26 04:42:56 -0700
commitac77140b7f4f42075d2377fc9d956a636b05aacf (patch)
treec64c6a30916ff741a2ab235141f7bd071cd54483 /chip/lm4
parentbb266fc26fc05d4ab22de6ad7bce5b477c9f9140 (diff)
downloadchrome-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 'chip/lm4')
-rw-r--r--chip/lm4/config_chip.h2
-rw-r--r--chip/lm4/fan.c6
-rw-r--r--chip/lm4/flash.c2
-rw-r--r--chip/lm4/gpio.c4
-rw-r--r--chip/lm4/i2c.c4
-rw-r--r--chip/lm4/keyboard_raw.c2
-rw-r--r--chip/lm4/lpc.c12
-rw-r--r--chip/lm4/uart.c2
8 files changed, 17 insertions, 17 deletions
diff --git a/chip/lm4/config_chip.h b/chip/lm4/config_chip.h
index 020a5d7c09..2456095aba 100644
--- a/chip/lm4/config_chip.h
+++ b/chip/lm4/config_chip.h
@@ -102,7 +102,7 @@
/* Chip needs to do custom pre-init */
#define CONFIG_CHIP_PRE_INIT
-#define GPIO_PIN(port, index) GPIO_##port, (1 << index)
+#define GPIO_PIN(port, index) GPIO_##port, BIT(index)
#define GPIO_PIN_MASK(p, m) .port = GPIO_##p, .mask = (m)
#endif /* __CROS_EC_CONFIG_CHIP_H */
diff --git a/chip/lm4/fan.c b/chip/lm4/fan.c
index 39baa0a03e..c0eee330db 100644
--- a/chip/lm4/fan.c
+++ b/chip/lm4/fan.c
@@ -32,14 +32,14 @@
void fan_set_enabled(int ch, int enabled)
{
if (enabled)
- LM4_FAN_FANCTL |= (1 << ch);
+ LM4_FAN_FANCTL |= BIT(ch);
else
- LM4_FAN_FANCTL &= ~(1 << ch);
+ LM4_FAN_FANCTL &= ~BIT(ch);
}
int fan_get_enabled(int ch)
{
- return (LM4_FAN_FANCTL & (1 << ch)) ? 1 : 0;
+ return (LM4_FAN_FANCTL & BIT(ch)) ? 1 : 0;
}
void fan_set_duty(int ch, int percent)
diff --git a/chip/lm4/flash.c b/chip/lm4/flash.c
index 1c8da9b26a..135b5d0960 100644
--- a/chip/lm4/flash.c
+++ b/chip/lm4/flash.c
@@ -17,7 +17,7 @@
#define FLASH_FWB_BYTES (FLASH_FWB_WORDS * 4)
#define BANK_SHIFT 5 /* bank registers have 32bits each, 2^32 */
-#define BANK_MASK ((1 << BANK_SHIFT) - 1) /* 5 bits */
+#define BANK_MASK (BIT(BANK_SHIFT) - 1) /* 5 bits */
#define F_BANK(b) ((b) >> BANK_SHIFT)
#define F_BIT(b) (1 << ((b) & BANK_MASK))
diff --git a/chip/lm4/gpio.c b/chip/lm4/gpio.c
index e90eb2bf4f..051e129dbf 100644
--- a/chip/lm4/gpio.c
+++ b/chip/lm4/gpio.c
@@ -61,7 +61,7 @@ void gpio_set_alternate_function(uint32_t port, uint32_t mask, int func)
int i;
/* Expand mask from bits to nibbles */
for (i = 0; i < 8; i++) {
- if (mask & (1 << i))
+ if (mask & BIT(i))
pctlmask |= 1 << (4 * i);
}
@@ -191,7 +191,7 @@ static int gpio_port_to_clock_gate_mask(uint32_t gpio_port)
{
int index = find_gpio_port_index(gpio_port);
- return index >= 0 ? (1 << index) : 0;
+ return index >= 0 ? BIT(index) : 0;
}
#endif
diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c
index 6a746fd9b5..1183ce9550 100644
--- a/chip/lm4/i2c.c
+++ b/chip/lm4/i2c.c
@@ -201,9 +201,9 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size,
i2c_unwedge(port);
/* Clock timeout or arbitration lost. Reset port to clear. */
- atomic_or(LM4_SYSTEM_SRI2C_ADDR, (1 << port));
+ atomic_or(LM4_SYSTEM_SRI2C_ADDR, BIT(port));
clock_wait_cycles(3);
- atomic_clear(LM4_SYSTEM_SRI2C_ADDR, (1 << port));
+ atomic_clear(LM4_SYSTEM_SRI2C_ADDR, BIT(port));
clock_wait_cycles(3);
/* Restore settings */
diff --git a/chip/lm4/keyboard_raw.c b/chip/lm4/keyboard_raw.c
index 85042ce85e..00e00f1c05 100644
--- a/chip/lm4/keyboard_raw.c
+++ b/chip/lm4/keyboard_raw.c
@@ -68,7 +68,7 @@ test_mockable void keyboard_raw_drive_column(int col)
else if (col == KEYBOARD_COLUMN_ALL)
mask = 0; /* Assert all outputs */
else
- mask = 0x1fff ^ (1 << col); /* Assert a single output */
+ mask = 0x1fff ^ BIT(col); /* Assert a single output */
#ifdef CONFIG_KEYBOARD_COL2_INVERTED
/* Invert column 2 output */
diff --git a/chip/lm4/lpc.c b/chip/lm4/lpc.c
index 745e5e5465..e96e35d359 100644
--- a/chip/lm4/lpc.c
+++ b/chip/lm4/lpc.c
@@ -747,12 +747,12 @@ static void lpc_init(void)
/* Enable LPC channels */
LM4_LPC_LPCCTL = LM4_LPC_SCI_CLK_1 |
- (1 << LPC_CH_ACPI) |
- (1 << LPC_CH_PORT80) |
- (1 << LPC_CH_CMD_DATA) |
- (1 << LPC_CH_KEYBOARD) |
- (1 << LPC_CH_CMD) |
- (1 << LPC_CH_MEMMAP);
+ BIT(LPC_CH_ACPI) |
+ BIT(LPC_CH_PORT80) |
+ BIT(LPC_CH_CMD_DATA) |
+ BIT(LPC_CH_KEYBOARD) |
+ BIT(LPC_CH_CMD) |
+ BIT(LPC_CH_MEMMAP);
#ifdef CONFIG_UART_HOST
LM4_LPC_LPCCTL |= 1 << LPC_CH_COMX;
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index 6ef9f67834..04a22c382c 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -193,7 +193,7 @@ void uart_init(void)
clock_enable_peripheral(CGC_OFFSET_UART, mask, CGC_MODE_ALL);
#ifdef CONFIG_UART_HOST
- mask |= (1 << CONFIG_UART_HOST);
+ mask |= BIT(CONFIG_UART_HOST);
#endif
clock_enable_peripheral(CGC_OFFSET_UART, mask,