Skip to contentSkip to conversation

powerpc: add setmaskedbits macros

PATCH Superseded Timur Tabi 2 participants 2 messages Aug 15, 2007

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH 1/1 powerpc: add setmaskedbits macros

This patch adds the setmaskedbits_xxx() macros, which are used to set a multiple-bit bit pattern in a register. The macros include a mask, which zeros the respective bits before applying the value via a bitwise-OR. There are big-endian and little-endian versions for 8, 16, 32, and 64 bits.

---

Fixed the changelog.

 include/asm-powerpc/io.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
include/asm-powerpc/io.h +13 -0
index bb8d965..ac3defb 100644
@@ -734,6 +734,19 @@ 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))
 
+#ifdef __powerpc64__
+#define setmaskedbits_be64(a, v, m) out_be64((a), (in_be64(a) & ~(m)) | (v))
+#define setmaskedbits_le64(a, v, m) out_le64((a), (in_le64(a) & ~(m)) | (v))
+#endif
+
+#define setmaskedbits_be32(a, v, m) out_be32((a), (in_be32(a) & ~(m)) | (v))
+#define setmaskedbits_be16(a, v, m) out_be16((a), (in_be16(a) & ~(m)) | (v))
+
+#define setmaskedbits_le32(a, v, m) out_le32((a), (in_le32(a) & ~(m)) | (v))
+#define setmaskedbits_le16(a, v, m) out_le16((a), (in_le16(a) & ~(m)) | (v))
+
+#define setmaskedbits_8(a, v, m) out_8((a), (in_8(a) & ~(m)) | (v))
+
 #endif /* __KERNEL__ */
 
 #endif /* _ASM_POWERPC_IO_H */
Signature · 1 line
1.5.2.4
#1 lore raw
Quoted 4 lines · Timur Tabi

This patch adds the setmaskedbits_xxx() macros, which are used to set a multiple-bit bit pattern in a register. The macros include a mask, which zeros the respective bits before applying the value via a bitwise-OR. There are big-endian and little-endian versions for 8, 16, 32, and 64 bits.

Why do we want these? (Don't tell me, put it in the commit log. :)

Paul.