Commit f8a1af6b authored by Mike Murphy's avatar Mike Murphy Committed by Linus Torvalds

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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 245127db
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
sysfs - _The_ filesystem for exporting kernel objects. sysfs - _The_ filesystem for exporting kernel objects.
Patrick Mochel <mochel@osdl.org> Patrick Mochel <mochel@osdl.org>
Mike Murphy <mamurph@cs.clemson.edu>
10 January 2003 Revised: 22 February 2009
Original: 10 January 2003
What it is: What it is:
...@@ -64,12 +66,13 @@ An attribute definition is simply: ...@@ -64,12 +66,13 @@ An attribute definition is simply:
struct attribute { struct attribute {
char * name; char * name;
struct module *owner;
mode_t mode; mode_t mode;
}; };
int sysfs_create_file(struct kobject * kobj, struct attribute * attr); int sysfs_create_file(struct kobject * kobj, const struct attribute * attr);
void sysfs_remove_file(struct kobject * kobj, struct attribute * attr); void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr);
A bare attribute contains no means to read or write the value of the A bare attribute contains no means to read or write the value of the
...@@ -81,8 +84,10 @@ For example, the driver model defines struct device_attribute like: ...@@ -81,8 +84,10 @@ For example, the driver model defines struct device_attribute like:
struct device_attribute { struct device_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct device * dev, char * buf); ssize_t (*show)(struct device *dev, struct device_attribute *attr,
ssize_t (*store)(struct device * dev, const char * buf); char *buf);
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
}; };
int device_create_file(struct device *, struct device_attribute *); int device_create_file(struct device *, struct device_attribute *);
...@@ -91,11 +96,7 @@ void device_remove_file(struct device *, struct device_attribute *); ...@@ -91,11 +96,7 @@ void device_remove_file(struct device *, struct device_attribute *);
It also defines this helper for defining device attributes: It also defines this helper for defining device attributes:
#define DEVICE_ATTR(_name, _mode, _show, _store) \ #define DEVICE_ATTR(_name, _mode, _show, _store) \
struct device_attribute dev_attr_##_name = { \ struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
.attr = {.name = __stringify(_name) , .mode = _mode }, \
.show = _show, \
.store = _store, \
};
For example, declaring For example, declaring
...@@ -107,9 +108,9 @@ static struct device_attribute dev_attr_foo = { ...@@ -107,9 +108,9 @@ static struct device_attribute dev_attr_foo = {
.attr = { .attr = {
.name = "foo", .name = "foo",
.mode = S_IWUSR | S_IRUGO, .mode = S_IWUSR | S_IRUGO,
},
.show = show_foo, .show = show_foo,
.store = store_foo, .store = store_foo,
},
}; };
...@@ -161,10 +162,12 @@ To read or write attributes, show() or store() methods must be ...@@ -161,10 +162,12 @@ To read or write attributes, show() or store() methods must be
specified when declaring the attribute. The method types should be as specified when declaring the attribute. The method types should be as
simple as those defined for device attributes: simple as those defined for device attributes:
ssize_t (*show)(struct device * dev, char * buf); ssize_t (*show)(struct device * dev, struct device_attribute * attr,
ssize_t (*store)(struct device * dev, const char * buf); char * buf);
ssize_t (*store)(struct device * dev, struct device_attribute * attr,
const char * buf);
IOW, they should take only an object and a buffer as parameters. IOW, they should take only an object, an attribute, and a buffer as parameters.
sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the sysfs allocates a buffer of size (PAGE_SIZE) and passes it to the
...@@ -300,13 +303,15 @@ Structure: ...@@ -300,13 +303,15 @@ Structure:
struct device_attribute { struct device_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct device * dev, char * buf); ssize_t (*show)(struct device *dev, struct device_attribute *attr,
ssize_t (*store)(struct device * dev, const char * buf); char *buf);
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
}; };
Declaring: Declaring:
DEVICE_ATTR(_name, _str, _mode, _show, _store); DEVICE_ATTR(_name, _mode, _show, _store);
Creation/Removal: Creation/Removal:
...@@ -342,7 +347,8 @@ Structure: ...@@ -342,7 +347,8 @@ Structure:
struct driver_attribute { struct driver_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct device_driver *, char * buf); ssize_t (*show)(struct device_driver *, char * buf);
ssize_t (*store)(struct device_driver *, const char * buf); ssize_t (*store)(struct device_driver *, const char * buf,
size_t count);
}; };
Declaring: Declaring:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment