Skip to content

Commit

Permalink
[PATCH] Kobject: provide better warning messages when people do stupi…
Browse files Browse the repository at this point in the history
…d 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: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Mar 20, 2006
1 parent 4f2928d commit dcd0da0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,17 @@ int kobject_add(struct kobject * kobj)
unlink(kobj);
if (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;
Expand All @@ -207,18 +218,13 @@ int kobject_add(struct kobject * kobj)

int kobject_register(struct kobject * kobj)
{
int error = 0;
int error = -EINVAL;
if (kobj) {
kobject_init(kobj);
error = kobject_add(kobj);
if (error) {
printk("kobject_register failed for %s (%d)\n",
kobject_name(kobj),error);
dump_stack();
} else
if (!error)
kobject_uevent(kobj, KOBJ_ADD);
} else
error = -EINVAL;
}
return error;
}

Expand Down

0 comments on commit dcd0da0

Please sign in to comment.