diff options
Diffstat (limited to 'include/linux/configfs.h')
| -rw-r--r-- | include/linux/configfs.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/include/linux/configfs.h b/include/linux/configfs.h index fef6f3d0a4a7..8c6967f3fb11 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h | |||
| @@ -40,9 +40,9 @@ | |||
| 40 | #include <linux/types.h> | 40 | #include <linux/types.h> |
| 41 | #include <linux/list.h> | 41 | #include <linux/list.h> |
| 42 | #include <linux/kref.h> | 42 | #include <linux/kref.h> |
| 43 | #include <linux/mutex.h> | ||
| 43 | 44 | ||
| 44 | #include <asm/atomic.h> | 45 | #include <asm/atomic.h> |
| 45 | #include <asm/semaphore.h> | ||
| 46 | 46 | ||
| 47 | #define CONFIGFS_ITEM_NAME_LEN 20 | 47 | #define CONFIGFS_ITEM_NAME_LEN 20 |
| 48 | 48 | ||
| @@ -75,7 +75,6 @@ extern void config_item_init(struct config_item *); | |||
| 75 | extern void config_item_init_type_name(struct config_item *item, | 75 | extern void config_item_init_type_name(struct config_item *item, |
| 76 | const char *name, | 76 | const char *name, |
| 77 | struct config_item_type *type); | 77 | struct config_item_type *type); |
| 78 | extern void config_item_cleanup(struct config_item *); | ||
| 79 | 78 | ||
| 80 | extern struct config_item * config_item_get(struct config_item *); | 79 | extern struct config_item * config_item_get(struct config_item *); |
| 81 | extern void config_item_put(struct config_item *); | 80 | extern void config_item_put(struct config_item *); |
| @@ -87,12 +86,10 @@ struct config_item_type { | |||
| 87 | struct configfs_attribute **ct_attrs; | 86 | struct configfs_attribute **ct_attrs; |
| 88 | }; | 87 | }; |
| 89 | 88 | ||
| 90 | |||
| 91 | /** | 89 | /** |
| 92 | * group - a group of config_items of a specific type, belonging | 90 | * group - a group of config_items of a specific type, belonging |
| 93 | * to a specific subsystem. | 91 | * to a specific subsystem. |
| 94 | */ | 92 | */ |
| 95 | |||
| 96 | struct config_group { | 93 | struct config_group { |
| 97 | struct config_item cg_item; | 94 | struct config_item cg_item; |
| 98 | struct list_head cg_children; | 95 | struct list_head cg_children; |
| @@ -100,13 +97,11 @@ struct config_group { | |||
| 100 | struct config_group **default_groups; | 97 | struct config_group **default_groups; |
| 101 | }; | 98 | }; |
| 102 | 99 | ||
| 103 | |||
| 104 | extern void config_group_init(struct config_group *group); | 100 | extern void config_group_init(struct config_group *group); |
| 105 | extern void config_group_init_type_name(struct config_group *group, | 101 | extern void config_group_init_type_name(struct config_group *group, |
| 106 | const char *name, | 102 | const char *name, |
| 107 | struct config_item_type *type); | 103 | struct config_item_type *type); |
| 108 | 104 | ||
| 109 | |||
| 110 | static inline struct config_group *to_config_group(struct config_item *item) | 105 | static inline struct config_group *to_config_group(struct config_item *item) |
| 111 | { | 106 | { |
| 112 | return item ? container_of(item,struct config_group,cg_item) : NULL; | 107 | return item ? container_of(item,struct config_group,cg_item) : NULL; |
| @@ -122,7 +117,8 @@ static inline void config_group_put(struct config_group *group) | |||
| 122 | config_item_put(&group->cg_item); | 117 | config_item_put(&group->cg_item); |
| 123 | } | 118 | } |
| 124 | 119 | ||
| 125 | extern struct config_item *config_group_find_obj(struct config_group *, const char *); | 120 | extern struct config_item *config_group_find_item(struct config_group *, |
| 121 | const char *); | ||
| 126 | 122 | ||
| 127 | 123 | ||
| 128 | struct configfs_attribute { | 124 | struct configfs_attribute { |
| @@ -131,6 +127,22 @@ struct configfs_attribute { | |||
| 131 | mode_t ca_mode; | 127 | mode_t ca_mode; |
| 132 | }; | 128 | }; |
| 133 | 129 | ||
| 130 | /* | ||
| 131 | * Users often need to create attribute structures for their configurable | ||
| 132 | * attributes, containing a configfs_attribute member and function pointers | ||
| 133 | * for the show() and store() operations on that attribute. They can use | ||
| 134 | * this macro (similar to sysfs' __ATTR) to make defining attributes easier. | ||
| 135 | */ | ||
| 136 | #define __CONFIGFS_ATTR(_name, _mode, _show, _store) \ | ||
| 137 | { \ | ||
| 138 | .attr = { \ | ||
| 139 | .ca_name = __stringify(_name), \ | ||
| 140 | .ca_mode = _mode, \ | ||
| 141 | .ca_owner = THIS_MODULE, \ | ||
| 142 | }, \ | ||
| 143 | .show = _show, \ | ||
| 144 | .store = _store, \ | ||
| 145 | } | ||
| 134 | 146 | ||
| 135 | /* | 147 | /* |
| 136 | * If allow_link() exists, the item can symlink(2) out to other | 148 | * If allow_link() exists, the item can symlink(2) out to other |
| @@ -157,12 +169,13 @@ struct configfs_group_operations { | |||
| 157 | struct config_item *(*make_item)(struct config_group *group, const char *name); | 169 | struct config_item *(*make_item)(struct config_group *group, const char *name); |
| 158 | struct config_group *(*make_group)(struct config_group *group, const char *name); | 170 | struct config_group *(*make_group)(struct config_group *group, const char *name); |
| 159 | int (*commit_item)(struct config_item *item); | 171 | int (*commit_item)(struct config_item *item); |
| 172 | void (*disconnect_notify)(struct config_group *group, struct config_item *item); | ||
| 160 | void (*drop_item)(struct config_group *group, struct config_item *item); | 173 | void (*drop_item)(struct config_group *group, struct config_item *item); |
| 161 | }; | 174 | }; |
| 162 | 175 | ||
| 163 | struct configfs_subsystem { | 176 | struct configfs_subsystem { |
| 164 | struct config_group su_group; | 177 | struct config_group su_group; |
| 165 | struct semaphore su_sem; | 178 | struct mutex su_mutex; |
| 166 | }; | 179 | }; |
| 167 | 180 | ||
| 168 | static inline struct configfs_subsystem *to_configfs_subsystem(struct config_group *group) | 181 | static inline struct configfs_subsystem *to_configfs_subsystem(struct config_group *group) |
| @@ -175,6 +188,11 @@ static inline struct configfs_subsystem *to_configfs_subsystem(struct config_gro | |||
| 175 | int configfs_register_subsystem(struct configfs_subsystem *subsys); | 188 | int configfs_register_subsystem(struct configfs_subsystem *subsys); |
| 176 | void configfs_unregister_subsystem(struct configfs_subsystem *subsys); | 189 | void configfs_unregister_subsystem(struct configfs_subsystem *subsys); |
| 177 | 190 | ||
| 191 | /* These functions can sleep and can alloc with GFP_KERNEL */ | ||
| 192 | /* WARNING: These cannot be called underneath configfs callbacks!! */ | ||
| 193 | int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target); | ||
| 194 | void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target); | ||
| 195 | |||
| 178 | #endif /* __KERNEL__ */ | 196 | #endif /* __KERNEL__ */ |
| 179 | 197 | ||
| 180 | #endif /* _CONFIGFS_H_ */ | 198 | #endif /* _CONFIGFS_H_ */ |
