]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kernel.h: move VERIFY_OCTAL_PERMISSIONS() to sysfs.h
authorYury Norov <ynorov@nvidia.com>
Fri, 16 Jan 2026 04:25:06 +0000 (23:25 -0500)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 1 Feb 2026 00:16:05 +0000 (16:16 -0800)
The macro is related to sysfs, but is defined in kernel.h.  Move it to the
proper header, and unload the generic kernel.h.

Now that the macro is removed from kernel.h, linux/moduleparam.h is
decoupled, and kernel.h inclusion can be removed.

Link: https://lkml.kernel.org/r/20260116042510.241009-4-ynorov@nvidia.com
Signed-off-by: Yury Norov <ynorov@nvidia.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/filesystems/sysfs.rst
include/linux/kernel.h
include/linux/moduleparam.h
include/linux/sysfs.h

index 2703c04af7d070f83d49ec27bdbb80137e59cd28..ffcef4d6bc8d793fa702e22aaf8c05cdb2755753 100644 (file)
@@ -120,7 +120,7 @@ is equivalent to doing::
            .store = store_foo,
     };
 
-Note as stated in include/linux/kernel.h "OTHER_WRITABLE?  Generally
+Note as stated in include/linux/sysfs.h "OTHER_WRITABLE?  Generally
 considered a bad idea." so trying to set a sysfs file writable for
 everyone will fail reverting to RO mode for "Others".
 
index cefe733a0c10e36015f7d5ee5d98f8bd9e8da369..09850b26061ce9ad3cf6939ba9d85412c0039fa7 100644 (file)
@@ -388,16 +388,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
 # define REBUILD_DUE_TO_DYNAMIC_FTRACE
 #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
index 03a977168c52d35bce26ae686710cfac22e6b080..281a006dc284673b1d5e0e44baad917f79b00135 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/compiler.h>
 #include <linux/init.h>
 #include <linux/stringify.h>
-#include <linux/kernel.h>
+#include <linux/sysfs.h>
 #include <linux/types.h>
 
 /*
index c33a96b7391a244a3f2edcee999a2e2ee8a165a7..99b775f3ff469f0ffb56b03f2e20ecde095eafc2 100644 (file)
@@ -808,4 +808,17 @@ static inline void sysfs_put(struct kernfs_node *kn)
        kernfs_put(kn);
 }
 
+/* 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 /* _SYSFS_H_ */