Commit 4f01a757 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Linus Torvalds

Driver core: fix deprectated sysfs structure for nested class devices

Nested class devices used to have 'device' symlink point to a real
(physical) device instead of a parent class device.  When converting
subsystems to struct device we need to keep doing what class devices did if
CONFIG_SYSFS_DEPRECATED is Y, otherwise parts of udev break.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: default avatarGreg KH <greg@kroah.com>
Tested-by: default avatarAnssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 508a9274
...@@ -679,13 +679,25 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -679,13 +679,25 @@ static int device_add_class_symlinks(struct device *dev)
goto out_subsys; goto out_subsys;
} }
if (dev->parent) { if (dev->parent) {
error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, #ifdef CONFIG_SYSFS_DEPRECATED
{
struct device *parent = dev->parent;
char *class_name;
/*
* In old sysfs stacked class devices had 'device'
* link pointing to real device instead of parent
*/
while (parent->class && !parent->bus && parent->parent)
parent = parent->parent;
error = sysfs_create_link(&dev->kobj,
&parent->kobj,
"device"); "device");
if (error) if (error)
goto out_busid; goto out_busid;
#ifdef CONFIG_SYSFS_DEPRECATED
{ 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)
error = sysfs_create_link(&dev->parent->kobj, error = sysfs_create_link(&dev->parent->kobj,
...@@ -694,6 +706,11 @@ static int device_add_class_symlinks(struct device *dev) ...@@ -694,6 +706,11 @@ static int device_add_class_symlinks(struct device *dev)
if (error) if (error)
goto out_device; goto out_device;
} }
#else
error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
"device");
if (error)
goto out_busid;
#endif #endif
} }
return 0; return 0;
......
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