[v1,7/8] linux/kernel.h: move VERIFY_OCTAL_PERMISSIONS() to octal_permissions.h
Commit Message
Reducing dependencies on the header linux/kernel.h.
Signed-off-by: Max Kellermann <max.kellermann@ionos.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 | 1 +
10 files changed, 28 insertions(+), 14 deletions(-)
create mode 100644 include/linux/octal_permissions.h
@@ -8,6 +8,7 @@
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/module.h>
+#include <linux/octal_permissions.h>
#include <linux/of.h>
#include <linux/perf_event.h>
#include <linux/platform_device.h>
@@ -20,6 +20,7 @@
#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/circ_buf.h>
+#include <linux/octal_permissions.h>
#include <asm/page.h>
@@ -10,6 +10,7 @@
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/octal_permissions.h>
#include <linux/property.h>
#include <linux/sysfs.h>
#include <asm/unaligned.h>
@@ -9,6 +9,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/kernel.h>
+#include <linux/octal_permissions.h>
#include <linux/types.h>
#include <linux/pm_runtime.h>
#include <media/v4l2-device.h>
@@ -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>
@@ -14,6 +14,7 @@
#include "xfs_error.h"
#include "xfs_sysfs.h"
#include "xfs_inode.h"
+#include <linux/octal_permissions.h>
#ifdef DEBUG
@@ -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>
@@ -285,16 +284,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
@@ -4,7 +4,7 @@
/* (C) Copyright 2001, 2002 Rusty Russell IBM Corporation */
#include <linux/init.h>
#include <linux/stringify.h>
-#include <linux/kernel.h>
+#include <linux/octal_permissions.h>
/* You can override this manually, but generally this should match the
module name. */
new file mode 100644
@@ -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
@@ -21,6 +21,7 @@
#include <linux/kobject_ns.h>
#include <linux/stat.h>
#include <linux/atomic.h>
+#include <linux/octal_permissions.h>
struct kobject;
struct module;