header: debugfs.h: add DEFINE_DEBUGFS_ATTRIBUTE
authorHauke Mehrtens <hauke@hauke-m.de>
Sun, 4 Mar 2018 22:57:10 +0000 (23:57 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 21 Mar 2018 08:19:32 +0000 (09:19 +0100)
DEFINE_DEBUGFS_ATTRIBUTE and debugfs_create_file_unsafe() were
introduced in mainline commit c6468808149 ("debugfs: add support for
self-protecting attribute file fops"), but on older kernel versions
where we do not have this extra security in debugfs we can use the older
functions instead.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/backport-include/linux/debugfs.h

index 11670388e39bb46dd596d7597515fdbca597a988..fb50c4f5750e16e199f5428231f885a81bf59e74 100644 (file)
@@ -53,4 +53,11 @@ debugfs_real_fops(const struct file *filp)
 }
 #endif /* <4.9.0 but not >= 4.8.4, 4.7.10 */
 
+#ifndef DEFINE_DEBUGFS_ATTRIBUTE
+#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
+       DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt)
+#define debugfs_create_file_unsafe(name, mode, parent, data, fops) \
+       debugfs_create_file(name, mode, parent, data, fops)
+#endif
+
 #endif /* __BACKPORT_DEBUGFS_H_ */