summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2020-10-07 12:13:52 +0200
committerCommit Bot <commit-bot@chromium.org>2020-10-27 09:35:49 +0000
commita05f7b9f469e7c171f4a737968ab5cbd11ba1253 (patch)
treeab128a89ce9206ca967ad104e307d6c0b4c33a52 /chip
parent3cba51e9e807e7015d81c2891c47ea4c59587a1c (diff)
downloadchrome-ec-a05f7b9f469e7c171f4a737968ab5cbd11ba1253.tar.gz
tree: Use new atomic_* implementation
It is done as a part of porting to Zephyr. Since the implementation of atomic functions is done for all architectures use atomic_* instead of deprecated_atomic_*. Sometimes there was a compilation error "discards 'volatile' qualifier" due to dropping "volatile" in the argument of the functions, thus some pointers casts need to be made. It shouldn't cause any issues, because we are sure about generated asm (store operation will be performed). BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/ish/uart.c2
-rw-r--r--chip/lm4/i2c.c4
-rw-r--r--chip/mt8192_scp/ipi.c4
-rw-r--r--chip/npcx/cec.c4
-rw-r--r--chip/stm32/pwm.c6
-rw-r--r--chip/stm32/usart_info_command.c8
-rw-r--r--chip/stm32/usart_rx_dma.c4
-rw-r--r--chip/stm32/usart_rx_interrupt-stm32f4.c2
-rw-r--r--chip/stm32/usart_rx_interrupt-stm32l.c4
-rw-r--r--chip/stm32/usart_rx_interrupt.c2
-rw-r--r--chip/stm32/usb.c2
-rw-r--r--chip/stm32/usb_hid_keyboard.c2
12 files changed, 22 insertions, 22 deletions
diff --git a/chip/ish/uart.c b/chip/ish/uart.c
index b0f21cdf5f..d958dc94c5 100644
--- a/chip/ish/uart.c
+++ b/chip/ish/uart.c
@@ -264,7 +264,7 @@ static int uart_client_init(enum UART_PORT id, uint32_t baud_rate_id, int flags)
uart_ctx[id].client_flags = flags;
- deprecated_atomic_and(&uart_ctx[id].uart_state, ~UART_STATE_CG);
+ atomic_and(&uart_ctx[id].uart_state, ~UART_STATE_CG);
uart_hw_init(id);
return EC_SUCCESS;
diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c
index 0608b433bc..b5a9e566d7 100644
--- a/chip/lm4/i2c.c
+++ b/chip/lm4/i2c.c
@@ -202,9 +202,9 @@ int chip_i2c_xfer(const int port, const uint16_t slave_addr_flags,
i2c_unwedge(port);
/* Clock timeout or arbitration lost. Reset port to clear. */
- deprecated_atomic_or(LM4_SYSTEM_SRI2C_ADDR, BIT(port));
+ atomic_or(LM4_SYSTEM_SRI2C_ADDR, BIT(port));
clock_wait_cycles(3);
- deprecated_atomic_clear_bits(LM4_SYSTEM_SRI2C_ADDR, BIT(port));
+ atomic_clear_bits(LM4_SYSTEM_SRI2C_ADDR, BIT(port));
clock_wait_cycles(3);
/* Restore settings */
diff --git a/chip/mt8192_scp/ipi.c b/chip/mt8192_scp/ipi.c
index a6b2028329..fba511a642 100644
--- a/chip/mt8192_scp/ipi.c
+++ b/chip/mt8192_scp/ipi.c
@@ -30,13 +30,13 @@ static uint32_t disable_irq_count, saved_int_mask;
void ipi_disable_irq(void)
{
- if (deprecated_atomic_read_add(&disable_irq_count, 1) == 0)
+ if (atomic_read_add(&disable_irq_count, 1) == 0)
saved_int_mask = read_clear_int_mask();
}
void ipi_enable_irq(void)
{
- if (deprecated_atomic_read_sub(&disable_irq_count, 1) == 1)
+ if (atomic_read_sub(&disable_irq_count, 1) == 1)
set_int_mask(saved_int_mask);
}
diff --git a/chip/npcx/cec.c b/chip/npcx/cec.c
index 76fbf8279f..b41e36e127 100644
--- a/chip/npcx/cec.c
+++ b/chip/npcx/cec.c
@@ -256,7 +256,7 @@ static uint32_t apb1_freq_div_10k;
static void send_mkbp_event(uint32_t event)
{
- deprecated_atomic_or(&cec_events, event);
+ atomic_or(&cec_events, event);
mkbp_send_event(EC_MKBP_EVENT_CEC_EVENT);
}
@@ -963,7 +963,7 @@ DECLARE_HOST_COMMAND(EC_CMD_CEC_GET, hc_cec_get, EC_VER_MASK(0));
static int cec_get_next_event(uint8_t *out)
{
- uint32_t event_out = deprecated_atomic_read_clear(&cec_events);
+ uint32_t event_out = atomic_read_clear(&cec_events);
memcpy(out, &event_out, sizeof(event_out));
diff --git a/chip/stm32/pwm.c b/chip/stm32/pwm.c
index ce9c4ae04b..0b339399c9 100644
--- a/chip/stm32/pwm.c
+++ b/chip/stm32/pwm.c
@@ -99,7 +99,7 @@ static void pwm_configure(enum pwm_channel ch)
/* Enable auto-reload preload, start counting */
tim->cr1 |= BIT(7) | BIT(0);
- deprecated_atomic_or(&using_pwm, 1 << ch);
+ atomic_or(&using_pwm, 1 << ch);
/* Prevent sleep */
disable_sleep(SLEEP_MASK_PWM);
@@ -125,7 +125,7 @@ static void pwm_disable(enum pwm_channel ch)
/* Allow sleep */
enable_sleep(SLEEP_MASK_PWM);
- deprecated_atomic_clear_bits(&using_pwm, 1 << ch);
+ atomic_clear_bits(&using_pwm, 1 << ch);
/* Unless another PWM is active... Then prevent sleep */
if (using_pwm)
@@ -147,7 +147,7 @@ int pwm_get_enabled(enum pwm_channel ch)
static void pwm_reconfigure(enum pwm_channel ch)
{
- deprecated_atomic_clear_bits(&using_pwm, 1 << ch);
+ atomic_clear_bits(&using_pwm, 1 << ch);
pwm_configure(ch);
}
diff --git a/chip/stm32/usart_info_command.c b/chip/stm32/usart_info_command.c
index 16d5e5747e..4e77f12980 100644
--- a/chip/stm32/usart_info_command.c
+++ b/chip/stm32/usart_info_command.c
@@ -24,10 +24,10 @@ static int command_usart_info(int argc, char **argv)
" dropped %d bytes\n"
" overran %d times\n",
config->hw->index + 1,
- deprecated_atomic_read_clear(
- &(config->state->rx_dropped)),
- deprecated_atomic_read_clear(
- &(config->state->rx_overrun)));
+ atomic_read_clear(
+ (uint32_t *)&(config->state->rx_dropped)),
+ atomic_read_clear(
+ (uint32_t *)&(config->state->rx_overrun)));
if (config->rx->info)
config->rx->info(config);
diff --git a/chip/stm32/usart_rx_dma.c b/chip/stm32/usart_rx_dma.c
index 1867c0a310..868425d086 100644
--- a/chip/stm32/usart_rx_dma.c
+++ b/chip/stm32/usart_rx_dma.c
@@ -81,7 +81,7 @@ static void usart_rx_dma_interrupt_common(
/* (new_index == old_index): nothing to add to the queue. */
}
- deprecated_atomic_add(&config->state->rx_dropped, new_bytes - added);
+ atomic_add((uint32_t *)&(config->state->rx_dropped), new_bytes - added);
if (dma_config->state->max_bytes < new_bytes)
dma_config->state->max_bytes = new_bytes;
@@ -115,5 +115,5 @@ void usart_rx_dma_info(struct usart_config const *config)
DOWNCAST(config->rx, struct usart_rx_dma const, usart_rx);
ccprintf(" DMA RX max_bytes %d\n",
- deprecated_atomic_read_clear(&dma_config->state->max_bytes));
+ atomic_read_clear((uint32_t *)&dma_config->state->max_bytes));
}
diff --git a/chip/stm32/usart_rx_interrupt-stm32f4.c b/chip/stm32/usart_rx_interrupt-stm32f4.c
index 44e711327d..198c6dd180 100644
--- a/chip/stm32/usart_rx_interrupt-stm32f4.c
+++ b/chip/stm32/usart_rx_interrupt-stm32f4.c
@@ -33,7 +33,7 @@ static void usart_rx_interrupt_handler(struct usart_config const *config)
uint8_t byte = STM32_USART_RDR(base);
if (!queue_add_unit(config->producer.queue, &byte))
- deprecated_atomic_add(&config->state->rx_dropped, 1);
+ atomic_add((uint32_t *)&(config->state->rx_dropped), 1);
}
}
diff --git a/chip/stm32/usart_rx_interrupt-stm32l.c b/chip/stm32/usart_rx_interrupt-stm32l.c
index c0cd03d8c9..24ca7a0487 100644
--- a/chip/stm32/usart_rx_interrupt-stm32l.c
+++ b/chip/stm32/usart_rx_interrupt-stm32l.c
@@ -39,14 +39,14 @@ static void usart_rx_interrupt_handler(struct usart_config const *config)
if (!(status & STM32_USART_SR_RXNE))
(void)STM32_USART_RDR(config->hw->base);
- deprecated_atomic_add(&config->state->rx_overrun, 1);
+ atomic_add((uint32_t *)&(config->state->rx_overrun), 1);
}
if (status & STM32_USART_SR_RXNE) {
uint8_t byte = STM32_USART_RDR(base);
if (!queue_add_unit(config->producer.queue, &byte))
- deprecated_atomic_add(&config->state->rx_dropped, 1);
+ atomic_add((uint32_t *)&(config->state->rx_dropped), 1);
}
}
diff --git a/chip/stm32/usart_rx_interrupt.c b/chip/stm32/usart_rx_interrupt.c
index 3cbf1f49f4..3bc30d4aaf 100644
--- a/chip/stm32/usart_rx_interrupt.c
+++ b/chip/stm32/usart_rx_interrupt.c
@@ -30,7 +30,7 @@ static void usart_rx_interrupt_handler(struct usart_config const *config)
uint8_t byte = STM32_USART_RDR(base);
if (!queue_add_unit(config->producer.queue, &byte))
- deprecated_atomic_add(&config->state->rx_dropped, 1);
+ atomic_add((uint32_t *)&(config->state->rx_dropped), 1);
}
}
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 1711480d53..f6e1daa8a5 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -517,7 +517,7 @@ void usb_wake(void)
}
/* Only allow one caller at a time. */
- if (!deprecated_atomic_read_clear(&usb_wake_done))
+ if (!atomic_read_clear((int *)&usb_wake_done))
return;
CPRINTF("WAKE\n");
diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c
index c206f9a9c5..f12796257c 100644
--- a/chip/stm32/usb_hid_keyboard.c
+++ b/chip/stm32/usb_hid_keyboard.c
@@ -335,7 +335,7 @@ static void write_keyboard_report(void)
return;
}
- if (deprecated_atomic_read_clear(&hid_ep_data_ready)) {
+ if (atomic_read_clear((int *)&hid_ep_data_ready)) {
/*
* Endpoint is not busy, and interrupt handler did not just
* send the buffer: enable TX.