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