aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index a0773734545c..8dc32454661d 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -165,7 +165,7 @@ static int kobject_add_internal(struct kobject *kobj)
165 if (!kobj) 165 if (!kobj)
166 return -ENOENT; 166 return -ENOENT;
167 167
168 if (!kobj->k_name || !kobj->k_name[0]) { 168 if (!kobj->name || !kobj->name[0]) {
169 pr_debug("kobject: (%p): attempted to be registered with empty " 169 pr_debug("kobject: (%p): attempted to be registered with empty "
170 "name!\n", kobj); 170 "name!\n", kobj);
171 WARN_ON(1); 171 WARN_ON(1);
@@ -228,13 +228,11 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
228 if (!name) 228 if (!name)
229 return -ENOMEM; 229 return -ENOMEM;
230 230
231
232 /* Free the old name, if necessary. */ 231 /* Free the old name, if necessary. */
233 kfree(kobj->k_name); 232 kfree(kobj->name);
234 233
235 /* Now, set the new name */ 234 /* Now, set the new name */
236 kobj->k_name = name; 235 kobj->name = name;
237 kobj->state_name_set = 1;
238 236
239 return 0; 237 return 0;
240} 238}
@@ -295,7 +293,6 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
295 kref_init(&kobj->kref); 293 kref_init(&kobj->kref);
296 INIT_LIST_HEAD(&kobj->entry); 294 INIT_LIST_HEAD(&kobj->entry);
297 kobj->ktype = ktype; 295 kobj->ktype = ktype;
298 kobj->state_name_set = 0;
299 kobj->state_in_sysfs = 0; 296 kobj->state_in_sysfs = 0;
300 kobj->state_add_uevent_sent = 0; 297 kobj->state_add_uevent_sent = 0;
301 kobj->state_remove_uevent_sent = 0; 298 kobj->state_remove_uevent_sent = 0;
@@ -551,8 +548,7 @@ struct kobject * kobject_get(struct kobject * kobj)
551static void kobject_cleanup(struct kobject *kobj) 548static void kobject_cleanup(struct kobject *kobj)
552{ 549{
553 struct kobj_type *t = get_ktype(kobj); 550 struct kobj_type *t = get_ktype(kobj);
554 const char *name = kobj->k_name; 551 const char *name = kobj->name;
555 int name_set = kobj->state_name_set;
556 552
557 pr_debug("kobject: '%s' (%p): %s\n", 553 pr_debug("kobject: '%s' (%p): %s\n",
558 kobject_name(kobj), kobj, __FUNCTION__); 554 kobject_name(kobj), kobj, __FUNCTION__);
@@ -583,7 +579,7 @@ static void kobject_cleanup(struct kobject *kobj)
583 } 579 }
584 580
585 /* free name if we allocated it */ 581 /* free name if we allocated it */
586 if (name_set && name) { 582 if (name) {
587 pr_debug("kobject: '%s': free name\n", name); 583 pr_debug("kobject: '%s': free name\n", name);
588 kfree(name); 584 kfree(name);
589 } 585 }