[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240211123000.3359365-33-max.kellermann@ionos.com>
Date: Sun, 11 Feb 2024 13:29:57 +0100
From: Max Kellermann <max.kellermann@...os.com>
To: linux-kernel@...r.kernel.org
Cc: Max Kellermann <max.kellermann@...os.com>
Subject: [PATCH v3 32/35] linux/kernel.h: move VERIFY_OCTAL_PERMISSIONS() to octal_permissions.h
Reducing dependencies on the header linux/kernel.h.
Signed-off-by: Max Kellermann <max.kellermann@...os.com>
---
arch/arc/kernel/perf_event.c | 1 +
drivers/edac/thunderx_edac.c | 1 +
drivers/hwmon/occ/common.c | 1 +
drivers/media/platform/amphion/vpu_dbg.c | 1 +
drivers/soc/aspeed/aspeed-uart-routing.c | 1 +
fs/xfs/xfs_error.c | 1 +
include/linux/kernel.h | 13 -------------
include/linux/moduleparam.h | 2 +-
include/linux/octal_permissions.h | 20 ++++++++++++++++++++
include/linux/sysfs.h | 2 +-
10 files changed, 28 insertions(+), 15 deletions(-)
create mode 100644 include/linux/octal_permissions.h
diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
index 9d43a9988812..dbc24c9351d1 100644
--- a/arch/arc/kernel/perf_event.c
+++ b/arch/arc/kernel/perf_event.c
@@ -9,6 +9,7 @@
#include <linux/interrupt.h>
#include <linux/kernel.h> // for upper_32_bits(), lower_32_bits()
#include <linux/module.h>
+#include <linux/octal_permissions.h>
#include <linux/of.h>
#include <linux/perf_event.h>
#include <linux/platform_device.h>
diff --git a/drivers/edac/thunderx_edac.c b/drivers/edac/thunderx_edac.c
index e99ce19e6574..c610d99dceda 100644
--- a/drivers/edac/thunderx_edac.c
+++ b/drivers/edac/thunderx_edac.c
@@ -21,6 +21,7 @@
#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/circ_buf.h>
+#include <linux/octal_permissions.h>
#include <asm/page.h>
diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index f7b89b880339..1a4f1a90c2c5 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -11,6 +11,7 @@
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/octal_permissions.h>
#include <linux/property.h>
#include <linux/sprintf.h>
#include <linux/sysfs.h>
diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platform/amphion/vpu_dbg.c
index bed0ed4fb8a0..ef5658b492cf 100644
--- a/drivers/media/platform/amphion/vpu_dbg.c
+++ b/drivers/media/platform/amphion/vpu_dbg.c
@@ -9,6 +9,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/kernel.h>
+#include <linux/octal_permissions.h>
#include <linux/sprintf.h>
#include <linux/types.h>
#include <linux/pm_runtime.h>
diff --git a/drivers/soc/aspeed/aspeed-uart-routing.c b/drivers/soc/aspeed/aspeed-uart-routing.c
index a2195f062e01..6b091df7775a 100644
--- a/drivers/soc/aspeed/aspeed-uart-routing.c
+++ b/drivers/soc/aspeed/aspeed-uart-routing.c
@@ -5,6 +5,7 @@
*/
#include <linux/device.h>
#include <linux/module.h>
+#include <linux/octal_permissions.h>
#include <linux/of.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 8d558f0f1b3b..a225860d272a 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -14,6 +14,7 @@
#include "xfs_error.h"
#include "xfs_sysfs.h"
#include "xfs_inode.h"
+#include <linux/octal_permissions.h>
#include <linux/kstrtox.h>
#include <linux/sprintf.h>
#include <linux/sysfs.h>
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 5d088ce30045..ac332f4deed9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -29,7 +29,6 @@
#include <linux/typecheck.h>
#include <linux/panic.h>
#include <linux/printk.h>
-#include <linux/build_bug.h>
#include <linux/sprintf.h>
#include <linux/static_call_types.h>
#include <linux/instruction_pointer.h>
@@ -308,16 +307,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
#endif
-/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
-#define VERIFY_OCTAL_PERMISSIONS(perms) \
- (BUILD_BUG_ON_ZERO((perms) < 0) + \
- BUILD_BUG_ON_ZERO((perms) > 0777) + \
- /* USER_READABLE >= GROUP_READABLE >= OTHER_READABLE */ \
- BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \
- BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \
- /* USER_WRITABLE >= GROUP_WRITABLE */ \
- BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \
- /* OTHER_WRITABLE? Generally considered a bad idea. */ \
- BUILD_BUG_ON_ZERO((perms) & 2) + \
- (perms))
#endif
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index a285e74ec028..860b0ea1f3b3 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -4,7 +4,7 @@
/* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
#include <linux/init.h>
#include <linux/stringify.h>
-#include <linux/kernel.h> // for VERIFY_OCTAL_PERMISSIONS()
+#include <linux/octal_permissions.h>
/* You can override this manually, but generally this should match the
module name. */
diff --git a/include/linux/octal_permissions.h b/include/linux/octal_permissions.h
new file mode 100644
index 000000000000..57d4d6a5b66d
--- /dev/null
+++ b/include/linux/octal_permissions.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_OCTAL_PERMISSIONS_H
+#define _LINUX_OCTAL_PERMISSIONS_H
+
+#include <linux/build_bug.h>
+
+/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */
+#define VERIFY_OCTAL_PERMISSIONS(perms) \
+ (BUILD_BUG_ON_ZERO((perms) < 0) + \
+ BUILD_BUG_ON_ZERO((perms) > 0777) + \
+ /* USER_READABLE >= GROUP_READABLE >= OTHER_READABLE */ \
+ BUILD_BUG_ON_ZERO((((perms) >> 6) & 4) < (((perms) >> 3) & 4)) + \
+ BUILD_BUG_ON_ZERO((((perms) >> 3) & 4) < ((perms) & 4)) + \
+ /* USER_WRITABLE >= GROUP_WRITABLE */ \
+ BUILD_BUG_ON_ZERO((((perms) >> 6) & 2) < (((perms) >> 3) & 2)) + \
+ /* OTHER_WRITABLE? Generally considered a bad idea. */ \
+ BUILD_BUG_ON_ZERO((perms) & 2) + \
+ (perms))
+
+#endif
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 0500b023b5cc..a4b752b24329 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -15,10 +15,10 @@
#include <linux/sysfs_types.h>
#include <linux/kernfs.h>
-#include <linux/kernel.h> // for VERIFY_OCTAL_PERMISSIONS()
#include <linux/compiler.h>
#include <linux/list.h>
#include <linux/lockdep_types.h>
+#include <linux/octal_permissions.h>
struct kobject;
struct module;
--
2.39.2
Powered by blists - more mailing lists