ChangeSet 1.1097, 2003/05/09 16:26:28-07:00, greg@kroah.com [PATCH] driver core: Add driver symlink to class devices in sysfs. Thanks to Mike Anderson for the idea for this. drivers/base/class.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+) diff -Nru a/drivers/base/class.c b/drivers/base/class.c --- a/drivers/base/class.c Fri May 9 16:40:29 2003 +++ b/drivers/base/class.c Fri May 9 16:40:29 2003 @@ -133,6 +133,21 @@ sysfs_remove_link(&class_dev->kobj, "device"); } +static int class_device_driver_link(struct class_device * class_dev) +{ + if ((class_dev->dev) && (class_dev->dev->driver)) + return sysfs_create_link(&class_dev->kobj, + &class_dev->dev->driver->kobj, "driver"); + return 0; +} + +static void class_device_driver_unlink(struct class_device * class_dev) +{ + if ((class_dev->dev) && (class_dev->dev->driver)) + sysfs_remove_link(&class_dev->kobj, "driver"); +} + + #define to_class_dev(obj) container_of(obj,struct class_device,kobj) #define to_class_dev_attr(_attr) container_of(_attr,struct class_device_attribute,attr) @@ -265,6 +280,7 @@ } class_device_dev_link(class_dev); + class_device_driver_link(class_dev); register_done: if (error && parent) @@ -298,6 +314,7 @@ if (class_dev->dev) { class_device_dev_unlink(class_dev); + class_device_driver_unlink(class_dev); put_device(class_dev->dev); }