[PATCH master 04/23] include: linux/kernel.h: factor out alignment macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linux has already factored these macros into a separate <linux/align.h>.
We now do the same for barebox to avoid a recursive dependency in
incoming patches via linux/pagemap.h, which just needs the align macros
and nothing else out of linux/kernel.h.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 include/linux/align.h   | 13 +++++++++++++
 include/linux/kernel.h  |  9 +--------
 include/linux/pagemap.h |  2 +-
 3 files changed, 15 insertions(+), 9 deletions(-)
 create mode 100644 include/linux/align.h

diff --git a/include/linux/align.h b/include/linux/align.h
new file mode 100644
index 000000000000..8df1b3dcd749
--- /dev/null
+++ b/include/linux/align.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_ALIGN_H
+#define _LINUX_ALIGN_H
+
+#define ALIGN(x, a)		__ALIGN_MASK(x, (typeof(x))(a) - 1)
+#define ALIGN_DOWN(x, a)	ALIGN((x) - ((a) - 1), (a))
+#define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
+#define PTR_ALIGN(p, a)		((typeof(p))ALIGN((unsigned long)(p), (a)))
+#define PTR_ALIGN_DOWN(p, a)	((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
+#define PTR_IS_ALIGNED(x, a)	IS_ALIGNED((unsigned long)(x), (a))
+#define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
+
+#endif
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4e50f6075189..c411ac0860dd 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -10,6 +10,7 @@
 #include <linux/container_of.h>
 #include <linux/instruction_pointer.h>
 #include <linux/minmax.h>
+#include <linux/align.h>
 
 /**
  * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value
@@ -19,14 +20,6 @@
  */
 #define REPEAT_BYTE(x)	((~0ul / 0xff) * (x))
 
-#define ALIGN(x, a)		__ALIGN_MASK(x, (typeof(x))(a) - 1)
-#define ALIGN_DOWN(x, a)	ALIGN((x) - ((a) - 1), (a))
-#define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
-#define PTR_ALIGN(p, a)		((typeof(p))ALIGN((unsigned long)(p), (a)))
-#define PTR_ALIGN_DOWN(p, a)	((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
-#define PTR_IS_ALIGNED(x, a)	IS_ALIGNED((unsigned long)(x), (a))
-#define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
-
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 #define ARRAY_AND_SIZE(x)	(x), ARRAY_SIZE(x)
 
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 0db192e4d3ab..8bdaff4ebf1b 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -3,7 +3,7 @@
 #ifndef _LINUX_PAGEMAP_H
 #define _LINUX_PAGEMAP_H
 
-#include <linux/kernel.h>
+#include <linux/align.h>
 
 /*
  * Copyright 1995 Linus Torvalds
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux