aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-14 19:05:53 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-16 13:57:36 -0400
commite4b63603c2a1e2c4db3de11b0f2b17360a7695bb (patch)
tree06747806edc1c0e5c8510091300e5f5fcbd4b170 /include
parentf2f37f58b1b933b06d6d84e80a31a1b500fb0db2 (diff)
sysfs.h: add BIN_ATTR macro
This makes it easier to create static binary attributes, which is needed in a number of drivers, instead of "open coding" them. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/sysfs.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index f62ff01e5f59..d50a96b9bb6d 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -132,6 +132,15 @@ struct bin_attribute {
132 */ 132 */
133#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) 133#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)
134 134
135/* macro to create static binary attributes easier */
136#define BIN_ATTR(_name, _mode, _read, _write, _size) \
137struct bin_attribute bin_attr_##_name = { \
138 .attr = {.name = __stringify(_name), .mode = _mode }, \
139 .read = _read, \
140 .write = _write, \
141 .size = _size, \
142}
143
135struct sysfs_ops { 144struct sysfs_ops {
136 ssize_t (*show)(struct kobject *, struct attribute *,char *); 145 ssize_t (*show)(struct kobject *, struct attribute *,char *);
137 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 146 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);