aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/devio.c14
-rw-r--r--drivers/usb/core/hcd.c5
-rw-r--r--drivers/usb/core/hub.c27
-rw-r--r--drivers/usb/core/of.c3
-rw-r--r--drivers/usb/core/urb.c2
5 files changed, 35 insertions, 16 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index cfc3cff6e8d5..8e6ef671be9b 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -475,11 +475,11 @@ static void snoop_urb(struct usb_device *udev,
475 475
476 if (userurb) { /* Async */ 476 if (userurb) { /* Async */
477 if (when == SUBMIT) 477 if (when == SUBMIT)
478 dev_info(&udev->dev, "userurb %p, ep%d %s-%s, " 478 dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
479 "length %u\n", 479 "length %u\n",
480 userurb, ep, t, d, length); 480 userurb, ep, t, d, length);
481 else 481 else
482 dev_info(&udev->dev, "userurb %p, ep%d %s-%s, " 482 dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
483 "actual_length %u status %d\n", 483 "actual_length %u status %d\n",
484 userurb, ep, t, d, length, 484 userurb, ep, t, d, length,
485 timeout_or_status); 485 timeout_or_status);
@@ -1895,7 +1895,7 @@ static int proc_reapurb(struct usb_dev_state *ps, void __user *arg)
1895 if (as) { 1895 if (as) {
1896 int retval; 1896 int retval;
1897 1897
1898 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 1898 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1899 retval = processcompl(as, (void __user * __user *)arg); 1899 retval = processcompl(as, (void __user * __user *)arg);
1900 free_async(as); 1900 free_async(as);
1901 return retval; 1901 return retval;
@@ -1912,7 +1912,7 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
1912 1912
1913 as = async_getcompleted(ps); 1913 as = async_getcompleted(ps);
1914 if (as) { 1914 if (as) {
1915 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 1915 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1916 retval = processcompl(as, (void __user * __user *)arg); 1916 retval = processcompl(as, (void __user * __user *)arg);
1917 free_async(as); 1917 free_async(as);
1918 } else { 1918 } else {
@@ -2043,7 +2043,7 @@ static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg)
2043 if (as) { 2043 if (as) {
2044 int retval; 2044 int retval;
2045 2045
2046 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 2046 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
2047 retval = processcompl_compat(as, (void __user * __user *)arg); 2047 retval = processcompl_compat(as, (void __user * __user *)arg);
2048 free_async(as); 2048 free_async(as);
2049 return retval; 2049 return retval;
@@ -2060,7 +2060,7 @@ static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *ar
2060 2060
2061 as = async_getcompleted(ps); 2061 as = async_getcompleted(ps);
2062 if (as) { 2062 if (as) {
2063 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 2063 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
2064 retval = processcompl_compat(as, (void __user * __user *)arg); 2064 retval = processcompl_compat(as, (void __user * __user *)arg);
2065 free_async(as); 2065 free_async(as);
2066 } else { 2066 } else {
@@ -2489,7 +2489,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2489#endif 2489#endif
2490 2490
2491 case USBDEVFS_DISCARDURB: 2491 case USBDEVFS_DISCARDURB:
2492 snoop(&dev->dev, "%s: DISCARDURB %p\n", __func__, p); 2492 snoop(&dev->dev, "%s: DISCARDURB %pK\n", __func__, p);
2493 ret = proc_unlinkurb(ps, p); 2493 ret = proc_unlinkurb(ps, p);
2494 break; 2494 break;
2495 2495
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 49550790a3cb..5dea98358c05 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1723,7 +1723,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
1723 if (retval == 0) 1723 if (retval == 0)
1724 retval = -EINPROGRESS; 1724 retval = -EINPROGRESS;
1725 else if (retval != -EIDRM && retval != -EBUSY) 1725 else if (retval != -EIDRM && retval != -EBUSY)
1726 dev_dbg(&udev->dev, "hcd_unlink_urb %p fail %d\n", 1726 dev_dbg(&udev->dev, "hcd_unlink_urb %pK fail %d\n",
1727 urb, retval); 1727 urb, retval);
1728 usb_put_dev(udev); 1728 usb_put_dev(udev);
1729 } 1729 }
@@ -1890,7 +1890,7 @@ rescan:
1890 /* kick hcd */ 1890 /* kick hcd */
1891 unlink1(hcd, urb, -ESHUTDOWN); 1891 unlink1(hcd, urb, -ESHUTDOWN);
1892 dev_dbg (hcd->self.controller, 1892 dev_dbg (hcd->self.controller,
1893 "shutdown urb %p ep%d%s%s\n", 1893 "shutdown urb %pK ep%d%s%s\n",
1894 urb, usb_endpoint_num(&ep->desc), 1894 urb, usb_endpoint_num(&ep->desc),
1895 is_in ? "in" : "out", 1895 is_in ? "in" : "out",
1896 ({ char *s; 1896 ({ char *s;
@@ -2520,6 +2520,7 @@ struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
2520 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), 2520 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
2521 GFP_KERNEL); 2521 GFP_KERNEL);
2522 if (!hcd->bandwidth_mutex) { 2522 if (!hcd->bandwidth_mutex) {
2523 kfree(hcd->address0_mutex);
2523 kfree(hcd); 2524 kfree(hcd);
2524 dev_dbg(dev, "hcd bandwidth mutex alloc failed\n"); 2525 dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
2525 return NULL; 2526 return NULL;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 9dca59ef18b3..b8bb20d7acdb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -362,7 +362,8 @@ static void usb_set_lpm_parameters(struct usb_device *udev)
362} 362}
363 363
364/* USB 2.0 spec Section 11.24.4.5 */ 364/* USB 2.0 spec Section 11.24.4.5 */
365static int get_hub_descriptor(struct usb_device *hdev, void *data) 365static int get_hub_descriptor(struct usb_device *hdev,
366 struct usb_hub_descriptor *desc)
366{ 367{
367 int i, ret, size; 368 int i, ret, size;
368 unsigned dtype; 369 unsigned dtype;
@@ -378,10 +379,18 @@ static int get_hub_descriptor(struct usb_device *hdev, void *data)
378 for (i = 0; i < 3; i++) { 379 for (i = 0; i < 3; i++) {
379 ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), 380 ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
380 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB, 381 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
381 dtype << 8, 0, data, size, 382 dtype << 8, 0, desc, size,
382 USB_CTRL_GET_TIMEOUT); 383 USB_CTRL_GET_TIMEOUT);
383 if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2)) 384 if (hub_is_superspeed(hdev)) {
385 if (ret == size)
386 return ret;
387 } else if (ret >= USB_DT_HUB_NONVAR_SIZE + 2) {
388 /* Make sure we have the DeviceRemovable field. */
389 size = USB_DT_HUB_NONVAR_SIZE + desc->bNbrPorts / 8 + 1;
390 if (ret < size)
391 return -EMSGSIZE;
384 return ret; 392 return ret;
393 }
385 } 394 }
386 return -EINVAL; 395 return -EINVAL;
387} 396}
@@ -1313,7 +1322,7 @@ static int hub_configure(struct usb_hub *hub,
1313 } 1322 }
1314 mutex_init(&hub->status_mutex); 1323 mutex_init(&hub->status_mutex);
1315 1324
1316 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); 1325 hub->descriptor = kzalloc(sizeof(*hub->descriptor), GFP_KERNEL);
1317 if (!hub->descriptor) { 1326 if (!hub->descriptor) {
1318 ret = -ENOMEM; 1327 ret = -ENOMEM;
1319 goto fail; 1328 goto fail;
@@ -1321,13 +1330,19 @@ static int hub_configure(struct usb_hub *hub,
1321 1330
1322 /* Request the entire hub descriptor. 1331 /* Request the entire hub descriptor.
1323 * hub->descriptor can handle USB_MAXCHILDREN ports, 1332 * hub->descriptor can handle USB_MAXCHILDREN ports,
1324 * but the hub can/will return fewer bytes here. 1333 * but a (non-SS) hub can/will return fewer bytes here.
1325 */ 1334 */
1326 ret = get_hub_descriptor(hdev, hub->descriptor); 1335 ret = get_hub_descriptor(hdev, hub->descriptor);
1327 if (ret < 0) { 1336 if (ret < 0) {
1328 message = "can't read hub descriptor"; 1337 message = "can't read hub descriptor";
1329 goto fail; 1338 goto fail;
1330 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) { 1339 }
1340
1341 maxchild = USB_MAXCHILDREN;
1342 if (hub_is_superspeed(hdev))
1343 maxchild = min_t(unsigned, maxchild, USB_SS_MAXPORTS);
1344
1345 if (hub->descriptor->bNbrPorts > maxchild) {
1331 message = "hub has too many ports!"; 1346 message = "hub has too many ports!";
1332 ret = -ENODEV; 1347 ret = -ENODEV;
1333 goto fail; 1348 goto fail;
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index d787f195a9a6..d563cbcf76cf 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -53,6 +53,9 @@ EXPORT_SYMBOL_GPL(usb_of_get_child_node);
53 * 53 *
54 * Find the companion device from platform bus. 54 * Find the companion device from platform bus.
55 * 55 *
56 * Takes a reference to the returned struct device which needs to be dropped
57 * after use.
58 *
56 * Return: On success, a pointer to the companion device, %NULL on failure. 59 * Return: On success, a pointer to the companion device, %NULL on failure.
57 */ 60 */
58struct device *usb_of_get_companion_dev(struct device *dev) 61struct device *usb_of_get_companion_dev(struct device *dev)
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index d75cb8c0f7df..47903d510955 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -338,7 +338,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
338 if (!urb || !urb->complete) 338 if (!urb || !urb->complete)
339 return -EINVAL; 339 return -EINVAL;
340 if (urb->hcpriv) { 340 if (urb->hcpriv) {
341 WARN_ONCE(1, "URB %p submitted while active\n", urb); 341 WARN_ONCE(1, "URB %pK submitted while active\n", urb);
342 return -EBUSY; 342 return -EBUSY;
343 } 343 }
344 344