aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-03-06 15:55:53 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-03-09 18:32:58 -0500
commitf7f3461d87536bed52bb83bc8fbe6bfd28619fb1 (patch)
treed85b97ea5d47378669958028cfc55697d3a3d516 /drivers/base/core.c
parent161e232b8823e230d4fdf8064e606bbdf26f47e2 (diff)
Driver core: add device symlink back to sysfs
This moves the device symlink back to sysfs even if CONFIG_SYSFS_DEPRECATED is enabled as too many userspace programs (well, HAL), still rely on this link to be present. I will rework the ability for sysfs to change layouts like this in the future, but for now, this patch should fix people's network connections. Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Matt Mackall <mpm@selenic.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 89ebe3682726..fb16f293561d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -584,17 +584,17 @@ int device_add(struct device *dev)
584 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 584 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
585 sysfs_create_link(&dev->class->subsys.kset.kobj, 585 sysfs_create_link(&dev->class->subsys.kset.kobj,
586 &dev->kobj, dev->bus_id); 586 &dev->kobj, dev->bus_id);
587#ifdef CONFIG_SYSFS_DEPRECATED
588 if (parent) { 587 if (parent) {
589 sysfs_create_link(&dev->kobj, &dev->parent->kobj, 588 sysfs_create_link(&dev->kobj, &dev->parent->kobj,
590 "device"); 589 "device");
590#ifdef CONFIG_SYSFS_DEPRECATED
591 class_name = make_class_name(dev->class->name, 591 class_name = make_class_name(dev->class->name,
592 &dev->kobj); 592 &dev->kobj);
593 if (class_name) 593 if (class_name)
594 sysfs_create_link(&dev->parent->kobj, 594 sysfs_create_link(&dev->parent->kobj,
595 &dev->kobj, class_name); 595 &dev->kobj, class_name);
596 }
597#endif 596#endif
597 }
598 } 598 }
599 599
600 if ((error = device_add_attrs(dev))) 600 if ((error = device_add_attrs(dev)))
@@ -651,17 +651,17 @@ int device_add(struct device *dev)
651 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 651 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
652 sysfs_remove_link(&dev->class->subsys.kset.kobj, 652 sysfs_remove_link(&dev->class->subsys.kset.kobj,
653 dev->bus_id); 653 dev->bus_id);
654#ifdef CONFIG_SYSFS_DEPRECATED
655 if (parent) { 654 if (parent) {
655#ifdef CONFIG_SYSFS_DEPRECATED
656 char *class_name = make_class_name(dev->class->name, 656 char *class_name = make_class_name(dev->class->name,
657 &dev->kobj); 657 &dev->kobj);
658 if (class_name) 658 if (class_name)
659 sysfs_remove_link(&dev->parent->kobj, 659 sysfs_remove_link(&dev->parent->kobj,
660 class_name); 660 class_name);
661 kfree(class_name); 661 kfree(class_name);
662#endif
662 sysfs_remove_link(&dev->kobj, "device"); 663 sysfs_remove_link(&dev->kobj, "device");
663 } 664 }
664#endif
665 665
666 down(&dev->class->sem); 666 down(&dev->class->sem);
667 /* notify any interfaces that the device is now gone */ 667 /* notify any interfaces that the device is now gone */
@@ -761,17 +761,17 @@ void device_del(struct device * dev)
761 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 761 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
762 sysfs_remove_link(&dev->class->subsys.kset.kobj, 762 sysfs_remove_link(&dev->class->subsys.kset.kobj,
763 dev->bus_id); 763 dev->bus_id);
764#ifdef CONFIG_SYSFS_DEPRECATED
765 if (parent) { 764 if (parent) {
765#ifdef CONFIG_SYSFS_DEPRECATED
766 char *class_name = make_class_name(dev->class->name, 766 char *class_name = make_class_name(dev->class->name,
767 &dev->kobj); 767 &dev->kobj);
768 if (class_name) 768 if (class_name)
769 sysfs_remove_link(&dev->parent->kobj, 769 sysfs_remove_link(&dev->parent->kobj,
770 class_name); 770 class_name);
771 kfree(class_name); 771 kfree(class_name);
772#endif
772 sysfs_remove_link(&dev->kobj, "device"); 773 sysfs_remove_link(&dev->kobj, "device");
773 } 774 }
774#endif
775 775
776 down(&dev->class->sem); 776 down(&dev->class->sem);
777 /* notify any interfaces that the device is now gone */ 777 /* notify any interfaces that the device is now gone */
@@ -1071,8 +1071,8 @@ static int device_move_class_links(struct device *dev,
1071 struct device *old_parent, 1071 struct device *old_parent,
1072 struct device *new_parent) 1072 struct device *new_parent)
1073{ 1073{
1074 int error = 0;
1074#ifdef CONFIG_SYSFS_DEPRECATED 1075#ifdef CONFIG_SYSFS_DEPRECATED
1075 int error;
1076 char *class_name; 1076 char *class_name;
1077 1077
1078 class_name = make_class_name(dev->class->name, &dev->kobj); 1078 class_name = make_class_name(dev->class->name, &dev->kobj);
@@ -1100,7 +1100,12 @@ out:
1100 kfree(class_name); 1100 kfree(class_name);
1101 return error; 1101 return error;
1102#else 1102#else
1103 return 0; 1103 if (old_parent)
1104 sysfs_remove_link(&dev->kobj, "device");
1105 if (new_parent)
1106 error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
1107 "device");
1108 return error;
1104#endif 1109#endif
1105} 1110}
1106 1111