Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4b63603 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

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: default avatarGuenter Roeck <linux@roeck-us.net>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f2f37f58
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -132,6 +132,15 @@ struct bin_attribute {
 */
#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr)

/* macro to create static binary attributes easier */
#define BIN_ATTR(_name, _mode, _read, _write, _size)		\
struct bin_attribute bin_attr_##_name = {			\
	.attr = {.name = __stringify(_name), .mode = _mode },	\
	.read	= _read,					\
	.write	= _write,					\
	.size	= _size,					\
}

struct sysfs_ops {
	ssize_t	(*show)(struct kobject *, struct attribute *,char *);
	ssize_t	(*store)(struct kobject *,struct attribute *,const char *, size_t);