aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/core.c19
-rw-r--r--drivers/usb/core/usb.c2
2 files changed, 13 insertions, 8 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d0f84ff78776..27c2176895de 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -356,6 +356,13 @@ int device_add(struct device *dev)
356 if (parent) 356 if (parent)
357 klist_add_tail(&dev->knode_parent, &parent->klist_children); 357 klist_add_tail(&dev->knode_parent, &parent->klist_children);
358 358
359 if (dev->class) {
360 /* tie the class to the device */
361 down(&dev->class->sem);
362 list_add_tail(&dev->node, &dev->class->devices);
363 up(&dev->class->sem);
364 }
365
359 /* notify platform of device entry */ 366 /* notify platform of device entry */
360 if (platform_notify) 367 if (platform_notify)
361 platform_notify(dev); 368 platform_notify(dev);
@@ -455,6 +462,9 @@ void device_del(struct device * dev)
455 sysfs_remove_link(&dev->kobj, "device"); 462 sysfs_remove_link(&dev->kobj, "device");
456 sysfs_remove_link(&dev->parent->kobj, class_name); 463 sysfs_remove_link(&dev->parent->kobj, class_name);
457 kfree(class_name); 464 kfree(class_name);
465 down(&dev->class->sem);
466 list_del_init(&dev->node);
467 up(&dev->class->sem);
458 } 468 }
459 device_remove_file(dev, &dev->uevent_attr); 469 device_remove_file(dev, &dev->uevent_attr);
460 470
@@ -601,11 +611,6 @@ struct device *device_create(struct class *class, struct device *parent,
601 if (retval) 611 if (retval)
602 goto error; 612 goto error;
603 613
604 /* tie the class to the device */
605 down(&class->sem);
606 list_add_tail(&dev->node, &class->devices);
607 up(&class->sem);
608
609 return dev; 614 return dev;
610 615
611error: 616error:
@@ -636,9 +641,7 @@ void device_destroy(struct class *class, dev_t devt)
636 } 641 }
637 up(&class->sem); 642 up(&class->sem);
638 643
639 if (dev) { 644 if (dev)
640 list_del_init(&dev->node);
641 device_unregister(dev); 645 device_unregister(dev);
642 }
643} 646}
644EXPORT_SYMBOL_GPL(device_destroy); 647EXPORT_SYMBOL_GPL(device_destroy);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 515310751303..fb488c8a860c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -991,6 +991,8 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
991 991
992static int verify_suspended(struct device *dev, void *unused) 992static int verify_suspended(struct device *dev, void *unused)
993{ 993{
994 if (dev->driver == NULL)
995 return 0;
994 return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0; 996 return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0;
995} 997}
996 998