These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / include / linux / configfs.h
index 34025df..758a029 100644 (file)
@@ -64,14 +64,14 @@ struct config_item {
        struct dentry           *ci_dentry;
 };
 
-extern int config_item_set_name(struct config_item *, const char *, ...);
+extern __printf(2, 3)
+int config_item_set_name(struct config_item *, const char *, ...);
 
 static inline char *config_item_name(struct config_item * item)
 {
        return item->ci_name;
 }
 
-extern void config_item_init(struct config_item *);
 extern void config_item_init_type_name(struct config_item *item,
                                       const char *name,
                                       struct config_item_type *type);
@@ -125,86 +125,33 @@ struct configfs_attribute {
        const char              *ca_name;
        struct module           *ca_owner;
        umode_t                 ca_mode;
+       ssize_t (*show)(struct config_item *, char *);
+       ssize_t (*store)(struct config_item *, const char *, size_t);
 };
 
-/*
- * 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. If they don't
- * need anything else on the extended attribute structure, they can use
- * this macro to define it  The argument _item is the name of the
- * config_item structure.
- */
-#define CONFIGFS_ATTR_STRUCT(_item)                                    \
-struct _item##_attribute {                                             \
-       struct configfs_attribute attr;                                 \
-       ssize_t (*show)(struct _item *, char *);                        \
-       ssize_t (*store)(struct _item *, const char *, size_t);         \
+#define CONFIGFS_ATTR(_pfx, _name)                     \
+static struct configfs_attribute _pfx##attr_##_name = {        \
+       .ca_name        = __stringify(_name),           \
+       .ca_mode        = S_IRUGO | S_IWUSR,            \
+       .ca_owner       = THIS_MODULE,                  \
+       .show           = _pfx##_name##_show,           \
+       .store          = _pfx##_name##_store,          \
 }
 
-/*
- * With the extended attribute structure, users can use this macro
- * (similar to sysfs' __ATTR) to make defining attributes easier.
- * An example:
- * #define MYITEM_ATTR(_name, _mode, _show, _store)    \
- * struct myitem_attribute childless_attr_##_name =    \
- *         __CONFIGFS_ATTR(_name, _mode, _show, _store)
- */
-#define __CONFIGFS_ATTR(_name, _mode, _show, _store)                   \
-{                                                                      \
-       .attr   = {                                                     \
-                       .ca_name = __stringify(_name),                  \
-                       .ca_mode = _mode,                               \
-                       .ca_owner = THIS_MODULE,                        \
-       },                                                              \
-       .show   = _show,                                                \
-       .store  = _store,                                               \
-}
-/* Here is a readonly version, only requiring a show() operation */
-#define __CONFIGFS_ATTR_RO(_name, _show)                               \
-{                                                                      \
-       .attr   = {                                                     \
-                       .ca_name = __stringify(_name),                  \
-                       .ca_mode = 0444,                                \
-                       .ca_owner = THIS_MODULE,                        \
-       },                                                              \
-       .show   = _show,                                                \
+#define CONFIGFS_ATTR_RO(_pfx, _name)                  \
+static struct configfs_attribute _pfx##attr_##_name = {        \
+       .ca_name        = __stringify(_name),           \
+       .ca_mode        = S_IRUGO,                      \
+       .ca_owner       = THIS_MODULE,                  \
+       .show           = _pfx##_name##_show,           \
 }
 
-/*
- * With these extended attributes, the simple show_attribute() and
- * store_attribute() operations need to call the show() and store() of the
- * attributes.  This is a common pattern, so we provide a macro to define
- * them.  The argument _item is the name of the config_item structure.
- * This macro expects the attributes to be named "struct <name>_attribute"
- * and the function to_<name>() to exist;
- */
-#define CONFIGFS_ATTR_OPS(_item)                                       \
-static ssize_t _item##_attr_show(struct config_item *item,             \
-                                struct configfs_attribute *attr,       \
-                                char *page)                            \
-{                                                                      \
-       struct _item *_item = to_##_item(item);                         \
-       struct _item##_attribute *_item##_attr =                        \
-               container_of(attr, struct _item##_attribute, attr);     \
-       ssize_t ret = 0;                                                \
-                                                                       \
-       if (_item##_attr->show)                                         \
-               ret = _item##_attr->show(_item, page);                  \
-       return ret;                                                     \
-}                                                                      \
-static ssize_t _item##_attr_store(struct config_item *item,            \
-                                 struct configfs_attribute *attr,      \
-                                 const char *page, size_t count)       \
-{                                                                      \
-       struct _item *_item = to_##_item(item);                         \
-       struct _item##_attribute *_item##_attr =                        \
-               container_of(attr, struct _item##_attribute, attr);     \
-       ssize_t ret = -EINVAL;                                          \
-                                                                       \
-       if (_item##_attr->store)                                        \
-               ret = _item##_attr->store(_item, page, count);          \
-       return ret;                                                     \
+#define CONFIGFS_ATTR_WO(_pfx, _name)                  \
+static struct configfs_attribute _pfx##attr_##_name = {        \
+       .ca_name        = __stringify(_name),           \
+       .ca_mode        = S_IWUSR,                      \
+       .ca_owner       = THIS_MODULE,                  \
+       .store          = _pfx##_name##_store,          \
 }
 
 /*
@@ -223,8 +170,6 @@ static ssize_t _item##_attr_store(struct config_item *item,         \
  */
 struct configfs_item_operations {
        void (*release)(struct config_item *);
-       ssize_t (*show_attribute)(struct config_item *, struct configfs_attribute *,char *);
-       ssize_t (*store_attribute)(struct config_item *,struct configfs_attribute *,const char *, size_t);
        int (*allow_link)(struct config_item *src, struct config_item *target);
        int (*drop_link)(struct config_item *src, struct config_item *target);
 };
@@ -252,6 +197,16 @@ static inline struct configfs_subsystem *to_configfs_subsystem(struct config_gro
 int configfs_register_subsystem(struct configfs_subsystem *subsys);
 void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
 
+int configfs_register_group(struct config_group *parent_group,
+                           struct config_group *group);
+void configfs_unregister_group(struct config_group *group);
+
+struct config_group *
+configfs_register_default_group(struct config_group *parent_group,
+                               const char *name,
+                               struct config_item_type *item_type);
+void configfs_unregister_default_group(struct config_group *group);
+
 /* These functions can sleep and can alloc with GFP_KERNEL */
 /* WARNING: These cannot be called underneath configfs callbacks!! */
 int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target);