patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / linux / sysfs.h
1 /*
2  * sysfs.h - definitions for the device driver filesystem
3  *
4  * Copyright (c) 2001,2002 Patrick Mochel
5  *
6  * Please see Documentation/filesystems/sysfs.txt for more information.
7  */
8
9 #ifndef _SYSFS_H_
10 #define _SYSFS_H_
11
12 struct kobject;
13 struct module;
14
15 struct attribute {
16         char                    * name;
17         struct module           * owner;
18         mode_t                  mode;
19 };
20
21 struct attribute_group {
22         char                    * name;
23         struct attribute        ** attrs;
24 };
25
26
27 struct bin_attribute {
28         struct attribute        attr;
29         size_t                  size;
30         ssize_t (*read)(struct kobject *, char *, loff_t, size_t);
31         ssize_t (*write)(struct kobject *, char *, loff_t, size_t);
32 };
33
34 struct sysfs_ops {
35         ssize_t (*show)(struct kobject *, struct attribute *,char *);
36         ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
37 };
38
39 #ifdef CONFIG_SYSFS
40
41 extern int
42 sysfs_create_dir(struct kobject *);
43
44 extern void
45 sysfs_remove_dir(struct kobject *);
46
47 extern int
48 sysfs_rename_dir(struct kobject *, const char *new_name);
49
50 extern int
51 sysfs_create_file(struct kobject *, const struct attribute *);
52
53 extern int
54 sysfs_update_file(struct kobject *, const struct attribute *);
55
56 extern void
57 sysfs_remove_file(struct kobject *, const struct attribute *);
58
59 extern int 
60 sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name);
61
62 extern void
63 sysfs_remove_link(struct kobject *, char * name);
64
65 int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
66 int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
67
68 int sysfs_create_group(struct kobject *, const struct attribute_group *);
69 void sysfs_remove_group(struct kobject *, const struct attribute_group *);
70
71 #else /* CONFIG_SYSFS */
72
73 static inline int sysfs_create_dir(struct kobject * k)
74 {
75         return 0;
76 }
77
78 static inline void sysfs_remove_dir(struct kobject * k)
79 {
80         ;
81 }
82
83 static inline int sysfs_rename_dir(struct kobject * k, const char *new_name)
84 {
85         return 0;
86 }
87
88 static inline int sysfs_create_file(struct kobject * k, const struct attribute * a)
89 {
90         return 0;
91 }
92
93 static inline int sysfs_update_file(struct kobject * k, const struct attribute * a)
94 {
95         return 0;
96 }
97
98 static inline void sysfs_remove_file(struct kobject * k, const struct attribute * a)
99 {
100         ;
101 }
102
103 static inline int sysfs_create_link(struct kobject * k, struct kobject * t, char * n)
104 {
105         return 0;
106 }
107
108 static inline void sysfs_remove_link(struct kobject * k, char * name)
109 {
110         ;
111 }
112
113
114 static inline int sysfs_create_bin_file(struct kobject * k, struct bin_attribute * a)
115 {
116         return 0;
117 }
118
119 static inline int sysfs_remove_bin_file(struct kobject * k, struct bin_attribute * a)
120 {
121         return 0;
122 }
123
124 static inline int sysfs_create_group(struct kobject * k, const struct attribute_group *g)
125 {
126         return 0;
127 }
128
129 static inline void sysfs_remove_group(struct kobject * k, const struct attribute_group * g)
130 {
131         ;
132 }
133
134 #endif /* CONFIG_SYSFS */
135
136 #endif /* _SYSFS_H_ */