From: Andi Kleen <andi@firstfloor.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v10 1/5] bitops: Add clear/set_bit32 to linux/bitops.h
Date: Fri, 13 Oct 2017 14:56:41 -0700 [thread overview]
Message-ID: <20171013215645.23166-2-andi@firstfloor.org> (raw)
In-Reply-To: <20171013215645.23166-1-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
Add two simple wrappers around set_bit/clear_bit that accept
the common case of an u32 array. This avoids writing
casts in all callers.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
include/linux/bitops.h | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 8fbe259b197c..36794f058ba6 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -227,6 +227,32 @@ static inline unsigned long __ffs64(u64 word)
return __ffs((unsigned long)word);
}
+/*
+ * clear_bit32 - Clear a bit in memory for u32 array
+ * @nr: Bit to clear
+ * @addr: u32 * address of bitmap
+ *
+ * Same as clear_bit, but avoids needing casts for u32 arrays.
+ */
+
+static __always_inline void clear_bit32(long nr, volatile u32 *addr)
+{
+ clear_bit(nr, (volatile unsigned long *)addr);
+}
+
+/*
+ * set_bit32 - Set a bit in memory for u32 array
+ * @nr: Bit to clear
+ * @addr: u32 * address of bitmap
+ *
+ * Same as set_bit, but avoids needing casts for u32 arrays.
+ */
+
+static __always_inline void set_bit32(long nr, volatile u32 *addr)
+{
+ set_bit(nr, (volatile unsigned long *)addr);
+}
+
#ifdef __KERNEL__
#ifndef set_mask_bits
--
2.13.6
next prev parent reply other threads:[~2017-10-13 21:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 21:56 Support generic disabling of all XSAVE features Andi Kleen
2017-10-13 21:56 ` Andi Kleen [this message]
2017-10-17 15:14 ` [PATCH v10 1/5] bitops: Add clear/set_bit32 to linux/bitops.h Thomas Gleixner
2017-10-17 16:21 ` [tip:x86/fpu] bitops: Add clear/set_bit32() " tip-bot for Andi Kleen
2017-11-05 15:53 ` Heiko Carstens
2017-11-05 17:40 ` Ingo Molnar
2017-11-05 18:01 ` Linus Torvalds
2017-10-13 21:56 ` [PATCH v10 2/5] x86/cpuid: Add generic table for cpuid dependencies Andi Kleen
2017-10-17 16:22 ` [tip:x86/fpu] x86/cpuid: Add generic table for CPUID dependencies tip-bot for Andi Kleen
2017-10-13 21:56 ` [PATCH v10 3/5] x86/fpu: Parse clearcpuid= as early XSAVE argument Andi Kleen
2017-10-17 15:15 ` Thomas Gleixner
2017-10-17 15:19 ` Ingo Molnar
2017-10-17 16:22 ` [tip:x86/fpu] " tip-bot for Andi Kleen
2017-10-13 21:56 ` [PATCH v10 4/5] x86/fpu: Make XSAVE check the base CPUID features before enabling Andi Kleen
2017-10-17 16:23 ` [tip:x86/fpu] " tip-bot for Andi Kleen
2017-10-13 21:56 ` [PATCH v10 5/5] x86/fpu: Remove the explicit clearing of XSAVE dependend features Andi Kleen
2017-10-17 16:23 ` [tip:x86/fpu] x86/fpu: Remove the explicit clearing of XSAVE dependent features tip-bot for Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171013215645.23166-2-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox