diff options
author | Jun'ichi Nomura <j-nomura@ce.jp.nec.com> | 2006-03-13 17:14:25 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-20 16:42:59 -0500 |
commit | 7423172a50968de1905a61413c52bb070a62f5ce (patch) | |
tree | 296c5584a6a78336664436123bf21bd052c04f0c /lib/kobject.c | |
parent | dd308bc355a1aa4f202fe9a3133b6c676cb9606c (diff) |
[PATCH] kobject_add_dir
Adding kobject_add_dir() function which creates a subdirectory
for a given kobject.
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r-- | lib/kobject.c | 38 |
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 | ||
388 | static void dir_release(struct kobject *kobj) | ||
389 | { | ||
390 | kfree(kobj); | ||
391 | } | ||
392 | |||
393 | static 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 | */ | ||
406 | struct 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 | } | ||
424 | EXPORT_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 |