diff options
| author | Mark Brown <broonie@kernel.org> | 2017-12-04 17:59:52 +0000 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2017-12-04 17:59:52 +0000 |
| commit | d218439feccafaa3e852bbaecc0d9f6110096b65 (patch) | |
| tree | c4ebfeaebd965735cea5d90332d0f8013b79e628 /include/linux/bitops.h | |
| parent | a76d7f5454c688b52dc849e832cc4c6dd0975723 (diff) | |
| parent | fdaa451107ce543d345a339b4d5e20e8e4bac396 (diff) | |
| download | talos-op-linux-d218439feccafaa3e852bbaecc0d9f6110096b65.tar.gz talos-op-linux-d218439feccafaa3e852bbaecc0d9f6110096b65.zip | |
Merge branch 'fix/amd' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-amd
Diffstat (limited to 'include/linux/bitops.h')
| -rw-r--r-- | include/linux/bitops.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 8fbe259b197c..4cac4e1a72ff 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _LINUX_BITOPS_H #define _LINUX_BITOPS_H #include <asm/types.h> @@ -227,6 +228,30 @@ static inline unsigned long __ffs64(u64 word) return __ffs((unsigned long)word); } +/** + * assign_bit - Assign value to a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + * @value: the value to assign + */ +static __always_inline void assign_bit(long nr, volatile unsigned long *addr, + bool value) +{ + if (value) + set_bit(nr, addr); + else + clear_bit(nr, addr); +} + +static __always_inline void __assign_bit(long nr, volatile unsigned long *addr, + bool value) +{ + if (value) + __set_bit(nr, addr); + else + __clear_bit(nr, addr); +} + #ifdef __KERNEL__ #ifndef set_mask_bits @@ -236,7 +261,7 @@ static inline unsigned long __ffs64(u64 word) typeof(*ptr) old, new; \ \ do { \ - old = ACCESS_ONCE(*ptr); \ + old = READ_ONCE(*ptr); \ new = (old & ~mask) | bits; \ } while (cmpxchg(ptr, old, new) != old); \ \ @@ -251,7 +276,7 @@ static inline unsigned long __ffs64(u64 word) typeof(*ptr) old, new; \ \ do { \ - old = ACCESS_ONCE(*ptr); \ + old = READ_ONCE(*ptr); \ new = old & ~clear; \ } while (!(old & test) && \ cmpxchg(ptr, old, new) != old); \ |

