Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235432
b: refs/heads/master
c: d673bfc
h: refs/heads/master
v: v3
  • Loading branch information
Sarah Sharp committed Mar 14, 2011
1 parent b4c928f commit 0cdbf21
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23e0d1066f429ab44305e96fbff13f1793886277
refs/heads/master: d673bfcbfffdeb56064a6b1ee047b85590bed76c
11 changes: 10 additions & 1 deletion trunk/drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,15 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
dev_dbg (dev, "hcd alloc failed\n");
return NULL;
}
hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
GFP_KERNEL);
if (!hcd->bandwidth_mutex) {
kfree(hcd);
dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
return NULL;
}
mutex_init(hcd->bandwidth_mutex);

dev_set_drvdata(dev, hcd);
kref_init(&hcd->kref);

Expand All @@ -2205,7 +2214,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
#ifdef CONFIG_USB_SUSPEND
INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
#endif
mutex_init(&hcd->bandwidth_mutex);

hcd->driver = driver;
hcd->product_desc = (driver->product_desc) ? driver->product_desc :
Expand All @@ -2218,6 +2226,7 @@ static void hcd_release (struct kref *kref)
{
struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);

kfree(hcd->bandwidth_mutex);
kfree(hcd);
}

Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -3776,13 +3776,13 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
if (!udev->actconfig)
goto done;

mutex_lock(&hcd->bandwidth_mutex);
mutex_lock(hcd->bandwidth_mutex);
ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL);
if (ret < 0) {
dev_warn(&udev->dev,
"Busted HC? Not enough HCD resources for "
"old configuration.\n");
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
goto re_enumerate;
}
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
Expand All @@ -3793,10 +3793,10 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
dev_err(&udev->dev,
"can't restore configuration #%d (error=%d)\n",
udev->actconfig->desc.bConfigurationValue, ret);
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
goto re_enumerate;
}
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
usb_set_device_state(udev, USB_STATE_CONFIGURED);

/* Put interfaces back into the same altsettings as before.
Expand Down
22 changes: 11 additions & 11 deletions trunk/drivers/usb/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
/* Make sure we have enough bandwidth for this alternate interface.
* Remove the current alt setting and add the new alt setting.
*/
mutex_lock(&hcd->bandwidth_mutex);
mutex_lock(hcd->bandwidth_mutex);
ret = usb_hcd_alloc_bandwidth(dev, NULL, iface->cur_altsetting, alt);
if (ret < 0) {
dev_info(&dev->dev, "Not enough bandwidth for altsetting %d\n",
alternate);
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
return ret;
}

Expand All @@ -1311,10 +1311,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
} else if (ret < 0) {
/* Re-instate the old alt setting */
usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting);
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
return ret;
}
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);

/* FIXME drivers shouldn't need to replicate/bugfix the logic here
* when they implement async or easily-killable versions of this or
Expand Down Expand Up @@ -1413,7 +1413,7 @@ int usb_reset_configuration(struct usb_device *dev)

config = dev->actconfig;
retval = 0;
mutex_lock(&hcd->bandwidth_mutex);
mutex_lock(hcd->bandwidth_mutex);
/* Make sure we have enough bandwidth for each alternate setting 0 */
for (i = 0; i < config->desc.bNumInterfaces; i++) {
struct usb_interface *intf = config->interface[i];
Expand Down Expand Up @@ -1442,7 +1442,7 @@ int usb_reset_configuration(struct usb_device *dev)
usb_hcd_alloc_bandwidth(dev, NULL,
alt, intf->cur_altsetting);
}
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
return retval;
}
retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
Expand All @@ -1451,7 +1451,7 @@ int usb_reset_configuration(struct usb_device *dev)
NULL, 0, USB_CTRL_SET_TIMEOUT);
if (retval < 0)
goto reset_old_alts;
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);

/* re-init hc/hcd interface/endpoint state */
for (i = 0; i < config->desc.bNumInterfaces; i++) {
Expand Down Expand Up @@ -1739,10 +1739,10 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
* host controller will not allow submissions to dropped endpoints. If
* this call fails, the device state is unchanged.
*/
mutex_lock(&hcd->bandwidth_mutex);
mutex_lock(hcd->bandwidth_mutex);
ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
if (ret < 0) {
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
usb_autosuspend_device(dev);
goto free_interfaces;
}
Expand All @@ -1761,11 +1761,11 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
if (!cp) {
usb_set_device_state(dev, USB_STATE_ADDRESS);
usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
usb_autosuspend_device(dev);
goto free_interfaces;
}
mutex_unlock(&hcd->bandwidth_mutex);
mutex_unlock(hcd->bandwidth_mutex);
usb_set_device_state(dev, USB_STATE_CONFIGURED);

/* Initialize the new interface structures and the
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/usb/hcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct usb_hcd {
* bandwidth_mutex should be dropped after a successful control message
* to the device, or resetting the bandwidth after a failed attempt.
*/
struct mutex bandwidth_mutex;
struct mutex *bandwidth_mutex;


#define HCD_BUFFER_POOLS 4
Expand Down

0 comments on commit 0cdbf21

Please sign in to comment.