Implement __kobject_set_name() which takes pre-allocated @new_name and renames the kobject without failing.
Signed-off-by: Tejun Heo <[EMAIL PROTECTED]> --- include/linux/kobject.h | 1 + lib/kobject.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index a8a84fc..f7a7734 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -68,6 +68,7 @@ struct kobject { struct sysfs_dirent * sd; }; +extern void __kobject_set_name(struct kobject *kobj, const char *new_name); extern int kobject_set_name(struct kobject *, const char *, ...) __attribute__((format(printf,2,3))); diff --git a/lib/kobject.c b/lib/kobject.c index a280c62..1623125 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -230,6 +230,19 @@ int kobject_register(struct kobject * kobj) return error; } +/** + * __kobject_set_name - Set the name of an object to preallocated string + * @kobj: object. + * @new_name: pointer to pre-allocated string for the new name + * + * Set the name of @kobj to @new_name. @new_name is used + * directly and will be freed using kfree() on @kobj release. + */ +void __kobject_set_name(struct kobject *kobj, const char *new_name) +{ + kfree(kobj->k_name); + kobj->k_name = new_name; +} /** * kobject_set_name - Set the name of an object -- 1.5.0.3 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/