Subversion Repositories Kolibri OS

Rev

Rev 6936 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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