From 2d6ec2ba52bb99df4fe88ea55e9eae4dd789b0c8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 3 Dec 2007 21:31:08 -0800 Subject: [PATCH] --- yaml --- r: 75729 b: refs/heads/master c: c11c4154e7ff4cebfadad849b1e22689d759c3f4 h: refs/heads/master i: 75727: a2c308ea8f8193403ebbc9108d367bd87f5ad3b2 v: v3 --- [refs] | 2 +- trunk/include/linux/kobject.h | 5 +++++ trunk/lib/kobject.c | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 0c454c3eecb1..8c02e65d4cd9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 244f6cee9a928103132a722292bfa0eb84114b07 +refs/heads/master: c11c4154e7ff4cebfadad849b1e22689d759c3f4 diff --git a/trunk/include/linux/kobject.h b/trunk/include/linux/kobject.h index 57eea4cb940d..e2b8c3dae425 100644 --- a/trunk/include/linux/kobject.h +++ b/trunk/include/linux/kobject.h @@ -84,6 +84,11 @@ extern int __must_check kobject_add(struct kobject *); extern int __must_check kobject_add_ng(struct kobject *kobj, struct kobject *parent, const char *fmt, ...); +extern int __must_check kobject_init_and_add(struct kobject *kobj, + struct kobj_type *ktype, + struct kobject *parent, + const char *fmt, ...); + extern void kobject_del(struct kobject *); extern int __must_check kobject_rename(struct kobject *, const char *new_name); diff --git a/trunk/lib/kobject.c b/trunk/lib/kobject.c index 329fd1126b3f..8f249408b2ec 100644 --- a/trunk/lib/kobject.c +++ b/trunk/lib/kobject.c @@ -390,6 +390,33 @@ int kobject_add_ng(struct kobject *kobj, struct kobject *parent, } EXPORT_SYMBOL(kobject_add_ng); +/** + * kobject_init_and_add - initialize a kobject structure and add it to the kobject hierarchy + * @kobj: pointer to the kobject to initialize + * @ktype: pointer to the ktype for this kobject. + * @parent: pointer to the parent of this kobject. + * @fmt: the name of the kobject. + * + * This function combines the call to kobject_init_ng() and + * kobject_add_ng(). The same type of error handling after a call to + * kobject_add_ng() and kobject lifetime rules are the same here. + */ +int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, + struct kobject *parent, const char *fmt, ...) +{ + va_list args; + int retval; + + kobject_init_ng(kobj, ktype); + + va_start(args, fmt); + retval = kobject_add_varg(kobj, parent, fmt, args); + va_end(args); + + return retval; +} +EXPORT_SYMBOL_GPL(kobject_init_and_add); + /** * kobject_rename - change the name of an object * @kobj: object in question.