2 * sysfs.h - definitions for the device driver filesystem
4 * Copyright (c) 2001,2002 Patrick Mochel
6 * Please see Documentation/filesystems/sysfs.txt for more information.
12 #include <asm/atomic.h>
14 #define SYSFS_SUPER_MAGIC 0x62656572
21 struct module * owner;
25 struct attribute_group {
27 struct attribute ** attrs;
33 * Use these macros to make defining attributes easier. See include/linux/device.h
37 #define __ATTR(_name,_mode,_show,_store) { \
38 .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
43 #define __ATTR_RO(_name) { \
44 .attr = { .name = __stringify(_name), .mode = 0444, .owner = THIS_MODULE }, \
45 .show = _name##_show, \
48 #define __ATTR_NULL { .attr = { .name = NULL } }
50 #define attr_name(_attr) (_attr).attr.name
52 struct bin_attribute {
53 struct attribute attr;
55 ssize_t (*read)(struct kobject *, char *, loff_t, size_t);
56 ssize_t (*write)(struct kobject *, char *, loff_t, size_t);
60 ssize_t (*show)(struct kobject *, struct attribute *,char *);
61 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
66 struct list_head s_sibling;
67 struct list_head s_children;
71 struct dentry * s_dentry;
74 #define SYSFS_ROOT 0x0001
75 #define SYSFS_DIR 0x0002
76 #define SYSFS_KOBJ_ATTR 0x0004
77 #define SYSFS_KOBJ_BIN_ATTR 0x0008
78 #define SYSFS_KOBJ_LINK 0x0020
79 #define SYSFS_NOT_PINNED (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR | SYSFS_KOBJ_LINK)
84 sysfs_create_dir(struct kobject *);
87 sysfs_remove_dir(struct kobject *);
90 sysfs_rename_dir(struct kobject *, const char *new_name);
93 sysfs_create_file(struct kobject *, const struct attribute *);
96 sysfs_update_file(struct kobject *, const struct attribute *);
99 sysfs_remove_file(struct kobject *, const struct attribute *);
102 sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name);
105 sysfs_remove_link(struct kobject *, char * name);
107 int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
108 int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
110 int sysfs_create_group(struct kobject *, const struct attribute_group *);
111 void sysfs_remove_group(struct kobject *, const struct attribute_group *);
113 #else /* CONFIG_SYSFS */
115 static inline int sysfs_create_dir(struct kobject * k)
120 static inline void sysfs_remove_dir(struct kobject * k)
125 static inline int sysfs_rename_dir(struct kobject * k, const char *new_name)
130 static inline int sysfs_create_file(struct kobject * k, const struct attribute * a)
135 static inline int sysfs_update_file(struct kobject * k, const struct attribute * a)
140 static inline void sysfs_remove_file(struct kobject * k, const struct attribute * a)
145 static inline int sysfs_create_link(struct kobject * k, struct kobject * t, char * n)
150 static inline void sysfs_remove_link(struct kobject * k, char * name)
156 static inline int sysfs_create_bin_file(struct kobject * k, struct bin_attribute * a)
161 static inline int sysfs_remove_bin_file(struct kobject * k, struct bin_attribute * a)
166 static inline int sysfs_create_group(struct kobject * k, const struct attribute_group *g)
171 static inline void sysfs_remove_group(struct kobject * k, const struct attribute_group * g)
176 #endif /* CONFIG_SYSFS */
178 #endif /* _SYSFS_H_ */