diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-11-06 01:24:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:11 -0500 |
commit | 43968d2f1648f4dc92437dc0363a3e88377445b3 (patch) | |
tree | c9ba656e289bbbb5d5de32abc4181ae1d65dee00 | |
parent | 4ff6abff832fbc6cb1d769f6106c841bc2b09f63 (diff) |
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: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/base/core.c | 16 | ||||
-rw-r--r-- | include/linux/kobject.h | 4 | ||||
-rw-r--r-- | lib/kobject.c | 37 |
3 files changed, 20 insertions, 37 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 992eba3289bd..7762ee86697d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -571,6 +571,8 @@ static struct kobject *virtual_device_parent(struct device *dev) | |||
571 | static struct kobject * get_device_parent(struct device *dev, | 571 | static struct kobject * get_device_parent(struct device *dev, |
572 | struct device *parent) | 572 | struct device *parent) |
573 | { | 573 | { |
574 | int retval; | ||
575 | |||
574 | if (dev->class) { | 576 | if (dev->class) { |
575 | struct kobject *kobj = NULL; | 577 | struct kobject *kobj = NULL; |
576 | struct kobject *parent_kobj; | 578 | struct kobject *parent_kobj; |
@@ -600,8 +602,18 @@ static struct kobject * get_device_parent(struct device *dev, | |||
600 | return kobj; | 602 | return kobj; |
601 | 603 | ||
602 | /* or create a new class-directory at the parent device */ | 604 | /* or create a new class-directory at the parent device */ |
603 | return kobject_kset_add_dir(&dev->class->class_dirs, | 605 | k = kobject_create(); |
604 | parent_kobj, dev->class->name); | 606 | if (!k) |
607 | return NULL; | ||
608 | k->kset = &dev->class->class_dirs; | ||
609 | retval = kobject_add_ng(k, parent_kobj, "%s", dev->class->name); | ||
610 | if (retval < 0) { | ||
611 | kobject_put(k); | ||
612 | return NULL; | ||
613 | } | ||
614 | /* Do not emit a uevent, as it's not needed for this | ||
615 | * "class glue" directory. */ | ||
616 | return k; | ||
605 | } | 617 | } |
606 | 618 | ||
607 | if (parent) | 619 | if (parent) |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 7b09136fb211..718b48811288 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -91,6 +91,7 @@ extern int __must_check kobject_init_and_add(struct kobject *kobj, | |||
91 | 91 | ||
92 | extern void kobject_del(struct kobject *); | 92 | extern void kobject_del(struct kobject *); |
93 | 93 | ||
94 | extern struct kobject * __must_check kobject_create(void); | ||
94 | extern struct kobject * __must_check kobject_create_and_add(const char *name, | 95 | extern struct kobject * __must_check kobject_create_and_add(const char *name, |
95 | struct kobject *parent); | 96 | struct kobject *parent); |
96 | 97 | ||
@@ -103,9 +104,6 @@ extern void kobject_unregister(struct kobject *); | |||
103 | extern struct kobject * kobject_get(struct kobject *); | 104 | extern struct kobject * kobject_get(struct kobject *); |
104 | extern void kobject_put(struct kobject *); | 105 | extern void kobject_put(struct kobject *); |
105 | 106 | ||
106 | extern struct kobject *kobject_kset_add_dir(struct kset *kset, | ||
107 | struct kobject *, const char *); | ||
108 | |||
109 | extern char * kobject_get_path(struct kobject *, gfp_t); | 107 | extern char * kobject_get_path(struct kobject *, gfp_t); |
110 | 108 | ||
111 | struct kobj_type { | 109 | struct kobj_type { |
diff --git a/lib/kobject.c b/lib/kobject.c index 96b61d9a9284..67c3d38d48f0 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -629,15 +629,18 @@ static struct kobj_type dynamic_kobj_ktype = { | |||
629 | .release = dynamic_kobj_release, | 629 | .release = dynamic_kobj_release, |
630 | }; | 630 | }; |
631 | 631 | ||
632 | /* | 632 | /** |
633 | * kobject_create - create a struct kobject dynamically | 633 | * kobject_create - create a struct kobject dynamically |
634 | * | 634 | * |
635 | * This function creates a kobject structure dynamically and sets it up | 635 | * This function creates a kobject structure dynamically and sets it up |
636 | * to be a "dynamic" kobject with a default release function set up. | 636 | * to be a "dynamic" kobject with a default release function set up. |
637 | * | 637 | * |
638 | * If the kobject was not able to be created, NULL will be returned. | 638 | * If the kobject was not able to be created, NULL will be returned. |
639 | * The kobject structure returned from here must be cleaned up with a | ||
640 | * call to kobject_put() and not kfree(), as kobject_init_ng() has | ||
641 | * already been called on this structure. | ||
639 | */ | 642 | */ |
640 | static struct kobject *kobject_create(void) | 643 | struct kobject *kobject_create(void) |
641 | { | 644 | { |
642 | struct kobject *kobj; | 645 | struct kobject *kobj; |
643 | 646 | ||
@@ -683,36 +686,6 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent) | |||
683 | EXPORT_SYMBOL_GPL(kobject_create_and_add); | 686 | EXPORT_SYMBOL_GPL(kobject_create_and_add); |
684 | 687 | ||
685 | /** | 688 | /** |
686 | * kobject_kset_add_dir - add sub directory of object. | ||
687 | * @kset: kset the directory is belongs to. | ||
688 | * @parent: object in which a directory is created. | ||
689 | * @name: directory name. | ||
690 | * | ||
691 | * Add a plain directory object as child of given object. | ||
692 | */ | ||
693 | struct kobject *kobject_kset_add_dir(struct kset *kset, | ||
694 | struct kobject *parent, const char *name) | ||
695 | { | ||
696 | struct kobject *k; | ||
697 | int ret; | ||
698 | |||
699 | k = kobject_create(); | ||
700 | if (!k) | ||
701 | return NULL; | ||
702 | |||
703 | k->kset = kset; | ||
704 | ret = kobject_add_ng(k, parent, "%s", name); | ||
705 | if (ret < 0) { | ||
706 | printk(KERN_WARNING "%s: kobject_add error: %d\n", | ||
707 | __func__, ret); | ||
708 | kobject_put(k); | ||
709 | k = NULL; | ||
710 | } | ||
711 | |||
712 | return k; | ||
713 | } | ||
714 | |||
715 | /** | ||
716 | * kset_init - initialize a kset for use | 689 | * kset_init - initialize a kset for use |
717 | * @k: kset | 690 | * @k: kset |
718 | */ | 691 | */ |