Rev 6936 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6102 | serge | 1 | /* |
2 | * sysfs.h - definitions for the device driver filesystem |
||
3 | * |
||
4 | * Copyright (c) 2001,2002 Patrick Mochel |
||
5 | * Copyright (c) 2004 Silicon Graphics, Inc. |
||
6 | * Copyright (c) 2007 SUSE Linux Products GmbH |
||
7 | * Copyright (c) 2007 Tejun Heo |
||
8 | * |
||
9 | * Please see Documentation/filesystems/sysfs.txt for more information. |
||
10 | */ |
||
11 | |||
12 | #ifndef _SYSFS_H_ |
||
13 | #define _SYSFS_H_ |
||
14 | #include |
||
15 | #include |
||
16 | #include |
||
6934 | serge | 17 | #include |
6102 | serge | 18 | #include |
19 | |||
20 | struct kobject; |
||
21 | struct module; |
||
22 | struct bin_attribute; |
||
23 | enum kobj_ns_type; |
||
24 | |||
25 | struct attribute { |
||
26 | const char *name; |
||
27 | umode_t mode; |
||
28 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
||
29 | bool ignore_lockdep:1; |
||
30 | struct lock_class_key *key; |
||
31 | struct lock_class_key skey; |
||
32 | #endif |
||
33 | }; |
||
6936 | serge | 34 | struct attribute_group { |
35 | const char *name; |
||
36 | umode_t (*is_visible)(struct kobject *, |
||
37 | struct attribute *, int); |
||
38 | umode_t (*is_bin_visible)(struct kobject *, |
||
39 | struct bin_attribute *, int); |
||
40 | struct attribute **attrs; |
||
41 | struct bin_attribute **bin_attrs; |
||
42 | }; |
||
6102 | serge | 43 | #ifdef CONFIG_SYSFS |
44 | |||
45 | int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns); |
||
46 | void sysfs_remove_dir(struct kobject *kobj); |
||
47 | int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name, |
||
48 | const void *new_ns); |
||
49 | int __must_check sysfs_move_dir_ns(struct kobject *kobj, |
||
50 | struct kobject *new_parent_kobj, |
||
51 | const void *new_ns); |
||
52 | int __must_check sysfs_create_mount_point(struct kobject *parent_kobj, |
||
53 | const char *name); |
||
54 | void sysfs_remove_mount_point(struct kobject *parent_kobj, |
||
55 | const char *name); |
||
56 | |||
57 | int __must_check sysfs_create_file_ns(struct kobject *kobj, |
||
58 | const struct attribute *attr, |
||
59 | const void *ns); |
||
60 | int __must_check sysfs_create_files(struct kobject *kobj, |
||
61 | const struct attribute **attr); |
||
62 | int __must_check sysfs_chmod_file(struct kobject *kobj, |
||
63 | const struct attribute *attr, umode_t mode); |
||
64 | void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr, |
||
65 | const void *ns); |
||
66 | bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr); |
||
67 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); |
||
68 | |||
69 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
||
70 | const struct bin_attribute *attr); |
||
71 | void sysfs_remove_bin_file(struct kobject *kobj, |
||
72 | const struct bin_attribute *attr); |
||
73 | |||
74 | int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target, |
||
75 | const char *name); |
||
76 | int __must_check sysfs_create_link_nowarn(struct kobject *kobj, |
||
77 | struct kobject *target, |
||
78 | const char *name); |
||
79 | void sysfs_remove_link(struct kobject *kobj, const char *name); |
||
80 | |||
81 | int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target, |
||
82 | const char *old_name, const char *new_name, |
||
83 | const void *new_ns); |
||
84 | |||
85 | void sysfs_delete_link(struct kobject *dir, struct kobject *targ, |
||
86 | const char *name); |
||
87 | |||
88 | int __must_check sysfs_create_group(struct kobject *kobj, |
||
89 | const struct attribute_group *grp); |
||
90 | int __must_check sysfs_create_groups(struct kobject *kobj, |
||
91 | const struct attribute_group **groups); |
||
92 | int sysfs_update_group(struct kobject *kobj, |
||
93 | const struct attribute_group *grp); |
||
94 | void sysfs_remove_group(struct kobject *kobj, |
||
95 | const struct attribute_group *grp); |
||
96 | void sysfs_remove_groups(struct kobject *kobj, |
||
97 | const struct attribute_group **groups); |
||
98 | int sysfs_add_file_to_group(struct kobject *kobj, |
||
99 | const struct attribute *attr, const char *group); |
||
100 | void sysfs_remove_file_from_group(struct kobject *kobj, |
||
101 | const struct attribute *attr, const char *group); |
||
102 | int sysfs_merge_group(struct kobject *kobj, |
||
103 | const struct attribute_group *grp); |
||
104 | void sysfs_unmerge_group(struct kobject *kobj, |
||
105 | const struct attribute_group *grp); |
||
106 | int sysfs_add_link_to_group(struct kobject *kobj, const char *group_name, |
||
107 | struct kobject *target, const char *link_name); |
||
108 | void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, |
||
109 | const char *link_name); |
||
110 | int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, |
||
111 | struct kobject *target_kobj, |
||
112 | const char *target_name); |
||
113 | |||
114 | void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); |
||
115 | |||
116 | int __must_check sysfs_init(void); |
||
117 | |||
118 | static inline void sysfs_enable_ns(struct kernfs_node *kn) |
||
119 | { |
||
120 | return kernfs_enable_ns(kn); |
||
121 | } |
||
122 | |||
123 | #else /* CONFIG_SYSFS */ |
||
124 | |||
125 | static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) |
||
126 | { |
||
127 | return 0; |
||
128 | } |
||
129 | |||
130 | static inline void sysfs_remove_dir(struct kobject *kobj) |
||
131 | { |
||
132 | } |
||
133 | |||
134 | static inline int sysfs_rename_dir_ns(struct kobject *kobj, |
||
135 | const char *new_name, const void *new_ns) |
||
136 | { |
||
137 | return 0; |
||
138 | } |
||
139 | |||
140 | static inline int sysfs_move_dir_ns(struct kobject *kobj, |
||
141 | struct kobject *new_parent_kobj, |
||
142 | const void *new_ns) |
||
143 | { |
||
144 | return 0; |
||
145 | } |
||
146 | |||
147 | static inline int sysfs_create_mount_point(struct kobject *parent_kobj, |
||
148 | const char *name) |
||
149 | { |
||
150 | return 0; |
||
151 | } |
||
152 | |||
153 | static inline void sysfs_remove_mount_point(struct kobject *parent_kobj, |
||
154 | const char *name) |
||
155 | { |
||
156 | } |
||
157 | |||
158 | static inline int sysfs_create_file_ns(struct kobject *kobj, |
||
159 | const struct attribute *attr, |
||
160 | const void *ns) |
||
161 | { |
||
162 | return 0; |
||
163 | } |
||
164 | |||
165 | static inline int sysfs_create_files(struct kobject *kobj, |
||
166 | const struct attribute **attr) |
||
167 | { |
||
168 | return 0; |
||
169 | } |
||
170 | |||
171 | static inline int sysfs_chmod_file(struct kobject *kobj, |
||
172 | const struct attribute *attr, umode_t mode) |
||
173 | { |
||
174 | return 0; |
||
175 | } |
||
176 | |||
177 | static inline void sysfs_remove_file_ns(struct kobject *kobj, |
||
178 | const struct attribute *attr, |
||
179 | const void *ns) |
||
180 | { |
||
181 | } |
||
182 | |||
183 | static inline bool sysfs_remove_file_self(struct kobject *kobj, |
||
184 | const struct attribute *attr) |
||
185 | { |
||
186 | return false; |
||
187 | } |
||
188 | |||
189 | static inline void sysfs_remove_files(struct kobject *kobj, |
||
190 | const struct attribute **attr) |
||
191 | { |
||
192 | } |
||
193 | |||
194 | static inline int sysfs_create_bin_file(struct kobject *kobj, |
||
195 | const struct bin_attribute *attr) |
||
196 | { |
||
197 | return 0; |
||
198 | } |
||
199 | |||
200 | static inline void sysfs_remove_bin_file(struct kobject *kobj, |
||
201 | const struct bin_attribute *attr) |
||
202 | { |
||
203 | } |
||
204 | |||
7143 | serge | 205 | static inline int sysfs_create_link(struct kobject *kobj, |
206 | struct kobject *target, const char *name) |
||
207 | { |
||
208 | return 0; |
||
209 | } |
||
6102 | serge | 210 | |
211 | static inline int sysfs_create_link_nowarn(struct kobject *kobj, |
||
212 | struct kobject *target, |
||
213 | const char *name) |
||
214 | { |
||
215 | return 0; |
||
216 | } |
||
217 | |||
7143 | serge | 218 | static inline void sysfs_remove_link(struct kobject *kobj, const char *name) |
219 | { |
||
220 | } |
||
6102 | serge | 221 | |
222 | static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t, |
||
223 | const char *old_name, |
||
224 | const char *new_name, const void *ns) |
||
225 | { |
||
226 | return 0; |
||
227 | } |
||
228 | |||
229 | static inline void sysfs_delete_link(struct kobject *k, struct kobject *t, |
||
230 | const char *name) |
||
231 | { |
||
232 | } |
||
233 | |||
6936 | serge | 234 | static inline int sysfs_create_group(struct kobject *kobj, |
235 | const struct attribute_group *grp) |
||
236 | { |
||
237 | return 0; |
||
238 | } |
||
6102 | serge | 239 | |
6936 | serge | 240 | static inline int sysfs_create_groups(struct kobject *kobj, |
241 | const struct attribute_group **groups) |
||
242 | { |
||
243 | return 0; |
||
244 | } |
||
245 | |||
246 | static inline int sysfs_update_group(struct kobject *kobj, |
||
247 | const struct attribute_group *grp) |
||
248 | { |
||
249 | return 0; |
||
250 | } |
||
251 | |||
252 | static inline void sysfs_remove_group(struct kobject *kobj, |
||
253 | const struct attribute_group *grp) |
||
254 | { |
||
255 | } |
||
256 | |||
257 | static inline void sysfs_remove_groups(struct kobject *kobj, |
||
258 | const struct attribute_group **groups) |
||
259 | { |
||
260 | } |
||
261 | |||
6102 | serge | 262 | static inline int sysfs_add_file_to_group(struct kobject *kobj, |
263 | const struct attribute *attr, const char *group) |
||
264 | { |
||
265 | return 0; |
||
266 | } |
||
267 | |||
268 | static inline void sysfs_remove_file_from_group(struct kobject *kobj, |
||
269 | const struct attribute *attr, const char *group) |
||
270 | { |
||
271 | } |
||
272 | |||
6936 | serge | 273 | static inline int sysfs_merge_group(struct kobject *kobj, |
274 | const struct attribute_group *grp) |
||
275 | { |
||
276 | return 0; |
||
277 | } |
||
278 | |||
279 | static inline void sysfs_unmerge_group(struct kobject *kobj, |
||
280 | const struct attribute_group *grp) |
||
281 | { |
||
282 | } |
||
283 | |||
6102 | serge | 284 | static inline int sysfs_add_link_to_group(struct kobject *kobj, |
285 | const char *group_name, struct kobject *target, |
||
286 | const char *link_name) |
||
287 | { |
||
288 | return 0; |
||
289 | } |
||
290 | |||
291 | static inline void sysfs_remove_link_from_group(struct kobject *kobj, |
||
292 | const char *group_name, const char *link_name) |
||
293 | { |
||
294 | } |
||
295 | |||
296 | static inline int __compat_only_sysfs_link_entry_to_kobj( |
||
297 | struct kobject *kobj, |
||
298 | struct kobject *target_kobj, |
||
299 | const char *target_name) |
||
300 | { |
||
301 | return 0; |
||
302 | } |
||
303 | |||
304 | static inline void sysfs_notify(struct kobject *kobj, const char *dir, |
||
305 | const char *attr) |
||
306 | { |
||
307 | } |
||
308 | |||
309 | static inline int __must_check sysfs_init(void) |
||
310 | { |
||
311 | return 0; |
||
312 | } |
||
313 | |||
314 | #endif /* CONFIG_SYSFS */ |
||
315 | #endif /* _SYSFS_H_ */ |