diff options
author | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-21 14:05:45 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-21 14:05:45 -0500 |
commit | d04cdb64212eb5ae6a98026a97dda626e40e8e9a (patch) | |
tree | b6a7dbb21ccfceb915844e9a330b3d3dfcaf3c5b /lib/kobject.c | |
parent | 2f8600dff2b140096a7df781884e918a16aa90e0 (diff) | |
parent | ec1248e70edc5cf7b485efcc7b41e44e10f422e5 (diff) |
Merge ../linux-2.6
Diffstat (limited to 'lib/kobject.c')
-rw-r--r-- | lib/kobject.c | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index efe67fa96a71..25204a41a9b0 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 | ||
@@ -379,6 +385,44 @@ void kobject_put(struct kobject * kobj) | |||
379 | } | 385 | } |
380 | 386 | ||
381 | 387 | ||
388 | static void dir_release(struct kobject *kobj) | ||
389 | { | ||
390 | kfree(kobj); | ||
391 | } | ||
392 | |||
393 | static struct kobj_type dir_ktype = { | ||
394 | .release = dir_release, | ||
395 | .sysfs_ops = NULL, | ||
396 | .default_attrs = NULL, | ||
397 | }; | ||
398 | |||
399 | /** | ||
400 | * kobject_add_dir - add sub directory of object. | ||
401 | * @parent: object in which a directory is created. | ||
402 | * @name: directory name. | ||
403 | * | ||
404 | * Add a plain directory object as child of given object. | ||
405 | */ | ||
406 | struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | ||
407 | { | ||
408 | struct kobject *k; | ||
409 | |||
410 | if (!parent) | ||
411 | return NULL; | ||
412 | |||
413 | k = kzalloc(sizeof(*k), GFP_KERNEL); | ||
414 | if (!k) | ||
415 | return NULL; | ||
416 | |||
417 | k->parent = parent; | ||
418 | k->ktype = &dir_ktype; | ||
419 | kobject_set_name(k, name); | ||
420 | kobject_register(k); | ||
421 | |||
422 | return k; | ||
423 | } | ||
424 | EXPORT_SYMBOL_GPL(kobject_add_dir); | ||
425 | |||
382 | /** | 426 | /** |
383 | * kset_init - initialize a kset for use | 427 | * kset_init - initialize a kset for use |
384 | * @k: kset | 428 | * @k: kset |