summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-12-20 02:09:39 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 20:40:40 -0800
commitaf5ca3f4ec5cc4432a42a73b050dd8898ce8fd00 (patch)
tree3e5a3081b2802547f10da72c0026b4929d0e287b /lib
parent528a4bf1d5ffed310d26fc1d82d45c02949f71cf (diff)
downloadblackbird-op-linux-af5ca3f4ec5cc4432a42a73b050dd8898ce8fd00.tar.gz
blackbird-op-linux-af5ca3f4ec5cc4432a42a73b050dd8898ce8fd00.zip
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.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)
if (!kobj)
return -ENOENT;
- if (!kobj->k_name || !kobj->k_name[0]) {
+ if (!kobj->name || !kobj->name[0]) {
pr_debug("kobject: (%p): attempted to be registered with empty "
"name!\n", kobj);
WARN_ON(1);
@@ -228,13 +228,11 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
if (!name)
return -ENOMEM;
-
/* Free the old name, if necessary. */
- kfree(kobj->k_name);
+ kfree(kobj->name);
/* Now, set the new name */
- kobj->k_name = name;
- kobj->state_name_set = 1;
+ kobj->name = name;
return 0;
}
@@ -295,7 +293,6 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype)
kref_init(&kobj->kref);
INIT_LIST_HEAD(&kobj->entry);
kobj->ktype = ktype;
- kobj->state_name_set = 0;
kobj->state_in_sysfs = 0;
kobj->state_add_uevent_sent = 0;
kobj->state_remove_uevent_sent = 0;
@@ -551,8 +548,7 @@ struct kobject * kobject_get(struct kobject * kobj)
static void kobject_cleanup(struct kobject *kobj)
{
struct kobj_type *t = get_ktype(kobj);
- const char *name = kobj->k_name;
- int name_set = kobj->state_name_set;
+ const char *name = kobj->name;
pr_debug("kobject: '%s' (%p): %s\n",
kobject_name(kobj), kobj, __FUNCTION__);
@@ -583,7 +579,7 @@ static void kobject_cleanup(struct kobject *kobj)
}
/* free name if we allocated it */
- if (name_set && name) {
+ if (name) {
pr_debug("kobject: '%s': free name\n", name);
kfree(name);
}
OpenPOWER on IntegriCloud