Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22014
b: refs/heads/master
c: 7423172
h: refs/heads/master
v: v3
  • Loading branch information
Jun'ichi Nomura authored and Greg Kroah-Hartman committed Mar 20, 2006
1 parent 520d916 commit 65a2746
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dd308bc355a1aa4f202fe9a3133b6c676cb9606c
refs/heads/master: 7423172a50968de1905a61413c52bb070a62f5ce
2 changes: 2 additions & 0 deletions trunk/include/linux/kobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ extern void kobject_unregister(struct kobject *);
extern struct kobject * kobject_get(struct kobject *);
extern void kobject_put(struct kobject *);

extern struct kobject *kobject_add_dir(struct kobject *, const char *);

extern char * kobject_get_path(struct kobject *, gfp_t);

struct kobj_type {
Expand Down
38 changes: 38 additions & 0 deletions trunk/lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,44 @@ void kobject_put(struct kobject * kobj)
}


static void dir_release(struct kobject *kobj)
{
kfree(kobj);
}

static struct kobj_type dir_ktype = {
.release = dir_release,
.sysfs_ops = NULL,
.default_attrs = NULL,
};

/**
* kobject_add_dir - add sub directory of object.
* @parent: object in which a directory is created.
* @name: directory name.
*
* Add a plain directory object as child of given object.
*/
struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
{
struct kobject *k;

if (!parent)
return NULL;

k = kzalloc(sizeof(*k), GFP_KERNEL);
if (!k)
return NULL;

k->parent = parent;
k->ktype = &dir_ktype;
kobject_set_name(k, name);
kobject_register(k);

return k;
}
EXPORT_SYMBOL_GPL(kobject_add_dir);

/**
* kset_init - initialize a kset for use
* @k: kset
Expand Down

0 comments on commit 65a2746

Please sign in to comment.