aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sysfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sysfs.h')
-rw-r--r--include/linux/sysfs.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 9e8a9b555ad6..11baec7c9b26 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -51,9 +51,9 @@ do { \
51 static struct lock_class_key __key; \ 51 static struct lock_class_key __key; \
52 \ 52 \
53 (attr)->key = &__key; \ 53 (attr)->key = &__key; \
54} while(0) 54} while (0)
55#else 55#else
56#define sysfs_attr_init(attr) do {} while(0) 56#define sysfs_attr_init(attr) do {} while (0)
57#endif 57#endif
58 58
59struct attribute_group { 59struct attribute_group {
@@ -69,7 +69,7 @@ struct attribute_group {
69 * for examples.. 69 * for examples..
70 */ 70 */
71 71
72#define __ATTR(_name,_mode,_show,_store) { \ 72#define __ATTR(_name, _mode, _show, _store) { \
73 .attr = {.name = __stringify(_name), .mode = _mode }, \ 73 .attr = {.name = __stringify(_name), .mode = _mode }, \
74 .show = _show, \ 74 .show = _show, \
75 .store = _store, \ 75 .store = _store, \
@@ -80,6 +80,11 @@ struct attribute_group {
80 .show = _name##_show, \ 80 .show = _name##_show, \
81} 81}
82 82
83#define __ATTR_WO(_name) { \
84 .attr = { .name = __stringify(_name), .mode = S_IWUSR }, \
85 .store = _name##_store, \
86}
87
83#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \ 88#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \
84 _name##_show, _name##_store) 89 _name##_show, _name##_store)
85 90
@@ -108,8 +113,6 @@ static const struct attribute_group _name##_group = { \
108}; \ 113}; \
109__ATTRIBUTE_GROUPS(_name) 114__ATTRIBUTE_GROUPS(_name)
110 115
111#define attr_name(_attr) (_attr).attr.name
112
113struct file; 116struct file;
114struct vm_area_struct; 117struct vm_area_struct;
115 118
@@ -119,7 +122,7 @@ struct bin_attribute {
119 void *private; 122 void *private;
120 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *, 123 ssize_t (*read)(struct file *, struct kobject *, struct bin_attribute *,
121 char *, loff_t, size_t); 124 char *, loff_t, size_t);
122 ssize_t (*write)(struct file *,struct kobject *, struct bin_attribute *, 125 ssize_t (*write)(struct file *, struct kobject *, struct bin_attribute *,
123 char *, loff_t, size_t); 126 char *, loff_t, size_t);
124 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr, 127 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
125 struct vm_area_struct *vma); 128 struct vm_area_struct *vma);
@@ -153,7 +156,7 @@ struct bin_attribute {
153 156
154#define __BIN_ATTR_RW(_name, _size) __BIN_ATTR(_name, \ 157#define __BIN_ATTR_RW(_name, _size) __BIN_ATTR(_name, \
155 (S_IWUSR | S_IRUGO), _name##_read, \ 158 (S_IWUSR | S_IRUGO), _name##_read, \
156 _name##_write) 159 _name##_write, _size)
157 160
158#define __BIN_ATTR_NULL __ATTR_NULL 161#define __BIN_ATTR_NULL __ATTR_NULL
159 162
@@ -168,8 +171,8 @@ struct bin_attribute bin_attr_##_name = __BIN_ATTR_RO(_name, _size)
168struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size) 171struct bin_attribute bin_attr_##_name = __BIN_ATTR_RW(_name, _size)
169 172
170struct sysfs_ops { 173struct sysfs_ops {
171 ssize_t (*show)(struct kobject *, struct attribute *,char *); 174 ssize_t (*show)(struct kobject *, struct attribute *, char *);
172 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 175 ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t);
173 const void *(*namespace)(struct kobject *, const struct attribute *); 176 const void *(*namespace)(struct kobject *, const struct attribute *);
174}; 177};
175 178
@@ -215,10 +218,14 @@ void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
215 218
216int __must_check sysfs_create_group(struct kobject *kobj, 219int __must_check sysfs_create_group(struct kobject *kobj,
217 const struct attribute_group *grp); 220 const struct attribute_group *grp);
221int __must_check sysfs_create_groups(struct kobject *kobj,
222 const struct attribute_group **groups);
218int sysfs_update_group(struct kobject *kobj, 223int sysfs_update_group(struct kobject *kobj,
219 const struct attribute_group *grp); 224 const struct attribute_group *grp);
220void sysfs_remove_group(struct kobject *kobj, 225void sysfs_remove_group(struct kobject *kobj,
221 const struct attribute_group *grp); 226 const struct attribute_group *grp);
227void sysfs_remove_groups(struct kobject *kobj,
228 const struct attribute_group **groups);
222int sysfs_add_file_to_group(struct kobject *kobj, 229int sysfs_add_file_to_group(struct kobject *kobj,
223 const struct attribute *attr, const char *group); 230 const struct attribute *attr, const char *group);
224void sysfs_remove_file_from_group(struct kobject *kobj, 231void sysfs_remove_file_from_group(struct kobject *kobj,
@@ -343,6 +350,12 @@ static inline int sysfs_create_group(struct kobject *kobj,
343 return 0; 350 return 0;
344} 351}
345 352
353static inline int sysfs_create_groups(struct kobject *kobj,
354 const struct attribute_group **groups)
355{
356 return 0;
357}
358
346static inline int sysfs_update_group(struct kobject *kobj, 359static inline int sysfs_update_group(struct kobject *kobj,
347 const struct attribute_group *grp) 360 const struct attribute_group *grp)
348{ 361{
@@ -354,6 +367,11 @@ static inline void sysfs_remove_group(struct kobject *kobj,
354{ 367{
355} 368}
356 369
370static inline void sysfs_remove_groups(struct kobject *kobj,
371 const struct attribute_group **groups)
372{
373}
374
357static inline int sysfs_add_file_to_group(struct kobject *kobj, 375static inline int sysfs_add_file_to_group(struct kobject *kobj,
358 const struct attribute *attr, const char *group) 376 const struct attribute *attr, const char *group)
359{ 377{