diff options
author | Ting Shen <phoenixshen@google.com> | 2021-07-28 16:43:43 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-07-29 06:16:14 +0000 |
commit | afd9875ab56f4172d3d7fc7ec430ddf9afdc8176 (patch) | |
tree | e4ad76c4f1f766f50aba8edbac6fd0292fb7bcf9 /core | |
parent | 48cbee405bc950a7ec4950213a3d29e918e355e8 (diff) | |
download | chrome-ec-afd9875ab56f4172d3d7fc7ec430ddf9afdc8176.tar.gz |
atomic.h: atomic_clear_bits: return previously stored value
make the api consistent with other atomic methods
BUG=b:192422592
TEST=make
BRANCH=main
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I6cae4d521b44706cf7f44c669bf6964a08855b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3058080
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/atomic.h | 4 | ||||
-rw-r--r-- | core/cortex-m0/atomic.h | 4 | ||||
-rw-r--r-- | core/host/atomic.h | 4 | ||||
-rw-r--r-- | core/minute-ia/atomic.h | 4 | ||||
-rw-r--r-- | core/nds32/atomic.h | 5 | ||||
-rw-r--r-- | core/riscv-rv32i/atomic.h | 4 |
6 files changed, 14 insertions, 11 deletions
diff --git a/core/cortex-m/atomic.h b/core/cortex-m/atomic.h index 4446fb989c..e9b96f6fd5 100644 --- a/core/cortex-m/atomic.h +++ b/core/cortex-m/atomic.h @@ -13,9 +13,9 @@ typedef int atomic_t; typedef atomic_t atomic_val_t; -static inline void atomic_clear_bits(atomic_t *addr, atomic_val_t bits) +static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits) { - __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); + return __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); } static inline atomic_val_t atomic_or(atomic_t *addr, atomic_val_t bits) diff --git a/core/cortex-m0/atomic.h b/core/cortex-m0/atomic.h index e969f01de1..0c58e71e41 100644 --- a/core/cortex-m0/atomic.h +++ b/core/cortex-m0/atomic.h @@ -34,9 +34,9 @@ typedef atomic_t atomic_val_t; reg1; \ }) -static inline void atomic_clear_bits(atomic_t *addr, atomic_val_t bits) +static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits) { - ATOMIC_OP(bic, addr, bits); + return ATOMIC_OP(bic, addr, bits); } static inline atomic_val_t atomic_or(atomic_t *addr, atomic_val_t bits) diff --git a/core/host/atomic.h b/core/host/atomic.h index 1513823b6f..83786de904 100644 --- a/core/host/atomic.h +++ b/core/host/atomic.h @@ -13,9 +13,9 @@ typedef int atomic_t; typedef atomic_t atomic_val_t; -static inline void atomic_clear_bits(atomic_t *addr, atomic_val_t bits) +static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits) { - __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); + return __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); } static inline atomic_val_t atomic_or(atomic_t *addr, atomic_val_t bits) diff --git a/core/minute-ia/atomic.h b/core/minute-ia/atomic.h index 225bf0329d..37a4454902 100644 --- a/core/minute-ia/atomic.h +++ b/core/minute-ia/atomic.h @@ -37,9 +37,9 @@ static inline atomic_val_t atomic_and_u8(uint8_t *addr, uint8_t bits) return __atomic_fetch_and(addr, bits, __ATOMIC_SEQ_CST); } -static inline void atomic_clear_bits(atomic_t *addr, atomic_val_t bits) +static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits) { - __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); + return __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); } static inline atomic_val_t atomic_or(atomic_t *addr, atomic_val_t bits) diff --git a/core/nds32/atomic.h b/core/nds32/atomic.h index 00df72cbcb..b634c3a551 100644 --- a/core/nds32/atomic.h +++ b/core/nds32/atomic.h @@ -15,13 +15,16 @@ typedef int atomic_t; typedef atomic_t atomic_val_t; -static inline void atomic_clear_bits(atomic_t *addr, atomic_val_t bits) +static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits) { + atomic_val_t ret; atomic_t volatile *ptr = addr; uint32_t int_mask = read_clear_int_mask(); + ret = *ptr; *ptr &= ~bits; set_int_mask(int_mask); + return ret; } static inline atomic_val_t atomic_or(atomic_t *addr, atomic_val_t bits) diff --git a/core/riscv-rv32i/atomic.h b/core/riscv-rv32i/atomic.h index a4e9db66ed..e92beb2ca0 100644 --- a/core/riscv-rv32i/atomic.h +++ b/core/riscv-rv32i/atomic.h @@ -15,9 +15,9 @@ typedef int atomic_t; typedef atomic_t atomic_val_t; -static inline void atomic_clear_bits(atomic_t *addr, atomic_val_t bits) +static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits) { - __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); + return __atomic_fetch_and(addr, ~bits, __ATOMIC_SEQ_CST); } static inline atomic_val_t atomic_or(atomic_t *addr, atomic_val_t bits) |