aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/filesystems
diff options
context:
space:
mode:
authorMike Murphy <mamurph@cs.clemson.edu>2009-02-22 01:19:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-02-22 12:28:15 -0500
commitf8a1af6bbc63218cabce742a7a291ac7c08bbd00 (patch)
tree4d0e13844c5eca2731374b668211c29059d6af14 /Documentation/filesystems
parent245127dbe9ea1e5a93aae0d3ede09992f1e99f53 (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.txt50
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 @@
2sysfs - _The_ filesystem for exporting kernel objects. 2sysfs - _The_ filesystem for exporting kernel objects.
3 3
4Patrick Mochel <mochel@osdl.org> 4Patrick Mochel <mochel@osdl.org>
5Mike Murphy <mamurph@cs.clemson.edu>
5 6
610 January 2003 7Revised: 22 February 2009
8Original: 10 January 2003
7 9
8 10
9What it is: 11What it is:
@@ -64,12 +66,13 @@ An attribute definition is simply:
64 66
65struct attribute { 67struct 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
71int sysfs_create_file(struct kobject * kobj, struct attribute * attr); 74int sysfs_create_file(struct kobject * kobj, const struct attribute * attr);
72void sysfs_remove_file(struct kobject * kobj, struct attribute * attr); 75void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr);
73 76
74 77
75A bare attribute contains no means to read or write the value of the 78A bare attribute contains no means to read or write the value of the
@@ -80,9 +83,11 @@ a specific object type.
80For example, the driver model defines struct device_attribute like: 83For example, the driver model defines struct device_attribute like:
81 84
82struct device_attribute { 85struct 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
88int device_create_file(struct device *, struct device_attribute *); 93int device_create_file(struct device *, struct device_attribute *);
@@ -90,12 +95,8 @@ void device_remove_file(struct device *, struct device_attribute *);
90 95
91It also defines this helper for defining device attributes: 96It 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) \
94struct device_attribute dev_attr_##_name = { \ 99struct 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
100For example, declaring 101For 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
161specified when declaring the attribute. The method types should be as 162specified when declaring the attribute. The method types should be as
162simple as those defined for device attributes: 163simple as those defined for device attributes:
163 164
164 ssize_t (*show)(struct device * dev, char * buf); 165ssize_t (*show)(struct device * dev, struct device_attribute * attr,
165 ssize_t (*store)(struct device * dev, const char * buf); 166 char * buf);
167ssize_t (*store)(struct device * dev, struct device_attribute * attr,
168 const char * buf);
166 169
167IOW, they should take only an object and a buffer as parameters. 170IOW, they should take only an object, an attribute, and a buffer as parameters.
168 171
169 172
170sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the 173sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the
@@ -299,14 +302,16 @@ The following interface layers currently exist in sysfs:
299Structure: 302Structure:
300 303
301struct device_attribute { 304struct 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
307Declaring: 312Declaring:
308 313
309DEVICE_ATTR(_name, _str, _mode, _show, _store); 314DEVICE_ATTR(_name, _mode, _show, _store);
310 315
311Creation/Removal: 316Creation/Removal:
312 317
@@ -342,7 +347,8 @@ Structure:
342struct driver_attribute { 347struct 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
348Declaring: 354Declaring: