From: Dmitry Torokhov Date: Sun, 7 Oct 2007 16:22:21 +0000 (-0400) Subject: Driver core: fix SYSF_DEPRECATED breakage for nested classdevs X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3eb215de26e6e94bf5fed9cb77230c383b30e53b;p=linux-beck.git Driver core: fix SYSF_DEPRECATED breakage for nested classdevs We should only reparent to a class former class devices that form the base of class hierarchy. Nested devices should still grow from their real parents. Signed-off-by: Dmitry Torokhov Tested-by: Andrey Borzenkov Tested-by: Anssi Hannula Signed-off-by: Linus Torvalds --- diff --git a/drivers/base/core.c b/drivers/base/core.c index 67c92582d6ef..ec86d6fc2360 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -586,9 +586,13 @@ void device_initialize(struct device *dev) static struct kobject * get_device_parent(struct device *dev, struct device *parent) { - /* Set the parent to the class, not the parent device */ - /* this keeps sysfs from having a symlink to make old udevs happy */ - if (dev->class) + /* + * Set the parent to the class, not the parent device + * for topmost devices in class hierarchy. + * This keeps sysfs from having a symlink to make old + * udevs happy + */ + if (dev->class && (!parent || parent->class != dev->class)) return &dev->class->subsys.kobj; else if (parent) return &parent->kobj;