summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bitfield.h18
-rw-r--r--include/linux/bitmap-str.h1
-rw-r--r--include/linux/bitrev.h20
-rw-r--r--include/linux/cpumask.h7
-rw-r--r--include/linux/find.h8
5 files changed, 30 insertions, 24 deletions
diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
index 54aeeef1f0ec..14f86e455a67 100644
--- a/include/linux/bitfield.h
+++ b/include/linux/bitfield.h
@@ -44,7 +44,7 @@
* FIELD_MODIFY(REG_FIELD_C, &reg, c);
*/
-#define __bf_shf(x) (__builtin_ffsll(x) - 1)
+#define __bf_shf __builtin_ctzll
#define __scalar_type_to_unsigned_cases(type) \
unsigned type: (unsigned type)0, \
@@ -179,6 +179,22 @@
})
/**
+ * FIELD_GET_SIGNED() - extract a signed bitfield element
+ * @mask: shifted mask defining the field's length and position
+ * @reg: value of entire bitfield
+ *
+ * Returns the sign-extended field specified by @_mask from the
+ * bitfield passed in as @reg by masking and shifting it down.
+ */
+#define FIELD_GET_SIGNED(mask, reg) \
+ ({ \
+ __BF_FIELD_CHECK(mask, reg, 0U, "FIELD_GET_SIGNED: "); \
+ ((__signed_scalar_typeof(mask)) \
+ (((long long)(reg) << __builtin_clzll(mask)) >> \
+ (__builtin_clzll(mask) + __builtin_ctzll(mask)))); \
+ })
+
+/**
* FIELD_MODIFY() - modify a bitfield element
* @_mask: shifted mask defining the field's length and position
* @_reg_p: pointer to the memory that should be updated
diff --git a/include/linux/bitmap-str.h b/include/linux/bitmap-str.h
index 53d3e1b32d3d..abe7a69a846f 100644
--- a/include/linux/bitmap-str.h
+++ b/include/linux/bitmap-str.h
@@ -5,7 +5,6 @@
#include <linux/types.h>
int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, unsigned long *dst, int nbits);
-int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, int nmaskbits);
int bitmap_print_bitmask_to_buf(char *buf, const unsigned long *maskp, int nmaskbits,
loff_t off, size_t count);
int bitmap_print_list_to_buf(char *buf, const unsigned long *maskp, int nmaskbits,
diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
index d35b8ec1c485..11620a70e776 100644
--- a/include/linux/bitrev.h
+++ b/include/linux/bitrev.h
@@ -12,22 +12,10 @@
#define __bitrev8 __arch_bitrev8
#else
-extern u8 const byte_rev_table[256];
-static inline u8 __bitrev8(u8 byte)
-{
- return byte_rev_table[byte];
-}
-
-static inline u16 __bitrev16(u16 x)
-{
- return (__bitrev8(x & 0xff) << 8) | __bitrev8(x >> 8);
-}
-
-static inline u32 __bitrev32(u32 x)
-{
- return (__bitrev16(x & 0xffff) << 16) | __bitrev16(x >> 16);
-}
-
+#include <asm-generic/bitops/__bitrev.h>
+#define __bitrev32 generic___bitrev32
+#define __bitrev16 generic___bitrev16
+#define __bitrev8 generic___bitrev8
#endif /* CONFIG_HAVE_ARCH_BITREVERSE */
#define __bitrev8x4(x) (__bitrev32(swab32(x)))
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 80211900f373..d3cda0544954 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -13,8 +13,10 @@
#include <linux/cpumask_types.h>
#include <linux/gfp_types.h>
#include <linux/numa.h>
+#include <linux/sprintf.h>
#include <linux/threads.h>
#include <linux/types.h>
+#include <vdso/page.h>
#include <asm/bug.h>
@@ -1326,8 +1328,9 @@ static __always_inline bool cpu_dying(unsigned int cpu)
static __always_inline ssize_t
cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
{
- return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask),
- nr_cpu_ids);
+ /* Opencode offset_in_page(buf) to not include linux/mm.h */
+ return scnprintf(buf, PAGE_SIZE - ((unsigned long)buf & ~PAGE_MASK),
+ list ? "%*pbl\n" : "%*pb\n", cpumask_pr_args(mask));
}
/**
diff --git a/include/linux/find.h b/include/linux/find.h
index 6c2be8ca615d..a129f8205fb6 100644
--- a/include/linux/find.h
+++ b/include/linux/find.h
@@ -249,7 +249,7 @@ unsigned long find_nth_bit(const unsigned long *addr, unsigned long size, unsign
* @n: The number of set bit, which position is needed, counting from 0
*
* Returns the bit number of the N'th set bit.
- * If no such, returns @size.
+ * If no such, returns >= @size.
*/
static __always_inline
unsigned long find_nth_and_bit(const unsigned long *addr1, const unsigned long *addr2,
@@ -277,7 +277,7 @@ unsigned long find_nth_and_bit(const unsigned long *addr1, const unsigned long *
* @n: The number of set bit, which position is needed, counting from 0
*
* Returns the bit number of the N'th set bit.
- * If no such, returns @size.
+ * If no such, returns >= @size.
*/
static __always_inline
unsigned long find_nth_and_andnot_bit(const unsigned long *addr1,
@@ -655,8 +655,8 @@ unsigned long find_next_bit_le(const void *addr, unsigned
/**
* for_each_clear_bitrange_from - iterate over all unset bit ranges [b; e)
- * @b: bit offset of start of current bitrange (first set bit); must be initialized
- * @e: bit offset of end of current bitrange (first unset bit)
+ * @b: bit offset of start of current bitrange (first unset bit); must be initialized
+ * @e: bit offset of end of current bitrange (first set bit)
* @addr: bitmap address to base the search on
* @size: bitmap size in number of bits
*/