Commit f7f3461d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 161e232b
...@@ -584,17 +584,17 @@ int device_add(struct device *dev) ...@@ -584,17 +584,17 @@ int device_add(struct device *dev)
if (dev->kobj.parent != &dev->class->subsys.kset.kobj) if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
sysfs_create_link(&dev->class->subsys.kset.kobj, sysfs_create_link(&dev->class->subsys.kset.kobj,
&dev->kobj, dev->bus_id); &dev->kobj, dev->bus_id);
#ifdef CONFIG_SYSFS_DEPRECATED
if (parent) { if (parent) {
sysfs_create_link(&dev->kobj, &dev->parent->kobj, sysfs_create_link(&dev->kobj, &dev->parent->kobj,
"device"); "device");
#ifdef CONFIG_SYSFS_DEPRECATED
class_name = make_class_name(dev->class->name, class_name = make_class_name(dev->class->name,
&dev->kobj); &dev->kobj);
if (class_name) if (class_name)
sysfs_create_link(&dev->parent->kobj, sysfs_create_link(&dev->parent->kobj,
&dev->kobj, class_name); &dev->kobj, class_name);
}
#endif #endif
}
} }
if ((error = device_add_attrs(dev))) if ((error = device_add_attrs(dev)))
...@@ -651,17 +651,17 @@ int device_add(struct device *dev) ...@@ -651,17 +651,17 @@ int device_add(struct device *dev)
if (dev->kobj.parent != &dev->class->subsys.kset.kobj) if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
sysfs_remove_link(&dev->class->subsys.kset.kobj, sysfs_remove_link(&dev->class->subsys.kset.kobj,
dev->bus_id); dev->bus_id);
#ifdef CONFIG_SYSFS_DEPRECATED
if (parent) { if (parent) {
#ifdef CONFIG_SYSFS_DEPRECATED
char *class_name = make_class_name(dev->class->name, char *class_name = make_class_name(dev->class->name,
&dev->kobj); &dev->kobj);
if (class_name) if (class_name)
sysfs_remove_link(&dev->parent->kobj, sysfs_remove_link(&dev->parent->kobj,
class_name); class_name);
kfree(class_name); kfree(class_name);
#endif
sysfs_remove_link(&dev->kobj, "device"); sysfs_remove_link(&dev->kobj, "device");
} }
#endif
down(&dev->class->sem); down(&dev->class->sem);
/* notify any interfaces that the device is now gone */ /* notify any interfaces that the device is now gone */
...@@ -761,17 +761,17 @@ void device_del(struct device * dev) ...@@ -761,17 +761,17 @@ void device_del(struct device * dev)
if (dev->kobj.parent != &dev->class->subsys.kset.kobj) if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
sysfs_remove_link(&dev->class->subsys.kset.kobj, sysfs_remove_link(&dev->class->subsys.kset.kobj,
dev->bus_id); dev->bus_id);
#ifdef CONFIG_SYSFS_DEPRECATED
if (parent) { if (parent) {
#ifdef CONFIG_SYSFS_DEPRECATED
char *class_name = make_class_name(dev->class->name, char *class_name = make_class_name(dev->class->name,
&dev->kobj); &dev->kobj);
if (class_name) if (class_name)
sysfs_remove_link(&dev->parent->kobj, sysfs_remove_link(&dev->parent->kobj,
class_name); class_name);
kfree(class_name); kfree(class_name);
#endif
sysfs_remove_link(&dev->kobj, "device"); sysfs_remove_link(&dev->kobj, "device");
} }
#endif
down(&dev->class->sem); down(&dev->class->sem);
/* notify any interfaces that the device is now gone */ /* notify any interfaces that the device is now gone */
...@@ -1071,8 +1071,8 @@ static int device_move_class_links(struct device *dev, ...@@ -1071,8 +1071,8 @@ static int device_move_class_links(struct device *dev,
struct device *old_parent, struct device *old_parent,
struct device *new_parent) struct device *new_parent)
{ {
int error = 0;
#ifdef CONFIG_SYSFS_DEPRECATED #ifdef CONFIG_SYSFS_DEPRECATED
int error;
char *class_name; char *class_name;
class_name = make_class_name(dev->class->name, &dev->kobj); class_name = make_class_name(dev->class->name, &dev->kobj);
...@@ -1100,7 +1100,12 @@ out: ...@@ -1100,7 +1100,12 @@ out:
kfree(class_name); kfree(class_name);
return error; return error;
#else #else
return 0; if (old_parent)
sysfs_remove_link(&dev->kobj, "device");
if (new_parent)
error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
"device");
return error;
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment