aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/core.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index e6738bcbe5a9..6de33d7a29ba 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -679,14 +679,26 @@ static int device_add_class_symlinks(struct device *dev)
679 goto out_subsys; 679 goto out_subsys;
680 } 680 }
681 if (dev->parent) { 681 if (dev->parent) {
682 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
683 "device");
684 if (error)
685 goto out_busid;
686#ifdef CONFIG_SYSFS_DEPRECATED 682#ifdef CONFIG_SYSFS_DEPRECATED
687 { 683 {
688 char * class_name = make_class_name(dev->class->name, 684 struct device *parent = dev->parent;
689 &dev->kobj); 685 char *class_name;
686
687 /*
688 * In old sysfs stacked class devices had 'device'
689 * link pointing to real device instead of parent
690 */
691 while (parent->class && !parent->bus && parent->parent)
692 parent = parent->parent;
693
694 error = sysfs_create_link(&dev->kobj,
695 &parent->kobj,
696 "device");
697 if (error)
698 goto out_busid;
699
700 class_name = make_class_name(dev->class->name,
701 &dev->kobj);
690 if (class_name) 702 if (class_name)
691 error = sysfs_create_link(&dev->parent->kobj, 703 error = sysfs_create_link(&dev->parent->kobj,
692 &dev->kobj, class_name); 704 &dev->kobj, class_name);
@@ -694,6 +706,11 @@ static int device_add_class_symlinks(struct device *dev)
694 if (error) 706 if (error)
695 goto out_device; 707 goto out_device;
696 } 708 }
709#else
710 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
711 "device");
712 if (error)
713 goto out_busid;
697#endif 714#endif
698 } 715 }
699 return 0; 716 return 0;