Skip to content

Commit

Permalink
driver core: Use sysfs_rename_link in device_rename
Browse files Browse the repository at this point in the history
Don't open code the renaming of symlinks in sysfs
instead use the new helper function sysfs_rename_link

Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Eric W. Biederman authored and Greg Kroah-Hartman committed Mar 8, 2010
1 parent 7cb3294 commit 2354dcc
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1578,22 +1578,16 @@ int device_rename(struct device *dev, char *new_name)
if (old_class_name) {
new_class_name = make_class_name(dev->class->name, &dev->kobj);
if (new_class_name) {
error = sysfs_create_link_nowarn(&dev->parent->kobj,
&dev->kobj,
new_class_name);
if (error)
goto out;
sysfs_remove_link(&dev->parent->kobj, old_class_name);
error = sysfs_rename_link(&dev->parent->kobj,
&dev->kobj,
old_class_name,
new_class_name);
}
}
#else
if (dev->class) {
error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
&dev->kobj, dev_name(dev));
if (error)
goto out;
sysfs_remove_link(&dev->class->p->class_subsys.kobj,
old_device_name);
error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
&dev->kobj, old_device_name, new_name);
}
#endif

Expand Down

0 comments on commit 2354dcc

Please sign in to comment.