diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-12-19 20:09:39 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:40 -0500 |
commit | af5ca3f4ec5cc4432a42a73b050dd8898ce8fd00 (patch) | |
tree | 3e5a3081b2802547f10da72c0026b4929d0e287b /lib | |
parent | 528a4bf1d5ffed310d26fc1d82d45c02949f71cf (diff) |
Driver core: change sysdev classes to use dynamic kobject names
All kobjects require a dynamically allocated name now. We no longer
need to keep track if the name is statically assigned, we can just
unconditionally free() all kobject names on cleanup.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 14 |
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) | |||
551 | static void kobject_cleanup(struct kobject *kobj) | 548 | static 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 | } |