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>

+13 -8
+13 -8
drivers/base/core.c
··· 584 584 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 585 585 sysfs_create_link(&dev->class->subsys.kset.kobj, 586 586 &dev->kobj, dev->bus_id); 587 - #ifdef CONFIG_SYSFS_DEPRECATED 588 587 if (parent) { 589 588 sysfs_create_link(&dev->kobj, &dev->parent->kobj, 590 589 "device"); 590 + #ifdef CONFIG_SYSFS_DEPRECATED 591 591 class_name = make_class_name(dev->class->name, 592 592 &dev->kobj); 593 593 if (class_name) 594 594 sysfs_create_link(&dev->parent->kobj, 595 595 &dev->kobj, class_name); 596 - } 597 596 #endif 597 + } 598 598 } 599 599 600 600 if ((error = device_add_attrs(dev))) ··· 651 651 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 652 652 sysfs_remove_link(&dev->class->subsys.kset.kobj, 653 653 dev->bus_id); 654 - #ifdef CONFIG_SYSFS_DEPRECATED 655 654 if (parent) { 655 + #ifdef CONFIG_SYSFS_DEPRECATED 656 656 char *class_name = make_class_name(dev->class->name, 657 657 &dev->kobj); 658 658 if (class_name) 659 659 sysfs_remove_link(&dev->parent->kobj, 660 660 class_name); 661 661 kfree(class_name); 662 + #endif 662 663 sysfs_remove_link(&dev->kobj, "device"); 663 664 } 664 - #endif 665 665 666 666 down(&dev->class->sem); 667 667 /* notify any interfaces that the device is now gone */ ··· 761 761 if (dev->kobj.parent != &dev->class->subsys.kset.kobj) 762 762 sysfs_remove_link(&dev->class->subsys.kset.kobj, 763 763 dev->bus_id); 764 - #ifdef CONFIG_SYSFS_DEPRECATED 765 764 if (parent) { 765 + #ifdef CONFIG_SYSFS_DEPRECATED 766 766 char *class_name = make_class_name(dev->class->name, 767 767 &dev->kobj); 768 768 if (class_name) 769 769 sysfs_remove_link(&dev->parent->kobj, 770 770 class_name); 771 771 kfree(class_name); 772 + #endif 772 773 sysfs_remove_link(&dev->kobj, "device"); 773 774 } 774 - #endif 775 775 776 776 down(&dev->class->sem); 777 777 /* notify any interfaces that the device is now gone */ ··· 1071 1071 struct device *old_parent, 1072 1072 struct device *new_parent) 1073 1073 { 1074 + int error = 0; 1074 1075 #ifdef CONFIG_SYSFS_DEPRECATED 1075 - int error; 1076 1076 char *class_name; 1077 1077 1078 1078 class_name = make_class_name(dev->class->name, &dev->kobj); ··· 1100 1100 kfree(class_name); 1101 1101 return error; 1102 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 1109 #endif 1105 1110 } 1106 1111