aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-16 11:46:03 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-16 11:46:03 -0500
commitd59abb9325ae5eb8fd28440d80f820b945887541 (patch)
tree6ba86796569a8b478a959c2c76c8bfb2bde34522 /drivers/usb/core
parent319e2e3f63c348a9b66db4667efa73178e18b17d (diff)
parent3d724fa513cd1bd06d3457ccda36941f3606d048 (diff)
Merge branch 3.13-rc4 into usb-next
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/config.c7
-rw-r--r--drivers/usb/core/driver.c4
-rw-r--r--drivers/usb/core/hcd-pci.c1
-rw-r--r--drivers/usb/core/hcd.c38
-rw-r--r--drivers/usb/core/hub.c85
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/core/urb.c4
7 files changed, 86 insertions, 56 deletions
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index a6b2cabe7930..548d1996590f 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -651,10 +651,6 @@ void usb_destroy_configuration(struct usb_device *dev)
651 * 651 *
652 * hub-only!! ... and only in reset path, or usb_new_device() 652 * hub-only!! ... and only in reset path, or usb_new_device()
653 * (used by real hubs and virtual root hubs) 653 * (used by real hubs and virtual root hubs)
654 *
655 * NOTE: if this is a WUSB device and is not authorized, we skip the
656 * whole thing. A non-authorized USB device has no
657 * configurations.
658 */ 654 */
659int usb_get_configuration(struct usb_device *dev) 655int usb_get_configuration(struct usb_device *dev)
660{ 656{
@@ -666,8 +662,6 @@ int usb_get_configuration(struct usb_device *dev)
666 struct usb_config_descriptor *desc; 662 struct usb_config_descriptor *desc;
667 663
668 cfgno = 0; 664 cfgno = 0;
669 if (dev->authorized == 0) /* Not really an error */
670 goto out_not_authorized;
671 result = -ENOMEM; 665 result = -ENOMEM;
672 if (ncfg > USB_MAXCONFIG) { 666 if (ncfg > USB_MAXCONFIG) {
673 dev_warn(ddev, "too many configurations: %d, " 667 dev_warn(ddev, "too many configurations: %d, "
@@ -751,7 +745,6 @@ int usb_get_configuration(struct usb_device *dev)
751 745
752err: 746err:
753 kfree(desc); 747 kfree(desc);
754out_not_authorized:
755 dev->descriptor.bNumConfigurations = cfgno; 748 dev->descriptor.bNumConfigurations = cfgno;
756err2: 749err2:
757 if (result == -ENOMEM) 750 if (result == -ENOMEM)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 47aade2a5e74..8d989b1d3dc5 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -839,7 +839,7 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver,
839 return -ENODEV; 839 return -ENODEV;
840 840
841 new_udriver->drvwrap.for_devices = 1; 841 new_udriver->drvwrap.for_devices = 1;
842 new_udriver->drvwrap.driver.name = (char *) new_udriver->name; 842 new_udriver->drvwrap.driver.name = new_udriver->name;
843 new_udriver->drvwrap.driver.bus = &usb_bus_type; 843 new_udriver->drvwrap.driver.bus = &usb_bus_type;
844 new_udriver->drvwrap.driver.probe = usb_probe_device; 844 new_udriver->drvwrap.driver.probe = usb_probe_device;
845 new_udriver->drvwrap.driver.remove = usb_unbind_device; 845 new_udriver->drvwrap.driver.remove = usb_unbind_device;
@@ -900,7 +900,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
900 return -ENODEV; 900 return -ENODEV;
901 901
902 new_driver->drvwrap.for_devices = 0; 902 new_driver->drvwrap.for_devices = 0;
903 new_driver->drvwrap.driver.name = (char *) new_driver->name; 903 new_driver->drvwrap.driver.name = new_driver->name;
904 new_driver->drvwrap.driver.bus = &usb_bus_type; 904 new_driver->drvwrap.driver.bus = &usb_bus_type;
905 new_driver->drvwrap.driver.probe = usb_probe_interface; 905 new_driver->drvwrap.driver.probe = usb_probe_interface;
906 new_driver->drvwrap.driver.remove = usb_unbind_interface; 906 new_driver->drvwrap.driver.remove = usb_unbind_interface;
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index dfe9d0f22978..d59d99347d54 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -282,6 +282,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
282 282
283 if (retval != 0) 283 if (retval != 0)
284 goto unmap_registers; 284 goto unmap_registers;
285 device_wakeup_enable(hcd->self.controller);
285 286
286 if (pci_dev_run_wake(dev)) 287 if (pci_dev_run_wake(dev))
287 pm_runtime_put_noidle(&dev->dev); 288 pm_runtime_put_noidle(&dev->dev);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 6bffb8c87bc9..6297c9e50de2 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -44,6 +44,7 @@
44 44
45#include <linux/usb.h> 45#include <linux/usb.h>
46#include <linux/usb/hcd.h> 46#include <linux/usb/hcd.h>
47#include <linux/usb/phy.h>
47 48
48#include "usb.h" 49#include "usb.h"
49 50
@@ -2588,6 +2589,24 @@ int usb_add_hcd(struct usb_hcd *hcd,
2588 int retval; 2589 int retval;
2589 struct usb_device *rhdev; 2590 struct usb_device *rhdev;
2590 2591
2592 if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy) {
2593 struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);
2594
2595 if (IS_ERR(phy)) {
2596 retval = PTR_ERR(phy);
2597 if (retval == -EPROBE_DEFER)
2598 return retval;
2599 } else {
2600 retval = usb_phy_init(phy);
2601 if (retval) {
2602 usb_put_phy(phy);
2603 return retval;
2604 }
2605 hcd->phy = phy;
2606 hcd->remove_phy = 1;
2607 }
2608 }
2609
2591 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); 2610 dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
2592 2611
2593 /* Keep old behaviour if authorized_default is not in [0, 1]. */ 2612 /* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2603,7 +2622,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
2603 */ 2622 */
2604 if ((retval = hcd_buffer_create(hcd)) != 0) { 2623 if ((retval = hcd_buffer_create(hcd)) != 0) {
2605 dev_dbg(hcd->self.controller, "pool alloc failed\n"); 2624 dev_dbg(hcd->self.controller, "pool alloc failed\n");
2606 return retval; 2625 goto err_remove_phy;
2607 } 2626 }
2608 2627
2609 if ((retval = usb_register_bus(&hcd->self)) < 0) 2628 if ((retval = usb_register_bus(&hcd->self)) < 0)
@@ -2693,12 +2712,6 @@ int usb_add_hcd(struct usb_hcd *hcd,
2693 if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) 2712 if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
2694 usb_hcd_poll_rh_status(hcd); 2713 usb_hcd_poll_rh_status(hcd);
2695 2714
2696 /*
2697 * Host controllers don't generate their own wakeup requests;
2698 * they only forward requests from the root hub. Therefore
2699 * controllers should always be enabled for remote wakeup.
2700 */
2701 device_wakeup_enable(hcd->self.controller);
2702 return retval; 2715 return retval;
2703 2716
2704error_create_attr_group: 2717error_create_attr_group:
@@ -2734,6 +2747,12 @@ err_allocate_root_hub:
2734 usb_deregister_bus(&hcd->self); 2747 usb_deregister_bus(&hcd->self);
2735err_register_bus: 2748err_register_bus:
2736 hcd_buffer_destroy(hcd); 2749 hcd_buffer_destroy(hcd);
2750err_remove_phy:
2751 if (hcd->remove_phy && hcd->phy) {
2752 usb_phy_shutdown(hcd->phy);
2753 usb_put_phy(hcd->phy);
2754 hcd->phy = NULL;
2755 }
2737 return retval; 2756 return retval;
2738} 2757}
2739EXPORT_SYMBOL_GPL(usb_add_hcd); 2758EXPORT_SYMBOL_GPL(usb_add_hcd);
@@ -2806,6 +2825,11 @@ void usb_remove_hcd(struct usb_hcd *hcd)
2806 usb_put_dev(hcd->self.root_hub); 2825 usb_put_dev(hcd->self.root_hub);
2807 usb_deregister_bus(&hcd->self); 2826 usb_deregister_bus(&hcd->self);
2808 hcd_buffer_destroy(hcd); 2827 hcd_buffer_destroy(hcd);
2828 if (hcd->remove_phy && hcd->phy) {
2829 usb_phy_shutdown(hcd->phy);
2830 usb_put_phy(hcd->phy);
2831 hcd->phy = NULL;
2832 }
2809} 2833}
2810EXPORT_SYMBOL_GPL(usb_remove_hcd); 2834EXPORT_SYMBOL_GPL(usb_remove_hcd);
2811 2835
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bd9dc3504b51..162e94dbed53 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2235,17 +2235,13 @@ static int usb_enumerate_device(struct usb_device *udev)
2235 return err; 2235 return err;
2236 } 2236 }
2237 } 2237 }
2238 if (udev->wusb == 1 && udev->authorized == 0) { 2238
2239 udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2239 /* read the standard strings and cache them if present */
2240 udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2240 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
2241 udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2241 udev->manufacturer = usb_cache_string(udev,
2242 } else { 2242 udev->descriptor.iManufacturer);
2243 /* read the standard strings and cache them if present */ 2243 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2244 udev->product = usb_cache_string(udev, udev->descriptor.iProduct); 2244
2245 udev->manufacturer = usb_cache_string(udev,
2246 udev->descriptor.iManufacturer);
2247 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2248 }
2249 err = usb_enumerate_device_otg(udev); 2245 err = usb_enumerate_device_otg(udev);
2250 if (err < 0) 2246 if (err < 0)
2251 return err; 2247 return err;
@@ -2427,16 +2423,6 @@ int usb_deauthorize_device(struct usb_device *usb_dev)
2427 usb_dev->authorized = 0; 2423 usb_dev->authorized = 0;
2428 usb_set_configuration(usb_dev, -1); 2424 usb_set_configuration(usb_dev, -1);
2429 2425
2430 kfree(usb_dev->product);
2431 usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2432 kfree(usb_dev->manufacturer);
2433 usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2434 kfree(usb_dev->serial);
2435 usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2436
2437 usb_destroy_configuration(usb_dev);
2438 usb_dev->descriptor.bNumConfigurations = 0;
2439
2440out_unauthorized: 2426out_unauthorized:
2441 usb_unlock_device(usb_dev); 2427 usb_unlock_device(usb_dev);
2442 return 0; 2428 return 0;
@@ -2464,17 +2450,7 @@ int usb_authorize_device(struct usb_device *usb_dev)
2464 goto error_device_descriptor; 2450 goto error_device_descriptor;
2465 } 2451 }
2466 2452
2467 kfree(usb_dev->product);
2468 usb_dev->product = NULL;
2469 kfree(usb_dev->manufacturer);
2470 usb_dev->manufacturer = NULL;
2471 kfree(usb_dev->serial);
2472 usb_dev->serial = NULL;
2473
2474 usb_dev->authorized = 1; 2453 usb_dev->authorized = 1;
2475 result = usb_enumerate_device(usb_dev);
2476 if (result < 0)
2477 goto error_enumerate;
2478 /* Choose and set the configuration. This registers the interfaces 2454 /* Choose and set the configuration. This registers the interfaces
2479 * with the driver core and lets interface drivers bind to them. 2455 * with the driver core and lets interface drivers bind to them.
2480 */ 2456 */
@@ -2490,7 +2466,6 @@ int usb_authorize_device(struct usb_device *usb_dev)
2490 } 2466 }
2491 dev_info(&usb_dev->dev, "authorized to connect\n"); 2467 dev_info(&usb_dev->dev, "authorized to connect\n");
2492 2468
2493error_enumerate:
2494error_device_descriptor: 2469error_device_descriptor:
2495 usb_autosuspend_device(usb_dev); 2470 usb_autosuspend_device(usb_dev);
2496error_autoresume: 2471error_autoresume:
@@ -2523,6 +2498,21 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
2523#define HUB_LONG_RESET_TIME 200 2498#define HUB_LONG_RESET_TIME 200
2524#define HUB_RESET_TIMEOUT 800 2499#define HUB_RESET_TIMEOUT 800
2525 2500
2501/*
2502 * "New scheme" enumeration causes an extra state transition to be
2503 * exposed to an xhci host and causes USB3 devices to receive control
2504 * commands in the default state. This has been seen to cause
2505 * enumeration failures, so disable this enumeration scheme for USB3
2506 * devices.
2507 */
2508static bool use_new_scheme(struct usb_device *udev, int retry)
2509{
2510 if (udev->speed == USB_SPEED_SUPER)
2511 return false;
2512
2513 return USE_NEW_SCHEME(retry);
2514}
2515
2526static int hub_port_reset(struct usb_hub *hub, int port1, 2516static int hub_port_reset(struct usb_hub *hub, int port1,
2527 struct usb_device *udev, unsigned int delay, bool warm); 2517 struct usb_device *udev, unsigned int delay, bool warm);
2528 2518
@@ -3981,6 +3971,20 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
3981 } 3971 }
3982} 3972}
3983 3973
3974static int hub_enable_device(struct usb_device *udev)
3975{
3976 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3977
3978 if (!hcd->driver->enable_device)
3979 return 0;
3980 if (udev->state == USB_STATE_ADDRESS)
3981 return 0;
3982 if (udev->state != USB_STATE_DEFAULT)
3983 return -EINVAL;
3984
3985 return hcd->driver->enable_device(hcd, udev);
3986}
3987
3984/* Reset device, (re)assign address, get device descriptor. 3988/* Reset device, (re)assign address, get device descriptor.
3985 * Device connection must be stable, no more debouncing needed. 3989 * Device connection must be stable, no more debouncing needed.
3986 * Returns device in USB_STATE_ADDRESS, except on error. 3990 * Returns device in USB_STATE_ADDRESS, except on error.
@@ -4093,7 +4097,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4093 * this area, and this is how Linux has done it for ages. 4097 * this area, and this is how Linux has done it for ages.
4094 * Change it cautiously. 4098 * Change it cautiously.
4095 * 4099 *
4096 * NOTE: If USE_NEW_SCHEME() is true we will start by issuing 4100 * NOTE: If use_new_scheme() is true we will start by issuing
4097 * a 64-byte GET_DESCRIPTOR request. This is what Windows does, 4101 * a 64-byte GET_DESCRIPTOR request. This is what Windows does,
4098 * so it may help with some non-standards-compliant devices. 4102 * so it may help with some non-standards-compliant devices.
4099 * Otherwise we start with SET_ADDRESS and then try to read the 4103 * Otherwise we start with SET_ADDRESS and then try to read the
@@ -4101,10 +4105,17 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4101 * value. 4105 * value.
4102 */ 4106 */
4103 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { 4107 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
4104 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) { 4108 bool did_new_scheme = false;
4109
4110 if (use_new_scheme(udev, retry_counter)) {
4105 struct usb_device_descriptor *buf; 4111 struct usb_device_descriptor *buf;
4106 int r = 0; 4112 int r = 0;
4107 4113
4114 did_new_scheme = true;
4115 retval = hub_enable_device(udev);
4116 if (retval < 0)
4117 goto fail;
4118
4108#define GET_DESCRIPTOR_BUFSIZE 64 4119#define GET_DESCRIPTOR_BUFSIZE 64
4109 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO); 4120 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO);
4110 if (!buf) { 4121 if (!buf) {
@@ -4193,7 +4204,11 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4193 * - read ep0 maxpacket even for high and low speed, 4204 * - read ep0 maxpacket even for high and low speed,
4194 */ 4205 */
4195 msleep(10); 4206 msleep(10);
4196 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) 4207 /* use_new_scheme() checks the speed which may have
4208 * changed since the initial look so we cache the result
4209 * in did_new_scheme
4210 */
4211 if (did_new_scheme)
4197 break; 4212 break;
4198 } 4213 }
4199 4214
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 12924dbfdc2c..8f37063c0a49 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -98,9 +98,6 @@ static const struct usb_device_id usb_quirk_list[] = {
98 /* Alcor Micro Corp. Hub */ 98 /* Alcor Micro Corp. Hub */
99 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, 99 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
100 100
101 /* MicroTouch Systems touchscreen */
102 { USB_DEVICE(0x0596, 0x051e), .driver_info = USB_QUIRK_RESET_RESUME },
103
104 /* appletouch */ 101 /* appletouch */
105 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, 102 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
106 103
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index e62208356c89..07c58af6b5c0 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -492,9 +492,9 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
492 /* too small? */ 492 /* too small? */
493 switch (dev->speed) { 493 switch (dev->speed) {
494 case USB_SPEED_WIRELESS: 494 case USB_SPEED_WIRELESS:
495 if (urb->interval < 6) 495 if ((urb->interval < 6)
496 && (xfertype == USB_ENDPOINT_XFER_INT))
496 return -EINVAL; 497 return -EINVAL;
497 break;
498 default: 498 default:
499 if (urb->interval <= 0) 499 if (urb->interval <= 0)
500 return -EINVAL; 500 return -EINVAL;