diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 641c0c42bb48..5c91d0d81e78 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -3,6 +3,8 @@ | |||
3 | * | 3 | * |
4 | * Copyright (c) 2002-3 Patrick Mochel | 4 | * Copyright (c) 2002-3 Patrick Mochel |
5 | * Copyright (c) 2002-3 Open Source Development Labs | 5 | * Copyright (c) 2002-3 Open Source Development Labs |
6 | * Copyright (c) 2006 Greg Kroah-Hartman <gregkh@suse.de> | ||
7 | * Copyright (c) 2006 Novell, Inc. | ||
6 | * | 8 | * |
7 | * This file is released under the GPLv2 | 9 | * This file is released under the GPLv2 |
8 | * | 10 | * |
@@ -373,10 +375,11 @@ int device_add(struct device *dev) | |||
373 | "subsystem"); | 375 | "subsystem"); |
374 | sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, | 376 | sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, |
375 | dev->bus_id); | 377 | dev->bus_id); |
376 | 378 | if (parent) { | |
377 | sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); | 379 | sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); |
378 | class_name = make_class_name(dev->class->name, &dev->kobj); | 380 | class_name = make_class_name(dev->class->name, &dev->kobj); |
379 | sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); | 381 | sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); |
382 | } | ||
380 | } | 383 | } |
381 | 384 | ||
382 | if ((error = device_add_groups(dev))) | 385 | if ((error = device_add_groups(dev))) |
@@ -495,8 +498,10 @@ void device_del(struct device * dev) | |||
495 | sysfs_remove_link(&dev->kobj, "subsystem"); | 498 | sysfs_remove_link(&dev->kobj, "subsystem"); |
496 | sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); | 499 | sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); |
497 | class_name = make_class_name(dev->class->name, &dev->kobj); | 500 | class_name = make_class_name(dev->class->name, &dev->kobj); |
498 | sysfs_remove_link(&dev->kobj, "device"); | 501 | if (parent) { |
499 | sysfs_remove_link(&dev->parent->kobj, class_name); | 502 | sysfs_remove_link(&dev->kobj, "device"); |
503 | sysfs_remove_link(&dev->parent->kobj, class_name); | ||
504 | } | ||
500 | kfree(class_name); | 505 | kfree(class_name); |
501 | down(&dev->class->sem); | 506 | down(&dev->class->sem); |
502 | list_del_init(&dev->node); | 507 | list_del_init(&dev->node); |
@@ -625,10 +630,6 @@ struct device *device_create(struct class *class, struct device *parent, | |||
625 | 630 | ||
626 | if (class == NULL || IS_ERR(class)) | 631 | if (class == NULL || IS_ERR(class)) |
627 | goto error; | 632 | goto error; |
628 | if (parent == NULL) { | ||
629 | printk(KERN_WARNING "%s does not work yet for NULL parents\n", __FUNCTION__); | ||
630 | goto error; | ||
631 | } | ||
632 | 633 | ||
633 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 634 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
634 | if (!dev) { | 635 | if (!dev) { |