Skip to content

Commit 08c5188

Browse files
andy-shevtorvalds
authored andcommitted
kernel.h: drop inclusion in bitmap.h
The bitmap.h header is used in a lot of code around the kernel. Besides that it includes kernel.h which sometimes makes a loop. The problem here is many unneeded loops that make header hell dependencies. For example, how may you move bitmap_zalloc() from C-file to the header? Currently it's impossible. And bitmap.h here is only the tip of an iceberg. kerne.h is a dump of everything that even has nothing in common at all. We may still have it, but in my new code I prefer to include only the headers that I want to use, without the bulk of unneeded kernel code. Break the loop by introducing align.h, including it in kernel.h and bitmap.h followed by replacing kernel.h with limits.h. Link: https://lkml.kernel.org/r/20210326170347.37441-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Yury Norov <yury.norov@gmail.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4ee60ec commit 08c5188

3 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎include/linux/align.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _LINUX_ALIGN_H
3+
#define _LINUX_ALIGN_H
4+
5+
#include <linux/const.h>
6+
7+
/* @a is a power of 2 value */
8+
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
9+
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
10+
#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
11+
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
12+
#define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
13+
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
14+
15+
#endif /* _LINUX_ALIGN_H */

‎include/linux/bitmap.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
#ifndef __ASSEMBLY__
66

7+
#include <linux/align.h>
78
#include <linux/types.h>
89
#include <linux/bitops.h>
10+
#include <linux/limits.h>
911
#include <linux/string.h>
10-
#include <linux/kernel.h>
1112

1213
/*
1314
* bitmaps provide bit arrays that consume one or more unsigned

‎include/linux/kernel.h‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _LINUX_KERNEL_H
44

55
#include <stdarg.h>
6+
#include <linux/align.h>
67
#include <linux/limits.h>
78
#include <linux/linkage.h>
89
#include <linux/stddef.h>
@@ -30,14 +31,6 @@
3031
*/
3132
#define REPEAT_BYTE(x) ((~0ul / 0xff) * (x))
3233

33-
/* @a is a power of 2 value */
34-
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
35-
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
36-
#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
37-
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
38-
#define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
39-
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
40-
4134
/* generic data direction definitions */
4235
#define READ 0
4336
#define WRITE 1

0 commit comments

Comments
 (0)