aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2008-05-06 13:55:32 -0400
committerSteve French <sfrench@us.ibm.com>2008-05-06 13:55:32 -0400
commita815752ac0ffdb910e92958d41d28f4fb28e5296 (patch)
treea3aa16a282354da0debe8e3a3a7ed8aac6e54001 /lib/kobject.c
parent5ade9deaaa3e1f7291467d97b238648e43eae15e (diff)
parenta15306365a16380f3bafee9e181ba01231d4acd7 (diff)
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 2c649037092..718e5101c26 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -90,7 +90,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
90 } 90 }
91 91
92 pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj), 92 pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
93 kobj, __FUNCTION__, path); 93 kobj, __func__, path);
94} 94}
95 95
96/** 96/**
@@ -181,7 +181,7 @@ static int kobject_add_internal(struct kobject *kobj)
181 } 181 }
182 182
183 pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", 183 pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n",
184 kobject_name(kobj), kobj, __FUNCTION__, 184 kobject_name(kobj), kobj, __func__,
185 parent ? kobject_name(parent) : "<NULL>", 185 parent ? kobject_name(parent) : "<NULL>",
186 kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>"); 186 kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>");
187 187
@@ -196,10 +196,10 @@ static int kobject_add_internal(struct kobject *kobj)
196 printk(KERN_ERR "%s failed for %s with " 196 printk(KERN_ERR "%s failed for %s with "
197 "-EEXIST, don't try to register things with " 197 "-EEXIST, don't try to register things with "
198 "the same name in the same directory.\n", 198 "the same name in the same directory.\n",
199 __FUNCTION__, kobject_name(kobj)); 199 __func__, kobject_name(kobj));
200 else 200 else
201 printk(KERN_ERR "%s failed for %s (%d)\n", 201 printk(KERN_ERR "%s failed for %s (%d)\n",
202 __FUNCTION__, kobject_name(kobj), error); 202 __func__, kobject_name(kobj), error);
203 dump_stack(); 203 dump_stack();
204 } else 204 } else
205 kobj->state_in_sysfs = 1; 205 kobj->state_in_sysfs = 1;
@@ -216,21 +216,12 @@ static int kobject_add_internal(struct kobject *kobj)
216static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 216static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
217 va_list vargs) 217 va_list vargs)
218{ 218{
219 va_list aq;
220 char *name;
221
222 va_copy(aq, vargs);
223 name = kvasprintf(GFP_KERNEL, fmt, vargs);
224 va_end(aq);
225
226 if (!name)
227 return -ENOMEM;
228
229 /* Free the old name, if necessary. */ 219 /* Free the old name, if necessary. */
230 kfree(kobj->name); 220 kfree(kobj->name);
231 221
232 /* Now, set the new name */ 222 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
233 kobj->name = name; 223 if (!kobj->name)
224 return -ENOMEM;
234 225
235 return 0; 226 return 0;
236} 227}
@@ -246,12 +237,12 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
246 */ 237 */
247int kobject_set_name(struct kobject *kobj, const char *fmt, ...) 238int kobject_set_name(struct kobject *kobj, const char *fmt, ...)
248{ 239{
249 va_list args; 240 va_list vargs;
250 int retval; 241 int retval;
251 242
252 va_start(args, fmt); 243 va_start(vargs, fmt);
253 retval = kobject_set_name_vargs(kobj, fmt, args); 244 retval = kobject_set_name_vargs(kobj, fmt, vargs);
254 va_end(args); 245 va_end(vargs);
255 246
256 return retval; 247 return retval;
257} 248}
@@ -301,12 +292,9 @@ EXPORT_SYMBOL(kobject_init);
301static int kobject_add_varg(struct kobject *kobj, struct kobject *parent, 292static int kobject_add_varg(struct kobject *kobj, struct kobject *parent,
302 const char *fmt, va_list vargs) 293 const char *fmt, va_list vargs)
303{ 294{
304 va_list aq;
305 int retval; 295 int retval;
306 296
307 va_copy(aq, vargs); 297 retval = kobject_set_name_vargs(kobj, fmt, vargs);
308 retval = kobject_set_name_vargs(kobj, fmt, aq);
309 va_end(aq);
310 if (retval) { 298 if (retval) {
311 printk(KERN_ERR "kobject: can not set name properly!\n"); 299 printk(KERN_ERR "kobject: can not set name properly!\n");
312 return retval; 300 return retval;
@@ -540,7 +528,7 @@ static void kobject_cleanup(struct kobject *kobj)
540 const char *name = kobj->name; 528 const char *name = kobj->name;
541 529
542 pr_debug("kobject: '%s' (%p): %s\n", 530 pr_debug("kobject: '%s' (%p): %s\n",
543 kobject_name(kobj), kobj, __FUNCTION__); 531 kobject_name(kobj), kobj, __func__);
544 532
545 if (t && !t->release) 533 if (t && !t->release)
546 pr_debug("kobject: '%s' (%p): does not have a release() " 534 pr_debug("kobject: '%s' (%p): does not have a release() "
@@ -600,7 +588,7 @@ void kobject_put(struct kobject *kobj)
600 588
601static void dynamic_kobj_release(struct kobject *kobj) 589static void dynamic_kobj_release(struct kobject *kobj)
602{ 590{
603 pr_debug("kobject: (%p): %s\n", kobj, __FUNCTION__); 591 pr_debug("kobject: (%p): %s\n", kobj, __func__);
604 kfree(kobj); 592 kfree(kobj);
605} 593}
606 594
@@ -657,7 +645,7 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
657 retval = kobject_add(kobj, parent, "%s", name); 645 retval = kobject_add(kobj, parent, "%s", name);
658 if (retval) { 646 if (retval) {
659 printk(KERN_WARNING "%s: kobject_add error: %d\n", 647 printk(KERN_WARNING "%s: kobject_add error: %d\n",
660 __FUNCTION__, retval); 648 __func__, retval);
661 kobject_put(kobj); 649 kobject_put(kobj);
662 kobj = NULL; 650 kobj = NULL;
663 } 651 }
@@ -765,7 +753,7 @@ static void kset_release(struct kobject *kobj)
765{ 753{
766 struct kset *kset = container_of(kobj, struct kset, kobj); 754 struct kset *kset = container_of(kobj, struct kset, kobj);
767 pr_debug("kobject: '%s' (%p): %s\n", 755 pr_debug("kobject: '%s' (%p): %s\n",
768 kobject_name(kobj), kobj, __FUNCTION__); 756 kobject_name(kobj), kobj, __func__);
769 kfree(kset); 757 kfree(kset);
770} 758}
771 759