1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Andi Kleen <ak@linux.intel.com>
3 Date: Fri, 13 Oct 2017 14:56:41 -0700
4 Subject: [PATCH] bitops: Add clear/set_bit32() to linux/bitops.h
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Add two simple wrappers around set_bit/clear_bit() that accept
12 the common case of an u32 array. This avoids writing
15 Signed-off-by: Andi Kleen <ak@linux.intel.com>
16 Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
17 Cc: Linus Torvalds <torvalds@linux-foundation.org>
18 Cc: Peter Zijlstra <peterz@infradead.org>
19 Link: http://lkml.kernel.org/r/20171013215645.23166-2-andi@firstfloor.org
20 Signed-off-by: Ingo Molnar <mingo@kernel.org>
21 (cherry picked from commit cbe96375025e14fc76f9ed42ee5225120d7210f8)
22 Signed-off-by: Andy Whitcroft <apw@canonical.com>
23 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
24 (cherry picked from commit 06d31c11519ca0e8f9b7cab857f442ef44dfc1b2)
25 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
27 include/linux/bitops.h | 26 ++++++++++++++++++++++++++
28 1 file changed, 26 insertions(+)
30 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
31 index a83c822c35c2..eb257a96db6d 100644
32 --- a/include/linux/bitops.h
33 +++ b/include/linux/bitops.h
34 @@ -226,6 +226,32 @@ static inline unsigned long __ffs64(u64 word)
35 return __ffs((unsigned long)word);
39 + * clear_bit32 - Clear a bit in memory for u32 array
41 + * @addr: u32 * address of bitmap
43 + * Same as clear_bit, but avoids needing casts for u32 arrays.
46 +static __always_inline void clear_bit32(long nr, volatile u32 *addr)
48 + clear_bit(nr, (volatile unsigned long *)addr);
52 + * set_bit32 - Set a bit in memory for u32 array
54 + * @addr: u32 * address of bitmap
56 + * Same as set_bit, but avoids needing casts for u32 arrays.
59 +static __always_inline void set_bit32(long nr, volatile u32 *addr)
61 + set_bit(nr, (volatile unsigned long *)addr);