30 #include <linux/module.h>
31 #include <linux/slab.h>
61 #define CHILDLESS_ATTR(_name, _mode, _show, _store) \
62 struct childless_attribute childless_attr_##_name = __CONFIGFS_ATTR(_name, _mode, _show, _store)
63 #define CHILDLESS_ATTR_RO(_name, _show) \
64 struct childless_attribute childless_attr_##_name = __CONFIGFS_ATTR_RO(_name, _show);
88 char *
p = (
char *) page;
91 if (!p || (*p && (*p !=
'\n')))
102 static ssize_t childless_description_read(
struct childless *childless,
108 "The childless subsystem is the simplest possible subsystem in\n"
109 "configfs. It does not support the creation of child config_items.\n"
110 "It only has a few attributes. In fact, it isn't much different\n"
111 "than a directory in /proc.\n");
116 childless_storeme_write);
120 &childless_attr_showme.attr,
121 &childless_attr_storeme.attr,
122 &childless_attr_description.attr,
128 .show_attribute = childless_attr_show,
129 .store_attribute = childless_attr_store,
133 .ct_item_ops = &childless_item_ops,
134 .ct_attrs = childless_attrs,
138 static struct childless childless_subsys = {
142 .ci_namebuf =
"01-childless",
143 .ci_type = &childless_type,
173 .ca_name =
"storeme",
178 &simple_child_attr_storeme,
196 const char *page,
size_t count)
200 char *p = (
char *) page;
203 if (!p || (*p && (*p !=
'\n')))
214 static void simple_child_release(
struct config_item *item)
216 kfree(to_simple_child(item));
220 .release = simple_child_release,
221 .show_attribute = simple_child_attr_show,
222 .store_attribute = simple_child_attr_store,
226 .ct_item_ops = &simple_child_item_ops,
227 .ct_attrs = simple_child_attrs,
243 struct simple_child *simple_child;
245 simple_child = kzalloc(
sizeof(
struct simple_child),
GFP_KERNEL);
254 return &simple_child->
item;
259 .ca_name =
"description",
264 &simple_children_attr_description,
273 "[02-simple-children]\n"
275 "This subsystem allows the creation of child config_items. These\n"
276 "items have only one attribute that is readable and writeable.\n");
279 static void simple_children_release(
struct config_item *item)
281 kfree(to_simple_children(item));
285 .release = simple_children_release,
286 .show_attribute = simple_children_attr_show,
294 .make_item = simple_children_make_item,
298 .ct_item_ops = &simple_children_item_ops,
299 .ct_group_ops = &simple_children_group_ops,
300 .ct_attrs = simple_children_attrs,
307 .ci_namebuf =
"02-simple-children",
308 .ci_type = &simple_children_type,
330 simple_children = kzalloc(
sizeof(
struct simple_children),
332 if (!simple_children)
336 &simple_children_type);
338 return &simple_children->
group;
343 .ca_name =
"description",
348 &group_children_attr_description,
357 "[03-group-children]\n"
359 "This subsystem allows the creation of child config_groups. These\n"
360 "groups are like the subsystem simple-children.\n");
364 .show_attribute = group_children_attr_show,
372 .make_group = group_children_make_group,
376 .ct_item_ops = &group_children_item_ops,
377 .ct_group_ops = &group_children_group_ops,
378 .ct_attrs = group_children_attrs,
385 .ci_namebuf =
"03-group-children",
386 .ci_type = &group_children_type,
402 &simple_children_subsys,
403 &group_children_subsys,
407 static int __init configfs_example_init(
void)
413 for (i = 0; example_subsys[
i]; i++) {
414 subsys = example_subsys[
i];
422 subsys->
su_group.cg_item.ci_namebuf);
430 for (i--; i >= 0; i--)
436 static void __exit configfs_example_exit(
void)
440 for (i = 0; example_subsys[
i]; i++)