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>

authored by

Mike Murphy and committed by
Linus Torvalds
f8a1af6b 245127db

+28 -22
+28 -22
Documentation/filesystems/sysfs.txt
··· 2 sysfs - _The_ filesystem for exporting kernel objects. 3 4 Patrick Mochel <mochel@osdl.org> 5 6 - 10 January 2003 7 8 9 What it is: ··· 66 67 struct attribute { 68 char * name; 69 mode_t mode; 70 }; 71 72 73 - int sysfs_create_file(struct kobject * kobj, struct attribute * attr); 74 - void sysfs_remove_file(struct kobject * kobj, struct attribute * attr); 75 76 77 A bare attribute contains no means to read or write the value of the ··· 83 For example, the driver model defines struct device_attribute like: 84 85 struct device_attribute { 86 - struct attribute attr; 87 - ssize_t (*show)(struct device * dev, char * buf); 88 - ssize_t (*store)(struct device * dev, const char * buf); 89 }; 90 91 int device_create_file(struct device *, struct device_attribute *); ··· 95 96 It also defines this helper for defining device attributes: 97 98 - #define DEVICE_ATTR(_name, _mode, _show, _store) \ 99 - struct device_attribute dev_attr_##_name = { \ 100 - .attr = {.name = __stringify(_name) , .mode = _mode }, \ 101 - .show = _show, \ 102 - .store = _store, \ 103 - }; 104 105 For example, declaring 106 ··· 108 .attr = { 109 .name = "foo", 110 .mode = S_IWUSR | S_IRUGO, 111 }, 112 - .show = show_foo, 113 - .store = store_foo, 114 }; 115 116 ··· 162 specified when declaring the attribute. The method types should be as 163 simple as those defined for device attributes: 164 165 - ssize_t (*show)(struct device * dev, char * buf); 166 - ssize_t (*store)(struct device * dev, const char * buf); 167 168 - IOW, they should take only an object and a buffer as parameters. 169 170 171 sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the ··· 302 Structure: 303 304 struct device_attribute { 305 - struct attribute attr; 306 - ssize_t (*show)(struct device * dev, char * buf); 307 - ssize_t (*store)(struct device * dev, const char * buf); 308 }; 309 310 Declaring: 311 312 - DEVICE_ATTR(_name, _str, _mode, _show, _store); 313 314 Creation/Removal: 315 ··· 347 struct driver_attribute { 348 struct attribute attr; 349 ssize_t (*show)(struct device_driver *, char * buf); 350 - ssize_t (*store)(struct device_driver *, const char * buf); 351 }; 352 353 Declaring:
··· 2 sysfs - _The_ filesystem for exporting kernel objects. 3 4 Patrick Mochel <mochel@osdl.org> 5 + Mike Murphy <mamurph@cs.clemson.edu> 6 7 + Revised: 22 February 2009 8 + Original: 10 January 2003 9 10 11 What it is: ··· 64 65 struct attribute { 66 char * name; 67 + struct module *owner; 68 mode_t mode; 69 }; 70 71 72 + int sysfs_create_file(struct kobject * kobj, const struct attribute * attr); 73 + void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr); 74 75 76 A bare attribute contains no means to read or write the value of the ··· 80 For example, the driver model defines struct device_attribute like: 81 82 struct device_attribute { 83 + struct attribute attr; 84 + ssize_t (*show)(struct device *dev, struct device_attribute *attr, 85 + char *buf); 86 + ssize_t (*store)(struct device *dev, struct device_attribute *attr, 87 + const char *buf, size_t count); 88 }; 89 90 int device_create_file(struct device *, struct device_attribute *); ··· 90 91 It also defines this helper for defining device attributes: 92 93 + #define DEVICE_ATTR(_name, _mode, _show, _store) \ 94 + struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) 95 96 For example, declaring 97 ··· 107 .attr = { 108 .name = "foo", 109 .mode = S_IWUSR | S_IRUGO, 110 + .show = show_foo, 111 + .store = store_foo, 112 }, 113 }; 114 115 ··· 161 specified when declaring the attribute. The method types should be as 162 simple as those defined for device attributes: 163 164 + ssize_t (*show)(struct device * dev, struct device_attribute * attr, 165 + char * buf); 166 + ssize_t (*store)(struct device * dev, struct device_attribute * attr, 167 + const char * buf); 168 169 + IOW, they should take only an object, an attribute, and a buffer as parameters. 170 171 172 sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the ··· 299 Structure: 300 301 struct device_attribute { 302 + struct attribute attr; 303 + ssize_t (*show)(struct device *dev, struct device_attribute *attr, 304 + char *buf); 305 + ssize_t (*store)(struct device *dev, struct device_attribute *attr, 306 + const char *buf, size_t count); 307 }; 308 309 Declaring: 310 311 + DEVICE_ATTR(_name, _mode, _show, _store); 312 313 Creation/Removal: 314 ··· 342 struct driver_attribute { 343 struct attribute attr; 344 ssize_t (*show)(struct device_driver *, char * buf); 345 + ssize_t (*store)(struct device_driver *, const char * buf, 346 + size_t count); 347 }; 348 349 Declaring: