[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <11902755413676-git-send-email-htejun@gmail.com>
Date: Thu, 20 Sep 2007 17:05:41 +0900
From: Tejun Heo <htejun@...il.com>
To: ebiederm@...ssion.com, cornelia.huck@...ibm.com, greg@...ah.com,
stern@...land.harvard.edu, kay.sievers@...y.org,
linux-kernel@...r.kernel.org, htejun@...il.com
Cc: Tejun Heo <htejun@...il.com>
Subject: [PATCH 18/22] kobject: implement __kobject_set_name()
Implement __kobject_set_name() which takes pre-allocated @new_name and
renames the kobject without failing.
Signed-off-by: Tejun Heo <htejun@...il.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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists