aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sysfs.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-03-08 13:17:20 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-08 13:17:20 -0500
commite10154189f001b6428a83f58b03a27954f0f8022 (patch)
tree30b4ac5760c5d310e9cc2cbf8fc4b9c6f9d0e369 /include/linux/sysfs.h
parentd4bab1b091be4a91a7363118c9ede3cc9a7fefd4 (diff)
parent410c17651998944630a95fbb286a50362de2dbb0 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (62 commits) msi-laptop: depends on RFKILL msi-laptop: Detect 3G device exists by standard ec command msi-laptop: Add resume method for set the SCM load again msi-laptop: Support some MSI 3G netbook that is need load SCM msi-laptop: Add threeg sysfs file for support query 3G state by standard 66/62 ec command msi-laptop: Support standard ec 66/62 command on MSI notebook and nebook Driver core: create lock/unlock functions for struct device sysfs: fix for thinko with sysfs_bin_attr_init() sysfs: Kill unused sysfs_sb variable. sysfs: Pass super_block to sysfs_get_inode driver core: Use sysfs_rename_link in device_rename sysfs: Implement sysfs_rename_link sysfs: Pack sysfs_dirent more tightly. sysfs: Serialize updates to the vfs inode sysfs: windfarm: init sysfs attributes sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on module dynamic attributes sysfs: Document sysfs_attr_init and sysfs_bin_attr_init sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on dynamic attributes sysfs: Use one lockdep class per sysfs attribute. sysfs: Only take active references on attributes. ...
Diffstat (limited to 'include/linux/sysfs.h')
-rw-r--r--include/linux/sysfs.h61
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
20struct kobject; 21struct 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) \
51do { \
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
34struct attribute_group { 60struct 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
77struct sysfs_ops { 115struct 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
95int __must_check sysfs_create_file(struct kobject *kobj, 133int __must_check sysfs_create_file(struct kobject *kobj,
96 const struct attribute *attr); 134 const struct attribute *attr);
135int __must_check sysfs_create_files(struct kobject *kobj,
136 const struct attribute **attr);
97int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, 137int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr,
98 mode_t mode); 138 mode_t mode);
99void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr); 139void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
140void sysfs_remove_files(struct kobject *kobj, const struct attribute **attr);
100 141
101int __must_check sysfs_create_bin_file(struct kobject *kobj, 142int __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);
111void sysfs_remove_link(struct kobject *kobj, const char *name); 152void sysfs_remove_link(struct kobject *kobj, const char *name);
112 153
154int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
155 const char *old_name, const char *new_name);
156
113int __must_check sysfs_create_group(struct kobject *kobj, 157int __must_check sysfs_create_group(struct kobject *kobj,
114 const struct attribute_group *grp); 158 const struct attribute_group *grp);
115int sysfs_update_group(struct kobject *kobj, 159int 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
211static inline int sysfs_create_files(struct kobject *kobj,
212 const struct attribute **attr)
213{
214 return 0;
215}
216
167static inline int sysfs_chmod_file(struct kobject *kobj, 217static 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
228static inline void sysfs_remove_files(struct kobject *kobj,
229 const struct attribute **attr)
230{
231}
232
178static inline int sysfs_create_bin_file(struct kobject *kobj, 233static 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
261static 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
206static inline int sysfs_create_group(struct kobject *kobj, 267static inline int sysfs_create_group(struct kobject *kobj,
207 const struct attribute_group *grp) 268 const struct attribute_group *grp)
208{ 269{