From b9d9c82b4d081feb464f62dfc786c8621d09ecd2 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Thu, 15 Jun 2006 15:31:56 +0200 Subject: [PATCH] Driver core: add generic "subsystem" link to all devices Like the SUBSYTEM= key we find in the environment of the uevent, this creates a generic "subsystem" link in sysfs for every device. Userspace usually doesn't care at all if its a "class" or a "bus" device. This provides an unified way to determine the subsytem of a device, regardless of the way the driver core has created it. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/base/core.c') diff --git a/drivers/base/core.c b/drivers/base/core.c index 252cf403f891..cc8bb97427d0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -319,9 +319,12 @@ int device_add(struct device *dev) dev->devt_attr = attr; } - if (dev->class) + if (dev->class) { + sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj, + "subsystem"); sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, dev->bus_id); + } if ((error = device_pm_add(dev))) goto PMError; @@ -422,8 +425,10 @@ void device_del(struct device * dev) klist_del(&dev->knode_parent); if (dev->devt_attr) device_remove_file(dev, dev->devt_attr); - if (dev->class) + if (dev->class) { + sysfs_remove_link(&dev->kobj, "subsystem"); sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); + } device_remove_file(dev, &dev->uevent_attr); /* Notify the platform of the removal, in case they -- cgit v1.2.3