Skip to content

Commit 9f2c2d6

Browse files
andy-shevYuryNorov
authored andcommitted
bitops: Move aligned_byte_mask() to wordpart.h
The bitops.h is for bit related operations. The aligned_byte_mask() is about byte (or part of the machine word) operations, for which we have a separate header, move the mentioned macro to wordpart.h to consolidate similar operations. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Yury Norov <yury.norov@gmail.com>
1 parent fe708f9 commit 9f2c2d6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

include/linux/bitops.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
#include <uapi/linux/kernel.h>
1010

11-
/* Set bits in the first 'n' bytes when loaded from memory */
12-
#ifdef __LITTLE_ENDIAN
13-
# define aligned_byte_mask(n) ((1UL << 8*(n))-1)
14-
#else
15-
# define aligned_byte_mask(n) (~0xffUL << (BITS_PER_LONG - 8 - 8*(n)))
16-
#endif
17-
1811
#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
1912
#define BITS_TO_LONGS(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
2013
#define BITS_TO_U64(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))

include/linux/wordpart.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@
3939
*/
4040
#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
4141

42+
/* Set bits in the first 'n' bytes when loaded from memory */
43+
#ifdef __LITTLE_ENDIAN
44+
# define aligned_byte_mask(n) ((1UL << 8*(n))-1)
45+
#else
46+
# define aligned_byte_mask(n) (~0xffUL << (BITS_PER_LONG - 8 - 8*(n)))
47+
#endif
48+
4249
#endif // _LINUX_WORDPART_H

lib/usercopy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/fault-inject-usercopy.h>
44
#include <linux/instrumented.h>
55
#include <linux/uaccess.h>
6+
#include <linux/wordpart.h>
67
#include <linux/nospec.h>
78

89
/* out-of-line parts */

0 commit comments

Comments
 (0)