Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Dmitry Torokhov and committed by
Linus Torvalds
4f01a757 508a9274

+23 -6
+23 -6
drivers/base/core.c
··· 679 679 goto out_subsys; 680 680 } 681 681 if (dev->parent) { 682 - error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, 683 - "device"); 684 - if (error) 685 - goto out_busid; 686 682 #ifdef CONFIG_SYSFS_DEPRECATED 687 683 { 688 - char * class_name = make_class_name(dev->class->name, 689 - &dev->kobj); 684 + struct device *parent = dev->parent; 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 702 if (class_name) 691 703 error = sysfs_create_link(&dev->parent->kobj, 692 704 &dev->kobj, class_name); ··· 706 694 if (error) 707 695 goto out_device; 708 696 } 697 + #else 698 + error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, 699 + "device"); 700 + if (error) 701 + goto out_busid; 709 702 #endif 710 703 } 711 704 return 0;