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

[PATCH] Driver core: add proper symlinks for devices

We need to create the "compatible" symlinks that class_devices used to
create when they were in the class directories so that userspace does
not know anything changed at all.

Yeah, we have a lot of symlinks now, but we should be able to get rid of
them in a year or two... (wishful thinking...)

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

+11
+11
drivers/base/core.c
··· 273 273 int device_add(struct device *dev) 274 274 { 275 275 struct device *parent = NULL; 276 + char *class_name = NULL; 276 277 int error = -EINVAL; 277 278 278 279 dev = get_device(dev); ··· 325 324 "subsystem"); 326 325 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 327 326 dev->bus_id); 327 + 328 + sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); 329 + class_name = make_class_name(dev->class->name, &dev->kobj); 330 + sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); 328 331 } 329 332 330 333 if ((error = device_pm_add(dev))) ··· 344 339 if (platform_notify) 345 340 platform_notify(dev); 346 341 Done: 342 + kfree(class_name); 347 343 put_device(dev); 348 344 return error; 349 345 BusError: ··· 426 420 void device_del(struct device * dev) 427 421 { 428 422 struct device * parent = dev->parent; 423 + char *class_name = NULL; 429 424 430 425 if (parent) 431 426 klist_del(&dev->knode_parent); ··· 435 428 if (dev->class) { 436 429 sysfs_remove_link(&dev->kobj, "subsystem"); 437 430 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); 431 + class_name = make_class_name(dev->class->name, &dev->kobj); 432 + sysfs_remove_link(&dev->kobj, "device"); 433 + sysfs_remove_link(&dev->parent->kobj, class_name); 434 + kfree(class_name); 438 435 } 439 436 device_remove_file(dev, &dev->uevent_attr); 440 437