diff options
| author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2010-10-15 11:55:24 -0400 |
|---|---|---|
| committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2011-03-13 21:07:14 -0400 |
| commit | d673bfcbfffdeb56064a6b1ee047b85590bed76c (patch) | |
| tree | 50a4efa53b8ca6815ca25292136e7990425f0d36 | |
| parent | 23e0d1066f429ab44305e96fbff13f1793886277 (diff) | |
usb: Change usb_hcd->bandwidth_mutex to a pointer.
Change the bandwith_mutex in struct usb_hcd to a pointer. This will allow
the pointer to be shared across usb_hcds for the upcoming work to split
the xHCI driver roothub into a USB 2.0/1.1 and a USB 3.0 bus.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
| -rw-r--r-- | drivers/usb/core/hcd.c | 11 | ||||
| -rw-r--r-- | drivers/usb/core/hub.c | 8 | ||||
| -rw-r--r-- | drivers/usb/core/message.c | 22 | ||||
| -rw-r--r-- | include/linux/usb/hcd.h | 2 |
4 files changed, 26 insertions, 17 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 40c7a46ba7d3..3ba27118adc5 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
| @@ -2191,6 +2191,15 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, | |||
| 2191 | dev_dbg (dev, "hcd alloc failed\n"); | 2191 | dev_dbg (dev, "hcd alloc failed\n"); |
| 2192 | return NULL; | 2192 | return NULL; |
| 2193 | } | 2193 | } |
| 2194 | hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), | ||
| 2195 | GFP_KERNEL); | ||
| 2196 | if (!hcd->bandwidth_mutex) { | ||
| 2197 | kfree(hcd); | ||
| 2198 | dev_dbg(dev, "hcd bandwidth mutex alloc failed\n"); | ||
| 2199 | return NULL; | ||
| 2200 | } | ||
| 2201 | mutex_init(hcd->bandwidth_mutex); | ||
| 2202 | |||
| 2194 | dev_set_drvdata(dev, hcd); | 2203 | dev_set_drvdata(dev, hcd); |
| 2195 | kref_init(&hcd->kref); | 2204 | kref_init(&hcd->kref); |
| 2196 | 2205 | ||
| @@ -2205,7 +2214,6 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, | |||
| 2205 | #ifdef CONFIG_USB_SUSPEND | 2214 | #ifdef CONFIG_USB_SUSPEND |
| 2206 | INIT_WORK(&hcd->wakeup_work, hcd_resume_work); | 2215 | INIT_WORK(&hcd->wakeup_work, hcd_resume_work); |
| 2207 | #endif | 2216 | #endif |
| 2208 | mutex_init(&hcd->bandwidth_mutex); | ||
| 2209 | 2217 | ||
| 2210 | hcd->driver = driver; | 2218 | hcd->driver = driver; |
| 2211 | hcd->product_desc = (driver->product_desc) ? driver->product_desc : | 2219 | hcd->product_desc = (driver->product_desc) ? driver->product_desc : |
| @@ -2218,6 +2226,7 @@ static void hcd_release (struct kref *kref) | |||
| 2218 | { | 2226 | { |
| 2219 | struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); | 2227 | struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); |
| 2220 | 2228 | ||
| 2229 | kfree(hcd->bandwidth_mutex); | ||
| 2221 | kfree(hcd); | 2230 | kfree(hcd); |
| 2222 | } | 2231 | } |
| 2223 | 2232 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 0eb27006f846..825d803720b3 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
| @@ -3776,13 +3776,13 @@ static int usb_reset_and_verify_device(struct usb_device *udev) | |||
| 3776 | if (!udev->actconfig) | 3776 | if (!udev->actconfig) |
| 3777 | goto done; | 3777 | goto done; |
| 3778 | 3778 | ||
| 3779 | mutex_lock(&hcd->bandwidth_mutex); | 3779 | mutex_lock(hcd->bandwidth_mutex); |
| 3780 | ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL); | 3780 | ret = usb_hcd_alloc_bandwidth(udev, udev->actconfig, NULL, NULL); |
| 3781 | if (ret < 0) { | 3781 | if (ret < 0) { |
| 3782 | dev_warn(&udev->dev, | 3782 | dev_warn(&udev->dev, |
| 3783 | "Busted HC? Not enough HCD resources for " | 3783 | "Busted HC? Not enough HCD resources for " |
| 3784 | "old configuration.\n"); | 3784 | "old configuration.\n"); |
| 3785 | mutex_unlock(&hcd->bandwidth_mutex); | 3785 | mutex_unlock(hcd->bandwidth_mutex); |
| 3786 | goto re_enumerate; | 3786 | goto re_enumerate; |
| 3787 | } | 3787 | } |
| 3788 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 3788 | ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| @@ -3793,10 +3793,10 @@ static int usb_reset_and_verify_device(struct usb_device *udev) | |||
| 3793 | dev_err(&udev->dev, | 3793 | dev_err(&udev->dev, |
| 3794 | "can't restore configuration #%d (error=%d)\n", | 3794 | "can't restore configuration #%d (error=%d)\n", |
| 3795 | udev->actconfig->desc.bConfigurationValue, ret); | 3795 | udev->actconfig->desc.bConfigurationValue, ret); |
| 3796 | mutex_unlock(&hcd->bandwidth_mutex); | 3796 | mutex_unlock(hcd->bandwidth_mutex); |
| 3797 | goto re_enumerate; | 3797 | goto re_enumerate; |
| 3798 | } | 3798 | } |
| 3799 | mutex_unlock(&hcd->bandwidth_mutex); | 3799 | mutex_unlock(hcd->bandwidth_mutex); |
| 3800 | usb_set_device_state(udev, USB_STATE_CONFIGURED); | 3800 | usb_set_device_state(udev, USB_STATE_CONFIGURED); |
| 3801 | 3801 | ||
| 3802 | /* Put interfaces back into the same altsettings as before. | 3802 | /* Put interfaces back into the same altsettings as before. |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 832487423826..5701e857392b 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -1284,12 +1284,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
| 1284 | /* Make sure we have enough bandwidth for this alternate interface. | 1284 | /* Make sure we have enough bandwidth for this alternate interface. |
| 1285 | * Remove the current alt setting and add the new alt setting. | 1285 | * Remove the current alt setting and add the new alt setting. |
| 1286 | */ | 1286 | */ |
| 1287 | mutex_lock(&hcd->bandwidth_mutex); | 1287 | mutex_lock(hcd->bandwidth_mutex); |
| 1288 | ret = usb_hcd_alloc_bandwidth(dev, NULL, iface->cur_altsetting, alt); | 1288 | ret = usb_hcd_alloc_bandwidth(dev, NULL, iface->cur_altsetting, alt); |
| 1289 | if (ret < 0) { | 1289 | if (ret < 0) { |
| 1290 | dev_info(&dev->dev, "Not enough bandwidth for altsetting %d\n", | 1290 | dev_info(&dev->dev, "Not enough bandwidth for altsetting %d\n", |
| 1291 | alternate); | 1291 | alternate); |
| 1292 | mutex_unlock(&hcd->bandwidth_mutex); | 1292 | mutex_unlock(hcd->bandwidth_mutex); |
| 1293 | return ret; | 1293 | return ret; |
| 1294 | } | 1294 | } |
| 1295 | 1295 | ||
| @@ -1311,10 +1311,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) | |||
| 1311 | } else if (ret < 0) { | 1311 | } else if (ret < 0) { |
| 1312 | /* Re-instate the old alt setting */ | 1312 | /* Re-instate the old alt setting */ |
| 1313 | usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting); | 1313 | usb_hcd_alloc_bandwidth(dev, NULL, alt, iface->cur_altsetting); |
| 1314 | mutex_unlock(&hcd->bandwidth_mutex); | 1314 | mutex_unlock(hcd->bandwidth_mutex); |
| 1315 | return ret; | 1315 | return ret; |
| 1316 | } | 1316 | } |
| 1317 | mutex_unlock(&hcd->bandwidth_mutex); | 1317 | mutex_unlock(hcd->bandwidth_mutex); |
| 1318 | 1318 | ||
| 1319 | /* FIXME drivers shouldn't need to replicate/bugfix the logic here | 1319 | /* FIXME drivers shouldn't need to replicate/bugfix the logic here |
| 1320 | * when they implement async or easily-killable versions of this or | 1320 | * when they implement async or easily-killable versions of this or |
| @@ -1413,7 +1413,7 @@ int usb_reset_configuration(struct usb_device *dev) | |||
| 1413 | 1413 | ||
| 1414 | config = dev->actconfig; | 1414 | config = dev->actconfig; |
| 1415 | retval = 0; | 1415 | retval = 0; |
| 1416 | mutex_lock(&hcd->bandwidth_mutex); | 1416 | mutex_lock(hcd->bandwidth_mutex); |
| 1417 | /* Make sure we have enough bandwidth for each alternate setting 0 */ | 1417 | /* Make sure we have enough bandwidth for each alternate setting 0 */ |
| 1418 | for (i = 0; i < config->desc.bNumInterfaces; i++) { | 1418 | for (i = 0; i < config->desc.bNumInterfaces; i++) { |
| 1419 | struct usb_interface *intf = config->interface[i]; | 1419 | struct usb_interface *intf = config->interface[i]; |
| @@ -1442,7 +1442,7 @@ reset_old_alts: | |||
| 1442 | usb_hcd_alloc_bandwidth(dev, NULL, | 1442 | usb_hcd_alloc_bandwidth(dev, NULL, |
| 1443 | alt, intf->cur_altsetting); | 1443 | alt, intf->cur_altsetting); |
| 1444 | } | 1444 | } |
| 1445 | mutex_unlock(&hcd->bandwidth_mutex); | 1445 | mutex_unlock(hcd->bandwidth_mutex); |
| 1446 | return retval; | 1446 | return retval; |
| 1447 | } | 1447 | } |
| 1448 | retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 1448 | retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
| @@ -1451,7 +1451,7 @@ reset_old_alts: | |||
| 1451 | NULL, 0, USB_CTRL_SET_TIMEOUT); | 1451 | NULL, 0, USB_CTRL_SET_TIMEOUT); |
| 1452 | if (retval < 0) | 1452 | if (retval < 0) |
| 1453 | goto reset_old_alts; | 1453 | goto reset_old_alts; |
| 1454 | mutex_unlock(&hcd->bandwidth_mutex); | 1454 | mutex_unlock(hcd->bandwidth_mutex); |
| 1455 | 1455 | ||
| 1456 | /* re-init hc/hcd interface/endpoint state */ | 1456 | /* re-init hc/hcd interface/endpoint state */ |
| 1457 | for (i = 0; i < config->desc.bNumInterfaces; i++) { | 1457 | for (i = 0; i < config->desc.bNumInterfaces; i++) { |
| @@ -1739,10 +1739,10 @@ free_interfaces: | |||
| 1739 | * host controller will not allow submissions to dropped endpoints. If | 1739 | * host controller will not allow submissions to dropped endpoints. If |
| 1740 | * this call fails, the device state is unchanged. | 1740 | * this call fails, the device state is unchanged. |
| 1741 | */ | 1741 | */ |
| 1742 | mutex_lock(&hcd->bandwidth_mutex); | 1742 | mutex_lock(hcd->bandwidth_mutex); |
| 1743 | ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); | 1743 | ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); |
| 1744 | if (ret < 0) { | 1744 | if (ret < 0) { |
| 1745 | mutex_unlock(&hcd->bandwidth_mutex); | 1745 | mutex_unlock(hcd->bandwidth_mutex); |
| 1746 | usb_autosuspend_device(dev); | 1746 | usb_autosuspend_device(dev); |
| 1747 | goto free_interfaces; | 1747 | goto free_interfaces; |
| 1748 | } | 1748 | } |
| @@ -1761,11 +1761,11 @@ free_interfaces: | |||
| 1761 | if (!cp) { | 1761 | if (!cp) { |
| 1762 | usb_set_device_state(dev, USB_STATE_ADDRESS); | 1762 | usb_set_device_state(dev, USB_STATE_ADDRESS); |
| 1763 | usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); | 1763 | usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); |
| 1764 | mutex_unlock(&hcd->bandwidth_mutex); | 1764 | mutex_unlock(hcd->bandwidth_mutex); |
| 1765 | usb_autosuspend_device(dev); | 1765 | usb_autosuspend_device(dev); |
| 1766 | goto free_interfaces; | 1766 | goto free_interfaces; |
| 1767 | } | 1767 | } |
| 1768 | mutex_unlock(&hcd->bandwidth_mutex); | 1768 | mutex_unlock(hcd->bandwidth_mutex); |
| 1769 | usb_set_device_state(dev, USB_STATE_CONFIGURED); | 1769 | usb_set_device_state(dev, USB_STATE_CONFIGURED); |
| 1770 | 1770 | ||
| 1771 | /* Initialize the new interface structures and the | 1771 | /* Initialize the new interface structures and the |
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 0be61970074e..836aaa91ee15 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
| @@ -142,7 +142,7 @@ struct usb_hcd { | |||
| 142 | * bandwidth_mutex should be dropped after a successful control message | 142 | * bandwidth_mutex should be dropped after a successful control message |
| 143 | * to the device, or resetting the bandwidth after a failed attempt. | 143 | * to the device, or resetting the bandwidth after a failed attempt. |
| 144 | */ | 144 | */ |
| 145 | struct mutex bandwidth_mutex; | 145 | struct mutex *bandwidth_mutex; |
| 146 | 146 | ||
| 147 | 147 | ||
| 148 | #define HCD_BUFFER_POOLS 4 | 148 | #define HCD_BUFFER_POOLS 4 |
