[PATCH v3 4/4] kernel.h: Move lower_32_bits()/upper_32_bits() to bitops.h

From: Andy Shevchenko
Date: Thu Feb 06 2020 - 11:39:48 EST


Move lower_32_bits()/upper_32_bits() to bitops.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
v3: new patch
include/linux/bitops.h | 16 ++++++++++++++++
include/linux/kernel.h | 16 ----------------
lib/clz_ctz.c | 2 +-
lib/lz4/lz4defs.h | 1 +
lib/math/gcd.c | 2 ++
5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 21696ea359d1..bcd91b2f0d89 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -20,6 +20,22 @@
#define BITS_TO_U32(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32))
#define BITS_TO_BYTES(nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char))

+/**
+ * upper_32_bits - return bits 32-63 of a number
+ * @n: the number we're accessing
+ *
+ * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
+ * the "right shift count >= width of type" warning when that quantity is
+ * 32-bits.
+ */
+#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
+
+/**
+ * lower_32_bits - return bits 0-31 of a number
+ * @n: the number we're accessing
+ */
+#define lower_32_bits(n) ((u32)(n))
+
extern unsigned int __sw_hweight8(unsigned int w);
extern unsigned int __sw_hweight16(unsigned int w);
extern unsigned int __sw_hweight32(unsigned int w);
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d9ce634457cb..7c443bb779fb 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -60,22 +60,6 @@
#define _RET_IP_ (unsigned long)__builtin_return_address(0)
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })

-/**
- * upper_32_bits - return bits 32-63 of a number
- * @n: the number we're accessing
- *
- * A basic shift-right of a 64- or 32-bit quantity. Use this to suppress
- * the "right shift count >= width of type" warning when that quantity is
- * 32-bits.
- */
-#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
-
-/**
- * lower_32_bits - return bits 0-31 of a number
- * @n: the number we're accessing
- */
-#define lower_32_bits(n) ((u32)(n))
-
struct completion;
struct pt_regs;

diff --git a/lib/clz_ctz.c b/lib/clz_ctz.c
index 0d3a686b5ba2..28bb53f6cea3 100644
--- a/lib/clz_ctz.c
+++ b/lib/clz_ctz.c
@@ -11,8 +11,8 @@
* __c[lt]z[sd]i2 can be overridden by linking arch-specific versions.
*/

+#include <linux/bitops.h>
#include <linux/export.h>
-#include <linux/kernel.h>

int __weak __ctzsi2(int val);
int __weak __ctzsi2(int val)
diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
index 1a7fa9d9170f..c468eab7f3c6 100644
--- a/lib/lz4/lz4defs.h
+++ b/lib/lz4/lz4defs.h
@@ -36,6 +36,7 @@
*/

#include <asm/unaligned.h>
+#include <linux/bitops.h>
#include <linux/string.h> /* memset, memcpy */

#define FORCE_INLINE __always_inline
diff --git a/lib/math/gcd.c b/lib/math/gcd.c
index e3b042214d1b..6cd0d5b2aef7 100644
--- a/lib/math/gcd.c
+++ b/lib/math/gcd.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/bitops.h>
#include <linux/kernel.h>
#include <linux/gcd.h>
#include <linux/export.h>
--
2.24.1