diff options
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 3b112e3542f8..ce23dc8c18c5 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -669,6 +669,7 @@ void class_device_destroy(struct class *cls, dev_t devt) | |||
669 | int class_device_rename(struct class_device *class_dev, char *new_name) | 669 | int class_device_rename(struct class_device *class_dev, char *new_name) |
670 | { | 670 | { |
671 | int error = 0; | 671 | int error = 0; |
672 | char *old_class_name = NULL, *new_class_name = NULL; | ||
672 | 673 | ||
673 | class_dev = class_device_get(class_dev); | 674 | class_dev = class_device_get(class_dev); |
674 | if (!class_dev) | 675 | if (!class_dev) |
@@ -677,12 +678,24 @@ int class_device_rename(struct class_device *class_dev, char *new_name) | |||
677 | pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, | 678 | pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, |
678 | new_name); | 679 | new_name); |
679 | 680 | ||
681 | if (class_dev->dev) | ||
682 | old_class_name = make_class_name(class_dev); | ||
683 | |||
680 | strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); | 684 | strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); |
681 | 685 | ||
682 | error = kobject_rename(&class_dev->kobj, new_name); | 686 | error = kobject_rename(&class_dev->kobj, new_name); |
683 | 687 | ||
688 | if (class_dev->dev) { | ||
689 | new_class_name = make_class_name(class_dev); | ||
690 | sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, | ||
691 | new_class_name); | ||
692 | sysfs_remove_link(&class_dev->dev->kobj, old_class_name); | ||
693 | } | ||
684 | class_device_put(class_dev); | 694 | class_device_put(class_dev); |
685 | 695 | ||
696 | kfree(old_class_name); | ||
697 | kfree(new_class_name); | ||
698 | |||
686 | return error; | 699 | return error; |
687 | } | 700 | } |
688 | 701 | ||