aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 36668c8c3ea1..25204a41a9b0 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -385,6 +385,44 @@ void kobject_put(struct kobject * kobj)
385} 385}
386 386
387 387
388static void dir_release(struct kobject *kobj)
389{
390 kfree(kobj);
391}
392
393static struct kobj_type dir_ktype = {
394 .release = dir_release,
395 .sysfs_ops = NULL,
396 .default_attrs = NULL,
397};
398
399/**
400 * kobject_add_dir - add sub directory of object.
401 * @parent: object in which a directory is created.
402 * @name: directory name.
403 *
404 * Add a plain directory object as child of given object.
405 */
406struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
407{
408 struct kobject *k;
409
410 if (!parent)
411 return NULL;
412
413 k = kzalloc(sizeof(*k), GFP_KERNEL);
414 if (!k)
415 return NULL;
416
417 k->parent = parent;
418 k->ktype = &dir_ktype;
419 kobject_set_name(k, name);
420 kobject_register(k);
421
422 return k;
423}
424EXPORT_SYMBOL_GPL(kobject_add_dir);
425
388/** 426/**
389 * kset_init - initialize a kset for use 427 * kset_init - initialize a kset for use
390 * @k: kset 428 * @k: kset