Commit dcd0da00 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] Kobject: provide better warning messages when people do stupid things

Now that kobject_add() is used more than kobject_register() the kernel
wasn't always letting people know that they were doing something wrong.
This change fixes this.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4f2928d0
...@@ -194,6 +194,17 @@ int kobject_add(struct kobject * kobj) ...@@ -194,6 +194,17 @@ int kobject_add(struct kobject * kobj)
unlink(kobj); unlink(kobj);
if (parent) if (parent)
kobject_put(parent); kobject_put(parent);
/* be noisy on error issues */
if (error == -EEXIST)
printk("kobject_add failed for %s with -EEXIST, "
"don't try to register things with the "
"same name in the same directory.\n",
kobject_name(kobj));
else
printk("kobject_add failed for %s (%d)\n",
kobject_name(kobj), error);
dump_stack();
} }
return error; return error;
...@@ -207,18 +218,13 @@ int kobject_add(struct kobject * kobj) ...@@ -207,18 +218,13 @@ int kobject_add(struct kobject * kobj)
int kobject_register(struct kobject * kobj) int kobject_register(struct kobject * kobj)
{ {
int error = 0; int error = -EINVAL;
if (kobj) { if (kobj) {
kobject_init(kobj); kobject_init(kobj);
error = kobject_add(kobj); error = kobject_add(kobj);
if (error) { if (!error)
printk("kobject_register failed for %s (%d)\n",
kobject_name(kobj),error);
dump_stack();
} else
kobject_uevent(kobj, KOBJ_ADD); kobject_uevent(kobj, KOBJ_ADD);
} else }
error = -EINVAL;
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment