提交 43968d2f 编写于 作者: G Greg Kroah-Hartman

kobject: get rid of kobject_kset_add_dir

kobject_kset_add_dir is only called in one place so remove it and use
kobject_create() instead.

Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 4ff6abff
...@@ -571,6 +571,8 @@ static struct kobject *virtual_device_parent(struct device *dev) ...@@ -571,6 +571,8 @@ static struct kobject *virtual_device_parent(struct device *dev)
static struct kobject * get_device_parent(struct device *dev, static struct kobject * get_device_parent(struct device *dev,
struct device *parent) struct device *parent)
{ {
int retval;
if (dev->class) { if (dev->class) {
struct kobject *kobj = NULL; struct kobject *kobj = NULL;
struct kobject *parent_kobj; struct kobject *parent_kobj;
...@@ -600,8 +602,18 @@ static struct kobject * get_device_parent(struct device *dev, ...@@ -600,8 +602,18 @@ static struct kobject * get_device_parent(struct device *dev,
return kobj; return kobj;
/* or create a new class-directory at the parent device */ /* or create a new class-directory at the parent device */
return kobject_kset_add_dir(&dev->class->class_dirs, k = kobject_create();
parent_kobj, dev->class->name); if (!k)
return NULL;
k->kset = &dev->class->class_dirs;
retval = kobject_add_ng(k, parent_kobj, "%s", dev->class->name);
if (retval < 0) {
kobject_put(k);
return NULL;
}
/* Do not emit a uevent, as it's not needed for this
* "class glue" directory. */
return k;
} }
if (parent) if (parent)
......
...@@ -91,6 +91,7 @@ extern int __must_check kobject_init_and_add(struct kobject *kobj, ...@@ -91,6 +91,7 @@ extern int __must_check kobject_init_and_add(struct kobject *kobj,
extern void kobject_del(struct kobject *); extern void kobject_del(struct kobject *);
extern struct kobject * __must_check kobject_create(void);
extern struct kobject * __must_check kobject_create_and_add(const char *name, extern struct kobject * __must_check kobject_create_and_add(const char *name,
struct kobject *parent); struct kobject *parent);
...@@ -103,9 +104,6 @@ extern void kobject_unregister(struct kobject *); ...@@ -103,9 +104,6 @@ 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_kset_add_dir(struct kset *kset,
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 {
......
...@@ -629,15 +629,18 @@ static struct kobj_type dynamic_kobj_ktype = { ...@@ -629,15 +629,18 @@ static struct kobj_type dynamic_kobj_ktype = {
.release = dynamic_kobj_release, .release = dynamic_kobj_release,
}; };
/* /**
* kobject_create - create a struct kobject dynamically * kobject_create - create a struct kobject dynamically
* *
* This function creates a kobject structure dynamically and sets it up * This function creates a kobject structure dynamically and sets it up
* to be a "dynamic" kobject with a default release function set up. * to be a "dynamic" kobject with a default release function set up.
* *
* If the kobject was not able to be created, NULL will be returned. * If the kobject was not able to be created, NULL will be returned.
* The kobject structure returned from here must be cleaned up with a
* call to kobject_put() and not kfree(), as kobject_init_ng() has
* already been called on this structure.
*/ */
static struct kobject *kobject_create(void) struct kobject *kobject_create(void)
{ {
struct kobject *kobj; struct kobject *kobj;
...@@ -682,36 +685,6 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent) ...@@ -682,36 +685,6 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
} }
EXPORT_SYMBOL_GPL(kobject_create_and_add); EXPORT_SYMBOL_GPL(kobject_create_and_add);
/**
* kobject_kset_add_dir - add sub directory of object.
* @kset: kset the directory is belongs to.
* @parent: object in which a directory is created.
* @name: directory name.
*
* Add a plain directory object as child of given object.
*/
struct kobject *kobject_kset_add_dir(struct kset *kset,
struct kobject *parent, const char *name)
{
struct kobject *k;
int ret;
k = kobject_create();
if (!k)
return NULL;
k->kset = kset;
ret = kobject_add_ng(k, parent, "%s", name);
if (ret < 0) {
printk(KERN_WARNING "%s: kobject_add error: %d\n",
__func__, ret);
kobject_put(k);
k = NULL;
}
return k;
}
/** /**
* kset_init - initialize a kset for use * kset_init - initialize a kset for use
* @k: kset * @k: kset
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册