Implement __kobject_set_name() which takes pre-allocated @new_name and
renames the kobject without failing.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
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
-
| Greg Kroah-Hartman | [PATCH 008/196] Chinese: add translation of volatile-considered-harmful.txt |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg KH | Re: [Patch v2] Make PCI extended config space (MMCONFIG) a driver opt-in |
| Andrew Morton | -mm merge plans for 2.6.23 |
git: | |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Herbert Xu | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| David Miller | [GIT]: Networking |
| Rémi Denis-Courmont | [PATCH 01/14] Phonet global definitions |
