mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
[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>
This commit is contained in:
parent
dd308bc355
commit
7423172a50
2 changed files with 40 additions and 0 deletions
|
@ -80,6 +80,8 @@ extern void kobject_unregister(struct kobject *);
|
||||||
extern struct kobject * kobject_get(struct kobject *);
|
extern struct kobject * kobject_get(struct kobject *);
|
||||||
extern void kobject_put(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);
|
extern char * kobject_get_path(struct kobject *, gfp_t);
|
||||||
|
|
||||||
struct kobj_type {
|
struct kobj_type {
|
||||||
|
|
|
@ -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
|
* kset_init - initialize a kset for use
|
||||||
* @k: kset
|
* @k: kset
|
||||||
|
|
Loading…
Reference in a new issue