diff options
Diffstat (limited to 'include/linux/sysfs.h')
| -rw-r--r-- | include/linux/sysfs.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index cfa83083a2d4..f0496b3d1811 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
| 16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
| 17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
| 18 | #include <linux/lockdep.h> | ||
| 18 | #include <asm/atomic.h> | 19 | #include <asm/atomic.h> |
| 19 | 20 | ||
| 20 | struct kobject; | 21 | struct kobject; |
| @@ -29,8 +30,33 @@ struct attribute { | |||
| 29 | const char *name; | 30 | const char *name; |
| 30 | struct module *owner; | 31 | struct module *owner; |
| 31 | mode_t mode; | 32 | mode_t mode; |
| 33 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 34 | struct lock_class_key *key; | ||
| 35 | struct lock_class_key skey; | ||
| 36 | #endif | ||
| 32 | }; | 37 | }; |
| 33 | 38 | ||
| 39 | /** | ||
| 40 | * sysfs_attr_init - initialize a dynamically allocated sysfs attribute | ||
| 41 | * @attr: struct attribute to initialize | ||
| 42 | * | ||
| 43 | * Initialize a dynamically allocated struct attribute so we can | ||
| 44 | * make lockdep happy. This is a new requirement for attributes | ||
| 45 | * and initially this is only needed when lockdep is enabled. | ||
| 46 | * Lockdep gives a nice error when your attribute is added to | ||
| 47 | * sysfs if you don't have this. | ||
| 48 | */ | ||
| 49 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
| 50 | #define sysfs_attr_init(attr) \ | ||
| 51 | do { \ | ||
| 52 | static struct lock_class_key __key; \ | ||
| 53 | \ | ||
| 54 | (attr)->key = &__key; \ | ||
| 55 | } while(0) | ||
| 56 | #else | ||
| 57 | #define sysfs_attr_init(attr) do {} while(0) | ||
| 58 | #endif | ||
| 59 | |||
| 34 | struct attribute_group { | 60 | struct attribute_group { |
| 35 | const char *name; | 61 | const char *name; |
| 36 | mode_t (*is_visible)(struct kobject *, | 62 | mode_t (*is_visible)(struct kobject *, |
| @@ -74,6 +100,18 @@ struct bin_attribute { | |||
| 74 | struct vm_area_struct *vma); | 100 | struct vm_area_struct *vma); |
| 75 | }; | 101 | }; |
| 76 | 102 | ||
| 103 | /** | ||
| 104 | * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute | ||
| 105 | * @attr: struct bin_attribute to initialize | ||
| 106 | * | ||
| 107 | * Initialize a dynamically allocated struct bin_attribute so we | ||
| 108 | * can make lockdep happy. This is a new requirement for | ||
| 109 | * attributes and initially this is only needed when lockdep is | ||
| 110 | * enabled. Lockdep gives a nice error when your attribute is | ||
| 111 | * added to sysfs if you don't have this. | ||
| 112 | */ | ||
| 113 | #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) | ||
| 114 | |||
| 77 | struct sysfs_ops { | 115 | struct sysfs_ops { |
| 78 | ssize_t (*show)(struct kobject *, struct attribute *,char *); | 116 | ssize_t (*show)(struct kobject *, struct attribute *,char *); |
| 79 | ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); | 117 | ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); |
| @@ -94,9 +132,12 @@ int __must_check sysfs_move_dir(struct kobject *kobj, | |||
| 94 | 132 | ||
| 95 | int __must_check sysfs_create_file(struct kobject *kobj, | 133 | int __must_check sysfs_create_file(struct kobject *kobj, |
| 96 | const struct attribute *attr); | 134 | const struct attribute *attr); |
| 135 | int __must_check sysfs_create_files(struct kobject *kobj, | ||
| 136 | const struct attribute **attr); | ||
| 97 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, | 137 | int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, |
| 98 | mode_t mode); | 138 | mode_t mode); |
| 99 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); | 139 | void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); |
| 140 | void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr); | ||
| 100 | 141 | ||
| 101 | int __must_check sysfs_create_bin_file(struct kobject *kobj, | 142 | int __must_check sysfs_create_bin_file(struct kobject *kobj, |
| 102 | const struct bin_attribute *attr); | 143 | const struct bin_attribute *attr); |
| @@ -110,6 +151,9 @@ int __must_check sysfs_create_link_nowarn(struct kobject *kobj, | |||
| 110 | const char *name); | 151 | const char *name); |
| 111 | void sysfs_remove_link(struct kobject *kobj, const char *name); | 152 | void sysfs_remove_link(struct kobject *kobj, const char *name); |
| 112 | 153 | ||
| 154 | int sysfs_rename_link(struct kobject *kobj, struct kobject *target, | ||
| 155 | const char *old_name, const char *new_name); | ||
| 156 | |||
| 113 | int __must_check sysfs_create_group(struct kobject *kobj, | 157 | int __must_check sysfs_create_group(struct kobject *kobj, |
| 114 | const struct attribute_group *grp); | 158 | const struct attribute_group *grp); |
| 115 | int sysfs_update_group(struct kobject *kobj, | 159 | int sysfs_update_group(struct kobject *kobj, |
| @@ -164,6 +208,12 @@ static inline int sysfs_create_file(struct kobject *kobj, | |||
| 164 | return 0; | 208 | return 0; |
| 165 | } | 209 | } |
| 166 | 210 | ||
| 211 | static inline int sysfs_create_files(struct kobject *kobj, | ||
| 212 | const struct attribute **attr) | ||
| 213 | { | ||
| 214 | return 0; | ||
| 215 | } | ||
| 216 | |||
| 167 | static inline int sysfs_chmod_file(struct kobject *kobj, | 217 | static inline int sysfs_chmod_file(struct kobject *kobj, |
| 168 | struct attribute *attr, mode_t mode) | 218 | struct attribute *attr, mode_t mode) |
| 169 | { | 219 | { |
| @@ -175,6 +225,11 @@ static inline void sysfs_remove_file(struct kobject *kobj, | |||
| 175 | { | 225 | { |
| 176 | } | 226 | } |
| 177 | 227 | ||
| 228 | static inline void sysfs_remove_files(struct kobject *kobj, | ||
| 229 | const struct attribute **attr) | ||
| 230 | { | ||
| 231 | } | ||
| 232 | |||
| 178 | static inline int sysfs_create_bin_file(struct kobject *kobj, | 233 | static inline int sysfs_create_bin_file(struct kobject *kobj, |
| 179 | const struct bin_attribute *attr) | 234 | const struct bin_attribute *attr) |
| 180 | { | 235 | { |
| @@ -203,6 +258,12 @@ static inline void sysfs_remove_link(struct kobject *kobj, const char *name) | |||
| 203 | { | 258 | { |
| 204 | } | 259 | } |
| 205 | 260 | ||
| 261 | static inline int sysfs_rename_link(struct kobject *k, struct kobject *t, | ||
| 262 | const char *old_name, const char *new_name) | ||
| 263 | { | ||
| 264 | return 0; | ||
| 265 | } | ||
| 266 | |||
| 206 | static inline int sysfs_create_group(struct kobject *kobj, | 267 | static inline int sysfs_create_group(struct kobject *kobj, |
| 207 | const struct attribute_group *grp) | 268 | const struct attribute_group *grp) |
| 208 | { | 269 | { |
