diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-20 16:17:13 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-20 16:42:59 -0500 |
commit | dcd0da002122a70fe1c625c0ca9f58c95aa33ebe (patch) | |
tree | 5560cdc189fa3ae7eeeabb71ef5c5a2b26d4909e /lib | |
parent | 4f2928d0a439553f0288d9483faf417430629635 (diff) |
[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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index efe67fa96a71..36668c8c3ea1 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -194,6 +194,17 @@ int kobject_add(struct kobject * kobj) | |||
194 | unlink(kobj); | 194 | unlink(kobj); |
195 | if (parent) | 195 | if (parent) |
196 | kobject_put(parent); | 196 | kobject_put(parent); |
197 | |||
198 | /* be noisy on error issues */ | ||
199 | if (error == -EEXIST) | ||
200 | printk("kobject_add failed for %s with -EEXIST, " | ||
201 | "don't try to register things with the " | ||
202 | "same name in the same directory.\n", | ||
203 | kobject_name(kobj)); | ||
204 | else | ||
205 | printk("kobject_add failed for %s (%d)\n", | ||
206 | kobject_name(kobj), error); | ||
207 | dump_stack(); | ||
197 | } | 208 | } |
198 | 209 | ||
199 | return error; | 210 | return error; |
@@ -207,18 +218,13 @@ int kobject_add(struct kobject * kobj) | |||
207 | 218 | ||
208 | int kobject_register(struct kobject * kobj) | 219 | int kobject_register(struct kobject * kobj) |
209 | { | 220 | { |
210 | int error = 0; | 221 | int error = -EINVAL; |
211 | if (kobj) { | 222 | if (kobj) { |
212 | kobject_init(kobj); | 223 | kobject_init(kobj); |
213 | error = kobject_add(kobj); | 224 | error = kobject_add(kobj); |
214 | if (error) { | 225 | if (!error) |
215 | printk("kobject_register failed for %s (%d)\n", | ||
216 | kobject_name(kobj),error); | ||
217 | dump_stack(); | ||
218 | } else | ||
219 | kobject_uevent(kobj, KOBJ_ADD); | 226 | kobject_uevent(kobj, KOBJ_ADD); |
220 | } else | 227 | } |
221 | error = -EINVAL; | ||
222 | return error; | 228 | return error; |
223 | } | 229 | } |
224 | 230 | ||