[PATCH] configfs+dlm: Separate out __CONFIGFS_ATTR into configfs.h
[cascardo/linux.git] / include / linux / configfs.h
index 3d4a96e..def7c83 100644 (file)
@@ -130,6 +130,22 @@ struct configfs_attribute {
        mode_t                  ca_mode;
 };
 
+/*
+ * Users often need to create attribute structures for their configurable
+ * attributes, containing a configfs_attribute member and function pointers
+ * for the show() and store() operations on that attribute. They can use
+ * this macro (similar to sysfs' __ATTR) to make defining attributes easier.
+ */
+#define __CONFIGFS_ATTR(_name, _mode, _show, _store)                   \
+{                                                                      \
+       .attr   = {                                                     \
+                       .ca_name = __stringify(_name),                  \
+                       .ca_mode = _mode,                               \
+                       .ca_owner = THIS_MODULE,                        \
+       },                                                              \
+       .show   = _show,                                                \
+       .store  = _store,                                               \
+}
 
 /*
  * If allow_link() exists, the item can symlink(2) out to other