diff options
author | Mike Murphy <mamurph@cs.clemson.edu> | 2009-02-22 01:19:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-02-22 12:28:15 -0500 |
commit | f8a1af6bbc63218cabce742a7a291ac7c08bbd00 (patch) | |
tree | 4d0e13844c5eca2731374b668211c29059d6af14 /Documentation/filesystems | |
parent | 245127dbe9ea1e5a93aae0d3ede09992f1e99f53 (diff) |
PATCH [2/2] Documentation/filesystems/sysfs.txt: fix descriptions of device attributes
Fix descriptions of device attributes to be consistent with the actual
implementations in include/linux/device.h
Signed-off-by: Mike Murphy <mamurph[at]cs.clemson.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/filesystems')
-rw-r--r-- | Documentation/filesystems/sysfs.txt | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index 9e9c348275a9..7e81e37c0b1e 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt | |||
@@ -2,8 +2,10 @@ | |||
2 | sysfs - _The_ filesystem for exporting kernel objects. | 2 | sysfs - _The_ filesystem for exporting kernel objects. |
3 | 3 | ||
4 | Patrick Mochel <mochel@osdl.org> | 4 | Patrick Mochel <mochel@osdl.org> |
5 | Mike Murphy <mamurph@cs.clemson.edu> | ||
5 | 6 | ||
6 | 10 January 2003 | 7 | Revised: 22 February 2009 |
8 | Original: 10 January 2003 | ||
7 | 9 | ||
8 | 10 | ||
9 | What it is: | 11 | What it is: |
@@ -64,12 +66,13 @@ An attribute definition is simply: | |||
64 | 66 | ||
65 | struct attribute { | 67 | struct attribute { |
66 | char * name; | 68 | char * name; |
69 | struct module *owner; | ||
67 | mode_t mode; | 70 | mode_t mode; |
68 | }; | 71 | }; |
69 | 72 | ||
70 | 73 | ||
71 | int sysfs_create_file(struct kobject * kobj, struct attribute * attr); | 74 | int sysfs_create_file(struct kobject * kobj, const struct attribute * attr); |
72 | void sysfs_remove_file(struct kobject * kobj, struct attribute * attr); | 75 | void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr); |
73 | 76 | ||
74 | 77 | ||
75 | A bare attribute contains no means to read or write the value of the | 78 | A bare attribute contains no means to read or write the value of the |
@@ -80,9 +83,11 @@ a specific object type. | |||
80 | For example, the driver model defines struct device_attribute like: | 83 | For example, the driver model defines struct device_attribute like: |
81 | 84 | ||
82 | struct device_attribute { | 85 | struct device_attribute { |
83 | struct attribute attr; | 86 | struct attribute attr; |
84 | ssize_t (*show)(struct device * dev, char * buf); | 87 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, |
85 | ssize_t (*store)(struct device * dev, const char * buf); | 88 | char *buf); |
89 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, | ||
90 | const char *buf, size_t count); | ||
86 | }; | 91 | }; |
87 | 92 | ||
88 | int device_create_file(struct device *, struct device_attribute *); | 93 | int device_create_file(struct device *, struct device_attribute *); |
@@ -90,12 +95,8 @@ void device_remove_file(struct device *, struct device_attribute *); | |||
90 | 95 | ||
91 | It also defines this helper for defining device attributes: | 96 | It also defines this helper for defining device attributes: |
92 | 97 | ||
93 | #define DEVICE_ATTR(_name, _mode, _show, _store) \ | 98 | #define DEVICE_ATTR(_name, _mode, _show, _store) \ |
94 | struct device_attribute dev_attr_##_name = { \ | 99 | struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) |
95 | .attr = {.name = __stringify(_name) , .mode = _mode }, \ | ||
96 | .show = _show, \ | ||
97 | .store = _store, \ | ||
98 | }; | ||
99 | 100 | ||
100 | For example, declaring | 101 | For example, declaring |
101 | 102 | ||
@@ -107,9 +108,9 @@ static struct device_attribute dev_attr_foo = { | |||
107 | .attr = { | 108 | .attr = { |
108 | .name = "foo", | 109 | .name = "foo", |
109 | .mode = S_IWUSR | S_IRUGO, | 110 | .mode = S_IWUSR | S_IRUGO, |
111 | .show = show_foo, | ||
112 | .store = store_foo, | ||
110 | }, | 113 | }, |
111 | .show = show_foo, | ||
112 | .store = store_foo, | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | 116 | ||
@@ -161,10 +162,12 @@ To read or write attributes, show() or store() methods must be | |||
161 | specified when declaring the attribute. The method types should be as | 162 | specified when declaring the attribute. The method types should be as |
162 | simple as those defined for device attributes: | 163 | simple as those defined for device attributes: |
163 | 164 | ||
164 | ssize_t (*show)(struct device * dev, char * buf); | 165 | ssize_t (*show)(struct device * dev, struct device_attribute * attr, |
165 | ssize_t (*store)(struct device * dev, const char * buf); | 166 | char * buf); |
167 | ssize_t (*store)(struct device * dev, struct device_attribute * attr, | ||
168 | const char * buf); | ||
166 | 169 | ||
167 | IOW, they should take only an object and a buffer as parameters. | 170 | IOW, they should take only an object, an attribute, and a buffer as parameters. |
168 | 171 | ||
169 | 172 | ||
170 | sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the | 173 | sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the |
@@ -299,14 +302,16 @@ The following interface layers currently exist in sysfs: | |||
299 | Structure: | 302 | Structure: |
300 | 303 | ||
301 | struct device_attribute { | 304 | struct device_attribute { |
302 | struct attribute attr; | 305 | struct attribute attr; |
303 | ssize_t (*show)(struct device * dev, char * buf); | 306 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, |
304 | ssize_t (*store)(struct device * dev, const char * buf); | 307 | char *buf); |
308 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, | ||
309 | const char *buf, size_t count); | ||
305 | }; | 310 | }; |
306 | 311 | ||
307 | Declaring: | 312 | Declaring: |
308 | 313 | ||
309 | DEVICE_ATTR(_name, _str, _mode, _show, _store); | 314 | DEVICE_ATTR(_name, _mode, _show, _store); |
310 | 315 | ||
311 | Creation/Removal: | 316 | Creation/Removal: |
312 | 317 | ||
@@ -342,7 +347,8 @@ Structure: | |||
342 | struct driver_attribute { | 347 | struct driver_attribute { |
343 | struct attribute attr; | 348 | struct attribute attr; |
344 | ssize_t (*show)(struct device_driver *, char * buf); | 349 | ssize_t (*show)(struct device_driver *, char * buf); |
345 | ssize_t (*store)(struct device_driver *, const char * buf); | 350 | ssize_t (*store)(struct device_driver *, const char * buf, |
351 | size_t count); | ||
346 | }; | 352 | }; |
347 | 353 | ||
348 | Declaring: | 354 | Declaring: |