diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-16 11:46:03 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-16 11:46:03 -0500 |
commit | d59abb9325ae5eb8fd28440d80f820b945887541 (patch) | |
tree | 6ba86796569a8b478a959c2c76c8bfb2bde34522 /drivers/usb/core/hub.c | |
parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) | |
parent | 3d724fa513cd1bd06d3457ccda36941f3606d048 (diff) |
Merge branch 3.13-rc4 into usb-next
Diffstat (limited to 'drivers/usb/core/hub.c')
-rw-r--r-- | drivers/usb/core/hub.c | 85 |
1 files changed, 50 insertions, 35 deletions
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 | |||
2440 | out_unauthorized: | 2426 | out_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 | ||
2493 | error_enumerate: | ||
2494 | error_device_descriptor: | 2469 | error_device_descriptor: |
2495 | usb_autosuspend_device(usb_dev); | 2470 | usb_autosuspend_device(usb_dev); |
2496 | error_autoresume: | 2471 | error_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 | */ | ||
2508 | static 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 | |||
2526 | static int hub_port_reset(struct usb_hub *hub, int port1, | 2516 | static 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 | ||
3974 | static 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 | ||