From: Timur Tabi <timur@freescale.com>
To: linuxppc-dev@ozlabs.org, Geert.Uytterhoeven@sonycom.com,
michael@ellerman.id.au, paulus@samba.org,
galak@kernel.crashing.org, benh@kernel.crashing.org
Cc: Timur Tabi <timur@freescale.com>
Subject: [PATCH] powerpc: add clrsetbits macros
Date: Fri, 17 Aug 2007 11:33:07 -0500 [thread overview]
Message-ID: <1187368387816-git-send-email-timur@freescale.com> (raw)
This patch adds the clrsetbits_xxx() macros, which are used to set and clear
multiple bits in a single read-modify-write operation. Specify the bits to
clear in the 'clear' parameter and the bits to set in the 'set' parameter.
These macros can also be used to set a multiple-bit bit pattern using a mask,
by specifying the mask in the 'clear' parameter and the new bit pattern in the
'set' parameter. There are big-endian and little-endian versions for 8, 16,
32, and 64 bits.
Signed-off-by: Timur Tabi <timur@freescale.com>
---
Renamed setclrbits to clrsetbits, since the clear is done first.
This patch is for for-2.6.24, assuming I can get everyone to like it.
include/asm-powerpc/io.h | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index bb8d965..0af2f7e 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -734,6 +734,33 @@ static inline void * bus_to_virt(unsigned long address)
#define setbits16(_addr, _v) out_be16((_addr), in_be16(_addr) | (_v))
#define clrbits16(_addr, _v) out_be16((_addr), in_be16(_addr) & ~(_v))
+/* Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single read-modify-write. These
+ * macros can also be used to set a multiple-bit bit pattern using a mask,
+ * by specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#ifdef __powerpc64__
+#define clrsetbits_be64(addr, clear, set) \
+ out_be64((addr), (in_be64(addr) & ~(clear)) | (set))
+#define clrsetbits_le64(addr, clear, set) \
+ out_le64((addr), (in_le64(addr) & ~(clear)) | (set))
+#endif
+
+#define clrsetbits_be32(addr, clear, set) \
+ out_be32((addr), (in_be32(addr) & ~(clear)) | (set))
+#define clrsetbits_be16(addr, clear, set) \
+ out_be16((addr), (in_be16(addr) & ~(clear)) | (set))
+
+#define clrsetbits_le32(addr, clear, set) \
+ out_le32((addr), (in_le32(addr) & ~(clear)) | (set))
+#define clrsetbits_le16(addr, clear, set) \
+ out_le16((addr), (in_le16(addr) & ~(clear)) | (set))
+
+#define clrsetbits_8(addr, clear, set) \
+ out_8((addr), (in_8(addr) & ~(clear)) | (set))
+
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_IO_H */
--
1.5.2.4
reply other threads:[~2007-08-17 16:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1187368387816-git-send-email-timur@freescale.com \
--to=timur@freescale.com \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=benh@kernel.crashing.org \
--cc=galak@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=michael@ellerman.id.au \
--cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).