summaryrefslogtreecommitdiffstats
path: root/include/linux/kernfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kernfs.h')
-rw-r--r--include/linux/kernfs.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index f20796ecc76e..105d09dcb064 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -11,6 +11,7 @@
11#include <linux/err.h> 11#include <linux/err.h>
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/mutex.h> 13#include <linux/mutex.h>
14#include <linux/lockdep.h>
14 15
15struct file; 16struct file;
16struct iattr; 17struct iattr;
@@ -62,6 +63,10 @@ struct kernfs_ops {
62 loff_t off); 63 loff_t off);
63 64
64 int (*mmap)(struct sysfs_open_file *of, struct vm_area_struct *vma); 65 int (*mmap)(struct sysfs_open_file *of, struct vm_area_struct *vma);
66
67#ifdef CONFIG_DEBUG_LOCK_ALLOC
68 struct lock_class_key lockdep_key;
69#endif
65}; 70};
66 71
67#ifdef CONFIG_SYSFS 72#ifdef CONFIG_SYSFS
@@ -69,11 +74,12 @@ struct kernfs_ops {
69struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent, 74struct sysfs_dirent *kernfs_create_dir_ns(struct sysfs_dirent *parent,
70 const char *name, void *priv, 75 const char *name, void *priv,
71 const void *ns); 76 const void *ns);
72struct sysfs_dirent *kernfs_create_file_ns(struct sysfs_dirent *parent, 77struct sysfs_dirent *kernfs_create_file_ns_key(struct sysfs_dirent *parent,
73 const char *name, 78 const char *name,
74 umode_t mode, loff_t size, 79 umode_t mode, loff_t size,
75 const struct kernfs_ops *ops, 80 const struct kernfs_ops *ops,
76 void *priv, const void *ns); 81 void *priv, const void *ns,
82 struct lock_class_key *key);
77struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent, 83struct sysfs_dirent *kernfs_create_link(struct sysfs_dirent *parent,
78 const char *name, 84 const char *name,
79 struct sysfs_dirent *target); 85 struct sysfs_dirent *target);
@@ -94,9 +100,10 @@ kernfs_create_dir_ns(struct sysfs_dirent *parent, const char *name, void *priv,
94{ return ERR_PTR(-ENOSYS); } 100{ return ERR_PTR(-ENOSYS); }
95 101
96static inline struct sysfs_dirent * 102static inline struct sysfs_dirent *
97kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name, 103kernfs_create_file_ns_key(struct sysfs_dirent *parent, const char *name,
98 umode_t mode, loff_t size, const struct kernfs_ops *ops, 104 umode_t mode, loff_t size,
99 void *priv, const void *ns) 105 const struct kernfs_ops *ops, void *priv,
106 const void *ns, struct lock_class_key *key)
100{ return ERR_PTR(-ENOSYS); } 107{ return ERR_PTR(-ENOSYS); }
101 108
102static inline struct sysfs_dirent * 109static inline struct sysfs_dirent *
@@ -132,6 +139,20 @@ kernfs_create_dir(struct sysfs_dirent *parent, const char *name, void *priv)
132} 139}
133 140
134static inline struct sysfs_dirent * 141static inline struct sysfs_dirent *
142kernfs_create_file_ns(struct sysfs_dirent *parent, const char *name,
143 umode_t mode, loff_t size, const struct kernfs_ops *ops,
144 void *priv, const void *ns)
145{
146 struct lock_class_key *key = NULL;
147
148#ifdef CONFIG_DEBUG_LOCK_ALLOC
149 key = (struct lock_class_key *)&ops->lockdep_key;
150#endif
151 return kernfs_create_file_ns_key(parent, name, mode, size, ops, priv,
152 ns, key);
153}
154
155static inline struct sysfs_dirent *
135kernfs_create_file(struct sysfs_dirent *parent, const char *name, umode_t mode, 156kernfs_create_file(struct sysfs_dirent *parent, const char *name, umode_t mode,
136 loff_t size, const struct kernfs_ops *ops, void *priv) 157 loff_t size, const struct kernfs_ops *ops, void *priv)
137{ 158{