From 0517587e5896cef1d5f99d3b24f5f2ca15d952ad Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 22 Jun 2006 13:29:52 -0700 Subject: [PATCH] USB: get USB suspend to work again Yeah, it's a hack, but it is only temporary until Alan's patches reworking this area make it in. We really should not care what devices below us are doing, especially when we do not really know what type of devices they are. This patch relies on the fact that the endpoint devices do not have a driver assigned to us. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/usb.c | 2 ++ 1 file changed, 2 insertions(+) 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, static int verify_suspended(struct device *dev, void *unused) { + if (dev->driver == NULL) + return 0; return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0; } -- cgit v1.2.2 From 5d9fd169c9fbdaecdc430431e59bf94ff40b93d3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 22 Jun 2006 17:17:32 -0700 Subject: [PATCH] Driver core: fix locking issues with the devices that are attached to classes Doh, that was foolish... Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 19 +++++++++++-------- 1 file changed, 11 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) if (parent) klist_add_tail(&dev->knode_parent, &parent->klist_children); + if (dev->class) { + /* tie the class to the device */ + down(&dev->class->sem); + list_add_tail(&dev->node, &dev->class->devices); + up(&dev->class->sem); + } + /* notify platform of device entry */ if (platform_notify) platform_notify(dev); @@ -455,6 +462,9 @@ void device_del(struct device * dev) sysfs_remove_link(&dev->kobj, "device"); sysfs_remove_link(&dev->parent->kobj, class_name); kfree(class_name); + down(&dev->class->sem); + list_del_init(&dev->node); + up(&dev->class->sem); } device_remove_file(dev, &dev->uevent_attr); @@ -601,11 +611,6 @@ struct device *device_create(struct class *class, struct device *parent, if (retval) goto error; - /* tie the class to the device */ - down(&class->sem); - list_add_tail(&dev->node, &class->devices); - up(&class->sem); - return dev; error: @@ -636,9 +641,7 @@ void device_destroy(struct class *class, dev_t devt) } up(&class->sem); - if (dev) { - list_del_init(&dev->node); + if (dev) device_unregister(dev); - } } EXPORT_SYMBOL_GPL(device_destroy); -- cgit v1.2.2