]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - lib/kobject.c
[SCSI] don't use __GFP_DMA for sense buffers if not required
[linux-2.6-omap-h63xx.git] / lib / kobject.c
index 03d40360ff1be9682f4c192fec63e45b0d9e33fd..3590f022a609cf7828c259b9485503fd3cda9683 100644 (file)
@@ -234,13 +234,13 @@ int kobject_register(struct kobject * kobj)
 
 
 /**
- *     kobject_set_name - Set the name of an object
- *     @kobj:  object.
- *     @fmt:   format string used to build the name
+ * kobject_set_name - Set the name of a kobject
+ * @kobj: kobject to name
+ * @fmt: format string used to build the name
  *
- *     If strlen(name) >= KOBJ_NAME_LEN, then use a dynamically allocated
- *     string that @kobj->k_name points to. Otherwise, use the static 
- *     @kobj->name array.
+ * This sets the name of the kobject.  If you have already added the
+ * kobject to the system, you must call kobject_rename() in order to
+ * change the name of the kobject.
  */
 int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
 {
@@ -308,6 +308,19 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
        if (!kobj->parent)
                return -EINVAL;
 
+       /* see if this name is already in use */
+       if (kobj->kset) {
+               struct kobject *temp_kobj;
+               temp_kobj = kset_find_obj(kobj->kset, new_name);
+               if (temp_kobj) {
+                       printk(KERN_WARNING "kobject '%s' cannot be renamed "
+                              "to '%s' as '%s' is already in existence.\n",
+                              kobject_name(kobj), new_name, new_name);
+                       kobject_put(temp_kobj);
+                       return -EINVAL;
+               }
+       }
+
        devpath = kobject_get_path(kobj, GFP_KERNEL);
        if (!devpath) {
                error = -ENOMEM;