Go to the documentation of this file.
38 #ifndef _CONFIGFS_MACROS_H_
39 #define _CONFIGFS_MACROS_H_
53 #define CONFIGFS_EATTR_STRUCT(_name, _item) \
54 struct _name##_attribute { \
55 struct configfs_attribute attr; \
56 ssize_t (*show)(struct _item *, char *); \
57 ssize_t (*store)(struct _item *, const char *, size_t); \
68 #define __CONFIGFS_EATTR(_name, _mode, _show, _store) \
71 .ca_name = __stringify(_name), \
73 .ca_owner = THIS_MODULE, \
79 #define __CONFIGFS_EATTR_RO(_name, _show) \
82 .ca_name = __stringify(_name), \
84 .ca_owner = THIS_MODULE, \
101 #define CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member) \
102 static struct _item *to_##_name(struct config_item *ci) \
104 return (ci) ? container_of(to_config_group(ci), struct _item, \
105 _item_member) : NULL; \
108 #define CONFIGFS_EATTR_OPS_SHOW(_name, _item) \
109 static ssize_t _name##_attr_show(struct config_item *item, \
110 struct configfs_attribute *attr, \
113 struct _item *_item = to_##_name(item); \
114 struct _name##_attribute * _name##_attr = \
115 container_of(attr, struct _name##_attribute, attr); \
118 if (_name##_attr->show) \
119 ret = _name##_attr->show(_item, page); \
123 #define CONFIGFS_EATTR_OPS_STORE(_name, _item) \
124 static ssize_t _name##_attr_store(struct config_item *item, \
125 struct configfs_attribute *attr, \
126 const char *page, size_t count) \
128 struct _item *_item = to_##_name(item); \
129 struct _name##_attribute * _name##_attr = \
130 container_of(attr, struct _name##_attribute, attr); \
131 ssize_t ret = -EINVAL; \
133 if (_name##_attr->store) \
134 ret = _name##_attr->store(_item, page, count); \
138 #define CONFIGFS_EATTR_OPS(_name, _item, _item_member) \
139 CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \
140 CONFIGFS_EATTR_OPS_SHOW(_name, _item); \
141 CONFIGFS_EATTR_OPS_STORE(_name, _item);
143 #define CONFIGFS_EATTR_OPS_RO(_name, _item, _item_member) \
144 CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \
145 CONFIGFS_EATTR_OPS_SHOW(_name, _item);