Commit f349cf34 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Greg Kroah-Hartman

driver core: Implement ns directory support for device classes.

device_del and device_rename were modified to use
sysfs_delete_link and sysfs_rename_link respectively to ensure
when these operations happen on devices whose classes
are in namespace directories they work properly.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarBenjamin Thery <benjamin.thery@bull.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 746edb7a
...@@ -786,7 +786,7 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -786,7 +786,7 @@ static int device_add_class_symlinks(struct device *dev)
out_busid: out_busid:
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
device_is_not_partition(dev)) device_is_not_partition(dev))
sysfs_remove_link(&dev->class->p->class_subsys.kobj, sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
dev_name(dev)); dev_name(dev));
#else #else
/* link in the class directory pointing to the device */ /* link in the class directory pointing to the device */
...@@ -804,7 +804,7 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -804,7 +804,7 @@ static int device_add_class_symlinks(struct device *dev)
return 0; return 0;
out_busid: out_busid:
sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev));
#endif #endif
out_subsys: out_subsys:
...@@ -832,13 +832,13 @@ static void device_remove_class_symlinks(struct device *dev) ...@@ -832,13 +832,13 @@ static void device_remove_class_symlinks(struct device *dev)
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
device_is_not_partition(dev)) device_is_not_partition(dev))
sysfs_remove_link(&dev->class->p->class_subsys.kobj, sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
dev_name(dev)); dev_name(dev));
#else #else
if (dev->parent && device_is_not_partition(dev)) if (dev->parent && device_is_not_partition(dev))
sysfs_remove_link(&dev->kobj, "device"); sysfs_remove_link(&dev->kobj, "device");
sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev));
#endif #endif
sysfs_remove_link(&dev->kobj, "subsystem"); sysfs_remove_link(&dev->kobj, "subsystem");
...@@ -1624,6 +1624,14 @@ int device_rename(struct device *dev, char *new_name) ...@@ -1624,6 +1624,14 @@ int device_rename(struct device *dev, char *new_name)
goto out; goto out;
} }
#ifndef CONFIG_SYSFS_DEPRECATED
if (dev->class) {
error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
&dev->kobj, old_device_name, new_name);
if (error)
goto out;
}
#endif
error = kobject_rename(&dev->kobj, new_name); error = kobject_rename(&dev->kobj, new_name);
if (error) if (error)
goto out; goto out;
...@@ -1638,11 +1646,6 @@ int device_rename(struct device *dev, char *new_name) ...@@ -1638,11 +1646,6 @@ int device_rename(struct device *dev, char *new_name)
new_class_name); new_class_name);
} }
} }
#else
if (dev->class) {
error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
&dev->kobj, old_device_name, new_name);
}
#endif #endif
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment