diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-09-19 01:46:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-09-19 14:24:18 -0400 |
commit | 4f01a757e75f2a3cab2bab89c4176498963946b9 (patch) | |
tree | b5773a393a60adb13021f5d1a02aff4e49cddc57 /drivers/base | |
parent | 508a92741a105e2e3d466cd727fb73154ebf08de (diff) |
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: Dmitry Torokhov <dtor@mail.ru>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Greg KH <greg@kroah.com>
Tested-by: Anssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 29 |
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; |