aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index d784daeb8571..2c6490370922 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -58,11 +58,6 @@ static int create_dir(struct kobject *kobj)
58 return error; 58 return error;
59} 59}
60 60
61static inline struct kobject *to_kobj(struct list_head *entry)
62{
63 return container_of(entry, struct kobject, entry);
64}
65
66static int get_kobj_path_length(struct kobject *kobj) 61static int get_kobj_path_length(struct kobject *kobj)
67{ 62{
68 int length = 1; 63 int length = 1;
@@ -153,6 +148,10 @@ static void kobject_init_internal(struct kobject *kobj)
153 return; 148 return;
154 kref_init(&kobj->kref); 149 kref_init(&kobj->kref);
155 INIT_LIST_HEAD(&kobj->entry); 150 INIT_LIST_HEAD(&kobj->entry);
151 kobj->state_in_sysfs = 0;
152 kobj->state_add_uevent_sent = 0;
153 kobj->state_remove_uevent_sent = 0;
154 kobj->state_initialized = 1;
156} 155}
157 156
158 157
@@ -289,13 +288,8 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
289 dump_stack(); 288 dump_stack();
290 } 289 }
291 290
292 kref_init(&kobj->kref); 291 kobject_init_internal(kobj);
293 INIT_LIST_HEAD(&kobj->entry);
294 kobj->ktype = ktype; 292 kobj->ktype = ktype;
295 kobj->state_in_sysfs = 0;
296 kobj->state_add_uevent_sent = 0;
297 kobj->state_remove_uevent_sent = 0;
298 kobj->state_initialized = 1;
299 return; 293 return;
300 294
301error: 295error:
@@ -593,8 +587,15 @@ static void kobject_release(struct kref *kref)
593 */ 587 */
594void kobject_put(struct kobject *kobj) 588void kobject_put(struct kobject *kobj)
595{ 589{
596 if (kobj) 590 if (kobj) {
591 if (!kobj->state_initialized) {
592 printk(KERN_WARNING "kobject: '%s' (%p): is not "
593 "initialized, yet kobject_put() is being "
594 "called.\n", kobject_name(kobj), kobj);
595 WARN_ON(1);
596 }
597 kref_put(&kobj->kref, kobject_release); 597 kref_put(&kobj->kref, kobject_release);
598 }
598} 599}
599 600
600static void dynamic_kobj_release(struct kobject *kobj) 601static void dynamic_kobj_release(struct kobject *kobj)
@@ -746,12 +747,11 @@ void kset_unregister(struct kset *k)
746 */ 747 */
747struct kobject *kset_find_obj(struct kset *kset, const char *name) 748struct kobject *kset_find_obj(struct kset *kset, const char *name)
748{ 749{
749 struct list_head *entry; 750 struct kobject *k;
750 struct kobject *ret = NULL; 751 struct kobject *ret = NULL;
751 752
752 spin_lock(&kset->list_lock); 753 spin_lock(&kset->list_lock);
753 list_for_each(entry, &kset->list) { 754 list_for_each_entry(k, &kset->list, entry) {
754 struct kobject *k = to_kobj(entry);
755 if (kobject_name(k) && !strcmp(kobject_name(k), name)) { 755 if (kobject_name(k) && !strcmp(kobject_name(k), name)) {
756 ret = kobject_get(k); 756 ret = kobject_get(k);
757 break; 757 break;