diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/core.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index cc8bb97427d0..a979bc3f49a9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -273,6 +273,7 @@ void device_initialize(struct device *dev) | |||
273 | int device_add(struct device *dev) | 273 | int device_add(struct device *dev) |
274 | { | 274 | { |
275 | struct device *parent = NULL; | 275 | struct device *parent = NULL; |
276 | char *class_name = NULL; | ||
276 | int error = -EINVAL; | 277 | int error = -EINVAL; |
277 | 278 | ||
278 | dev = get_device(dev); | 279 | dev = get_device(dev); |
@@ -324,6 +325,10 @@ int device_add(struct device *dev) | |||
324 | "subsystem"); | 325 | "subsystem"); |
325 | sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, | 326 | sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, |
326 | dev->bus_id); | 327 | dev->bus_id); |
328 | |||
329 | sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); | ||
330 | class_name = make_class_name(dev->class->name, &dev->kobj); | ||
331 | sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); | ||
327 | } | 332 | } |
328 | 333 | ||
329 | if ((error = device_pm_add(dev))) | 334 | if ((error = device_pm_add(dev))) |
@@ -339,6 +344,7 @@ int device_add(struct device *dev) | |||
339 | if (platform_notify) | 344 | if (platform_notify) |
340 | platform_notify(dev); | 345 | platform_notify(dev); |
341 | Done: | 346 | Done: |
347 | kfree(class_name); | ||
342 | put_device(dev); | 348 | put_device(dev); |
343 | return error; | 349 | return error; |
344 | BusError: | 350 | BusError: |
@@ -420,6 +426,7 @@ void put_device(struct device * dev) | |||
420 | void device_del(struct device * dev) | 426 | void device_del(struct device * dev) |
421 | { | 427 | { |
422 | struct device * parent = dev->parent; | 428 | struct device * parent = dev->parent; |
429 | char *class_name = NULL; | ||
423 | 430 | ||
424 | if (parent) | 431 | if (parent) |
425 | klist_del(&dev->knode_parent); | 432 | klist_del(&dev->knode_parent); |
@@ -428,6 +435,10 @@ void device_del(struct device * dev) | |||
428 | if (dev->class) { | 435 | if (dev->class) { |
429 | sysfs_remove_link(&dev->kobj, "subsystem"); | 436 | sysfs_remove_link(&dev->kobj, "subsystem"); |
430 | sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); | 437 | sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); |
438 | class_name = make_class_name(dev->class->name, &dev->kobj); | ||
439 | sysfs_remove_link(&dev->kobj, "device"); | ||
440 | sysfs_remove_link(&dev->parent->kobj, class_name); | ||
441 | kfree(class_name); | ||
431 | } | 442 | } |
432 | device_remove_file(dev, &dev->uevent_attr); | 443 | device_remove_file(dev, &dev->uevent_attr); |
433 | 444 | ||