aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sysfs.h
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2010-10-27 18:15:57 -0400
committerMichal Marek <mmarek@suse.cz>2010-10-27 18:15:57 -0400
commitb74b953b998bcc2db91b694446f3a2619ec32de6 (patch)
tree6ce24caabd730f6ae9287ed0676ec32e6ff31e9d /include/linux/sysfs.h
parentabb438526201c6a79949ad45375c051b6681c253 (diff)
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff)
Merge commit 'v2.6.36' into kbuild/misc
Update to be able to fix a recent change to scripts/basic/docproc.c (commit eda603f).
Diffstat (limited to 'include/linux/sysfs.h')
-rw-r--r--include/linux/sysfs.h100
1 files changed, 88 insertions, 12 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index cfa83083a2d4..96eb576d82fd 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -15,22 +15,44 @@
15#include <linux/compiler.h> 15#include <linux/compiler.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/lockdep.h>
19#include <linux/kobject_ns.h>
18#include <asm/atomic.h> 20#include <asm/atomic.h>
19 21
20struct kobject; 22struct kobject;
21struct module; 23struct module;
24enum kobj_ns_type;
22 25
23/* FIXME
24 * The *owner field is no longer used.
25 * x86 tree has been cleaned up. The owner
26 * attribute is still left for other arches.
27 */
28struct attribute { 26struct attribute {
29 const char *name; 27 const char *name;
30 struct module *owner;
31 mode_t mode; 28 mode_t mode;
29#ifdef CONFIG_DEBUG_LOCK_ALLOC
30 struct lock_class_key *key;
31 struct lock_class_key skey;
32#endif
32}; 33};
33 34
35/**
36 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
37 * @attr: struct attribute to initialize
38 *
39 * Initialize a dynamically allocated struct attribute so we can
40 * make lockdep happy. This is a new requirement for attributes
41 * and initially this is only needed when lockdep is enabled.
42 * Lockdep gives a nice error when your attribute is added to
43 * sysfs if you don't have this.
44 */
45#ifdef CONFIG_DEBUG_LOCK_ALLOC
46#define sysfs_attr_init(attr) \
47do { \
48 static struct lock_class_key __key; \
49 \
50 (attr)->key = &__key; \
51} while(0)
52#else
53#define sysfs_attr_init(attr) do {} while(0)
54#endif
55
34struct attribute_group { 56struct attribute_group {
35 const char *name; 57 const char *name;
36 mode_t (*is_visible)(struct kobject *, 58 mode_t (*is_visible)(struct kobject *,
@@ -60,20 +82,33 @@ struct attribute_group {
60 82
61#define attr_name(_attr) (_attr).attr.name 83#define attr_name(_attr) (_attr).attr.name
62 84
85struct file;
63struct vm_area_struct; 86struct vm_area_struct;
64 87
65struct bin_attribute { 88struct bin_attribute {
66 struct attribute attr; 89 struct attribute attr;
67 size_t size; 90 size_t size;
68 void *private; 91 void *private;
69 ssize_t (*read)(struct kobject *, struct bin_attribute *, 92 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
70 char *, loff_t, size_t); 93 char *, loff_t, size_t);
71 ssize_t (*write)(struct kobject *, struct bin_attribute *, 94 ssize_t (*write)(struct file *,struct kobject *, struct bin_attribute *,
72 char *, loff_t, size_t); 95 char *, loff_t, size_t);
73 int (*mmap)(struct kobject *, struct bin_attribute *attr, 96 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
74 struct vm_area_struct *vma); 97 struct vm_area_struct *vma);
75}; 98};
76 99
100/**
101 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
102 * @attr: struct bin_attribute to initialize
103 *
104 * Initialize a dynamically allocated struct bin_attribute so we
105 * can make lockdep happy. This is a new requirement for
106 * attributes and initially this is only needed when lockdep is
107 * enabled. Lockdep gives a nice error when your attribute is
108 * added to sysfs if you don't have this.
109 */
110#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
111
77struct sysfs_ops { 112struct sysfs_ops {
78 ssize_t (*show)(struct kobject *, struct attribute *,char *); 113 ssize_t (*show)(struct kobject *, struct attribute *,char *);
79 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 114 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
@@ -94,9 +129,12 @@ int __must_check sysfs_move_dir(struct kobject *kobj,
94 129
95int __must_check sysfs_create_file(struct kobject *kobj, 130int __must_check sysfs_create_file(struct kobject *kobj,
96 const struct attribute *attr); 131 const struct attribute *attr);
97int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, 132int __must_check sysfs_create_files(struct kobject *kobj,
98 mode_t mode); 133 const struct attribute **attr);
134int __must_check sysfs_chmod_file(struct kobject *kobj,
135 const struct attribute *attr, mode_t mode);
99void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); 136void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
137void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
100 138
101int __must_check sysfs_create_bin_file(struct kobject *kobj, 139int __must_check sysfs_create_bin_file(struct kobject *kobj,
102 const struct bin_attribute *attr); 140 const struct bin_attribute *attr);
@@ -110,6 +148,12 @@ int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
110 const char *name); 148 const char *name);
111void sysfs_remove_link(struct kobject *kobj, const char *name); 149void sysfs_remove_link(struct kobject *kobj, const char *name);
112 150
151int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
152 const char *old_name, const char *new_name);
153
154void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
155 const char *name);
156
113int __must_check sysfs_create_group(struct kobject *kobj, 157int __must_check sysfs_create_group(struct kobject *kobj,
114 const struct attribute_group *grp); 158 const struct attribute_group *grp);
115int sysfs_update_group(struct kobject *kobj, 159int sysfs_update_group(struct kobject *kobj,
@@ -124,10 +168,15 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
124void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 168void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
125void sysfs_notify_dirent(struct sysfs_dirent *sd); 169void sysfs_notify_dirent(struct sysfs_dirent *sd);
126struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 170struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
171 const void *ns,
127 const unsigned char *name); 172 const unsigned char *name);
128struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); 173struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
129void sysfs_put(struct sysfs_dirent *sd); 174void sysfs_put(struct sysfs_dirent *sd);
130void sysfs_printk_last_file(void); 175void sysfs_printk_last_file(void);
176
177/* Called to clear a ns tag when it is no longer valid */
178void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
179
131int __must_check sysfs_init(void); 180int __must_check sysfs_init(void);
132 181
133#else /* CONFIG_SYSFS */ 182#else /* CONFIG_SYSFS */
@@ -164,8 +213,14 @@ static inline int sysfs_create_file(struct kobject *kobj,
164 return 0; 213 return 0;
165} 214}
166 215
216static inline int sysfs_create_files(struct kobject *kobj,
217 const struct attribute **attr)
218{
219 return 0;
220}
221
167static inline int sysfs_chmod_file(struct kobject *kobj, 222static inline int sysfs_chmod_file(struct kobject *kobj,
168 struct attribute *attr, mode_t mode) 223 const struct attribute *attr, mode_t mode)
169{ 224{
170 return 0; 225 return 0;
171} 226}
@@ -175,6 +230,11 @@ static inline void sysfs_remove_file(struct kobject *kobj,
175{ 230{
176} 231}
177 232
233static inline void sysfs_remove_files(struct kobject *kobj,
234 const struct attribute **attr)
235{
236}
237
178static inline int sysfs_create_bin_file(struct kobject *kobj, 238static inline int sysfs_create_bin_file(struct kobject *kobj,
179 const struct bin_attribute *attr) 239 const struct bin_attribute *attr)
180{ 240{
@@ -203,6 +263,17 @@ static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
203{ 263{
204} 264}
205 265
266static inline int sysfs_rename_link(struct kobject *k, struct kobject *t,
267 const char *old_name, const char *new_name)
268{
269 return 0;
270}
271
272static inline void sysfs_delete_link(struct kobject *k, struct kobject *t,
273 const char *name)
274{
275}
276
206static inline int sysfs_create_group(struct kobject *kobj, 277static inline int sysfs_create_group(struct kobject *kobj,
207 const struct attribute_group *grp) 278 const struct attribute_group *grp)
208{ 279{
@@ -240,6 +311,7 @@ static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
240} 311}
241static inline 312static inline
242struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 313struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
314 const void *ns,
243 const unsigned char *name) 315 const unsigned char *name)
244{ 316{
245 return NULL; 317 return NULL;
@@ -252,6 +324,10 @@ static inline void sysfs_put(struct sysfs_dirent *sd)
252{ 324{
253} 325}
254 326
327static inline void sysfs_exit_ns(int type, const void *tag)
328{
329}
330
255static inline int __must_check sysfs_init(void) 331static inline int __must_check sysfs_init(void)
256{ 332{
257 return 0; 333 return 0;