Merge tag 'usb-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 14 Dec 2014 22:57:16 +0000 (14:57 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 14 Dec 2014 22:57:16 +0000 (14:57 -0800)
Pull USB updates from Greg KH:
 "Here's the big set of USB and PHY patches for 3.19-rc1.

  The normal churn in the USB gadget area is in here, as well as xhci
  and other individual USB driver updates.  The PHY tree is also in
  here, as there were dependancies on the USB tree.

  All of these have been in linux-next"

* tag 'usb-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (351 commits)
  arm: omap3: twl: remove usb phy init data
  usbip: fix error handling in stub_probe()
  usb: gadget: udc: missing curly braces
  USB: mos7720: delete some unneeded code
  wusb: replace memset by memzero_explicit
  usbip: remove unneeded structure
  usb: xhci: fix comment for PORT_DEV_REMOVE
  xhci: don't use the same variable for stopped and halted rings current TD
  xhci: clear extra bits from slot context when setting max exit latency
  xhci: cleanup finish_td function
  USB: adutux: NULL dereferences on disconnect
  usb: chipidea: fix platform_no_drv_owner.cocci warnings
  usb: chipidea: Fixed a few typos in comments
  Documentation: bindings: add doc for the USB2 ChipIdea USB driver
  usb: chipidea: add a usb2 driver for ci13xxx
  usb: chipidea: fix phy handling
  usb: chipidea: remove duplicate dev_set_drvdata for host_start
  usb: chipidea: parameter 'mode' isn't needed for hw_device_reset
  usb: chipidea: add controller reset API
  usb: chipidea: remove flag CI_HDRC_REQUIRE_TRANSCEIVER
  ...

12 files changed:
1  2 
arch/arm/boot/dts/am4372.dtsi
drivers/pinctrl/pinctrl-tegra-xusb.c
drivers/usb/core/hcd.c
drivers/usb/core/hub.c
drivers/usb/gadget/function/f_hid.c
drivers/usb/host/xhci.c
drivers/usb/phy/phy-msm-usb.c
drivers/usb/serial/usb-serial-simple.c
drivers/usb/storage/debug.c
drivers/usb/storage/uas.c
include/linux/pci_ids.h
include/linux/usb/hcd.h

index d42d7865dd53b1c3b3d7ca4c7ff5d508094cd859,e19068d24737b51dbd73ddf3c8203feff89f916a..b62a1cd776cd6a85a65a226937f5b8a7a87d5096
                cache-level = <2>;
        };
  
 +      am43xx_control_module: control_module@4a002000 {
 +              compatible = "syscon";
 +              reg = <0x44e10000 0x7f4>;
 +      };
 +
        am43xx_pinmux: pinmux@44e10800 {
                compatible = "ti,am437-padconf", "pinctrl-single";
                reg = <0x44e10800 0x31c>;
                        reg = <0x480C8000 0x200>;
                        interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>;
                        ti,hwmods = "mailbox";
 +                      #mbox-cells = <1>;
                        ti,mbox-num-users = <4>;
                        ti,mbox-num-fifos = <8>;
                        mbox_wkupm3: wkup_m3 {
                        };
                };
  
 +              tscadc: tscadc@44e0d000 {
 +                      compatible = "ti,am3359-tscadc";
 +                      reg = <0x44e0d000 0x1000>;
 +                      ti,hwmods = "adc_tsc";
 +                      interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
 +                      clocks = <&adc_tsc_fck>;
 +                      clock-names = "fck";
 +                      status = "disabled";
 +
 +                      tsc {
 +                              compatible = "ti,am3359-tsc";
 +                      };
 +
 +                      adc {
 +                              #io-channel-cells = <1>;
 +                              compatible = "ti,am3359-adc";
 +                      };
 +
 +              };
 +
                sham: sham@53100000 {
                        compatible = "ti,omap5-sham";
                        ti,hwmods = "sham";
                                maximum-speed = "high-speed";
                                dr_mode = "otg";
                                status = "disabled";
+                               snps,dis_u3_susphy_quirk;
+                               snps,dis_u2_susphy_quirk;
                        };
                };
  
                                maximum-speed = "high-speed";
                                dr_mode = "otg";
                                status = "disabled";
+                               snps,dis_u3_susphy_quirk;
+                               snps,dis_u2_susphy_quirk;
                        };
                };
  
                        compatible = "mmio-sram";
                        reg = <0x40300000 0x40000>; /* 256k */
                };
 +
 +              dcan0: can@481cc000 {
 +                      compatible = "ti,am4372-d_can", "ti,am3352-d_can";
 +                      ti,hwmods = "d_can0";
 +                      clocks = <&dcan0_fck>;
 +                      clock-names = "fck";
 +                      reg = <0x481cc000 0x2000>;
 +                      syscon-raminit = <&am43xx_control_module 0x644 0>;
 +                      interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
 +                      status = "disabled";
 +              };
 +
 +              dcan1: can@481d0000 {
 +                      compatible = "ti,am4372-d_can", "ti,am3352-d_can";
 +                      ti,hwmods = "d_can1";
 +                      clocks = <&dcan1_fck>;
 +                      clock-names = "fck";
 +                      reg = <0x481d0000 0x2000>;
 +                      syscon-raminit = <&am43xx_control_module 0x644 1>;
 +                      interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
 +                      status = "disabled";
 +              };
        };
  };
  
index 080ec7723ef2e4319810bef820a9578a25895557,a84299b922c8d845ad1cf466fb7c870e98ae168b..753d747d4261142541a1874beadcd8eb06ccf3dd
@@@ -20,7 -20,6 +20,7 @@@
  #include <linux/pinctrl/pinmux.h>
  #include <linux/platform_device.h>
  #include <linux/reset.h>
 +#include <linux/slab.h>
  
  #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h>
  
@@@ -172,7 -171,7 +172,7 @@@ static int tegra_xusb_padctl_parse_subn
                        if (err == -EINVAL)
                                continue;
  
 -                      return err;
 +                      goto out;
                }
  
                config = TEGRA_XUSB_PADCTL_PACK(properties[i].param, value);
                err = pinctrl_utils_add_config(padctl->pinctrl, &configs,
                                               &num_configs, config);
                if (err < 0)
 -                      return err;
 +                      goto out;
        }
  
        if (function)
  
        err = of_property_count_strings(np, "nvidia,lanes");
        if (err < 0)
 -              return err;
 +              goto out;
  
        reserve *= err;
  
        err = pinctrl_utils_reserve_map(padctl->pinctrl, maps, reserved_maps,
                                        num_maps, reserve);
        if (err < 0)
 -              return err;
 +              goto out;
  
        of_property_for_each_string(np, "nvidia,lanes", prop, group) {
                if (function) {
                                        reserved_maps, num_maps, group,
                                        function);
                        if (err < 0)
 -                              return err;
 +                              goto out;
                }
  
                if (num_configs) {
                                        configs, num_configs,
                                        PIN_MAP_TYPE_CONFIGS_GROUP);
                        if (err < 0)
 -                              return err;
 +                              goto out;
                }
        }
  
 -      return 0;
 +      err = 0;
 +
 +out:
 +      kfree(configs);
 +      return err;
  }
  
  static int tegra_xusb_padctl_dt_node_to_map(struct pinctrl_dev *pinctrl,
@@@ -915,7 -910,7 +915,7 @@@ static int tegra_xusb_padctl_probe(stru
                goto reset;
        }
  
-       phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops, NULL);
+       phy = devm_phy_create(&pdev->dev, NULL, &pcie_phy_ops);
        if (IS_ERR(phy)) {
                err = PTR_ERR(phy);
                goto unregister;
        padctl->phys[TEGRA_XUSB_PADCTL_PCIE] = phy;
        phy_set_drvdata(phy, padctl);
  
-       phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops, NULL);
+       phy = devm_phy_create(&pdev->dev, NULL, &sata_phy_ops);
        if (IS_ERR(phy)) {
                err = PTR_ERR(phy);
                goto unregister;
diff --combined drivers/usb/core/hcd.c
index 278be0515e8e05315cdd73ccf427b9bd7b1db0b8,2f2118fa36a8d2bfa4704d22ff1b895ec080b258..11cee55ae397929f90dd2c673f13b899ba23a873
@@@ -2258,6 -2258,10 +2258,6 @@@ int hcd_bus_resume(struct usb_device *r
        return status;
  }
  
 -#endif        /* CONFIG_PM */
 -
 -#ifdef        CONFIG_PM_RUNTIME
 -
  /* Workqueue routine for root-hub remote wakeup */
  static void hcd_resume_work(struct work_struct *work)
  {
@@@ -2289,7 -2293,7 +2289,7 @@@ void usb_hcd_resume_root_hub (struct us
  }
  EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
  
 -#endif        /* CONFIG_PM_RUNTIME */
 +#endif        /* CONFIG_PM */
  
  /*-------------------------------------------------------------------------*/
  
@@@ -2472,7 -2476,7 +2472,7 @@@ struct usb_hcd *usb_create_shared_hcd(c
        init_timer(&hcd->rh_timer);
        hcd->rh_timer.function = rh_timer_func;
        hcd->rh_timer.data = (unsigned long) hcd;
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
        INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
  #endif
  
@@@ -2646,7 -2650,7 +2646,7 @@@ int usb_add_hcd(struct usb_hcd *hcd
                }
        }
  
-       if (IS_ENABLED(CONFIG_GENERIC_PHY)) {
+       if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->phy) {
                struct phy *phy = phy_get(hcd->self.controller, "usb");
  
                if (IS_ERR(phy)) {
                                goto err_phy;
                        }
                        hcd->phy = phy;
+                       hcd->remove_phy = 1;
                }
        }
  
@@@ -2786,7 -2791,7 +2787,7 @@@ error_create_attr_group
        hcd->rh_registered = 0;
        spin_unlock_irq(&hcd_root_hub_lock);
  
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
        cancel_work_sync(&hcd->wakeup_work);
  #endif
        mutex_lock(&usb_bus_list_lock);
@@@ -2812,7 -2817,7 +2813,7 @@@ err_allocate_root_hub
  err_register_bus:
        hcd_buffer_destroy(hcd);
  err_create_buf:
-       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
+       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
                phy_power_off(hcd->phy);
                phy_exit(hcd->phy);
                phy_put(hcd->phy);
@@@ -2854,7 -2859,7 +2855,7 @@@ void usb_remove_hcd(struct usb_hcd *hcd
        hcd->rh_registered = 0;
        spin_unlock_irq (&hcd_root_hub_lock);
  
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
        cancel_work_sync(&hcd->wakeup_work);
  #endif
  
        usb_deregister_bus(&hcd->self);
        hcd_buffer_destroy(hcd);
  
-       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->phy) {
+       if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
                phy_power_off(hcd->phy);
                phy_exit(hcd->phy);
                phy_put(hcd->phy);
diff --combined drivers/usb/core/hub.c
index c9596525ba8c92f2df9b8c146cf5cbce92dfc94b,c1dc42e6af0527609951cbd4da83e815b27d848d..aeb50bb6ba9ca17e345f3e7e737560d03b88abbe
@@@ -1737,7 -1737,7 +1737,7 @@@ static int hub_probe(struct usb_interfa
         * - If user has indicated to prevent autosuspend by passing
         *   usbcore.autosuspend = -1 then keep autosuspend disabled.
         */
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
        if (hdev->dev.power.autosuspend_delay >= 0)
                pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
  #endif
@@@ -2543,11 -2543,14 +2543,14 @@@ int usb_authorize_device(struct usb_dev
                        "can't autoresume for authorization: %d\n", result);
                goto error_autoresume;
        }
-       result = usb_get_device_descriptor(usb_dev, sizeof(usb_dev->descriptor));
-       if (result < 0) {
-               dev_err(&usb_dev->dev, "can't re-read device descriptor for "
-                       "authorization: %d\n", result);
-               goto error_device_descriptor;
+       if (usb_dev->wusb) {
+               result = usb_get_device_descriptor(usb_dev, sizeof(usb_dev->descriptor));
+               if (result < 0) {
+                       dev_err(&usb_dev->dev, "can't re-read device descriptor for "
+                               "authorization: %d\n", result);
+                       goto error_device_descriptor;
+               }
        }
  
        usb_dev->authorized = 1;
@@@ -3449,7 -3452,7 +3452,7 @@@ int usb_port_resume(struct usb_device *
        return status;
  }
  
 -#ifdef        CONFIG_PM_RUNTIME
 +#ifdef        CONFIG_PM
  
  int usb_remote_wakeup(struct usb_device *udev)
  {
@@@ -3907,14 -3910,9 +3910,9 @@@ static void usb_enable_link_state(struc
  static int usb_disable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
                enum usb3_link_state state)
  {
-       int feature;
        switch (state) {
        case USB3_LPM_U1:
-               feature = USB_PORT_FEAT_U1_TIMEOUT;
-               break;
        case USB3_LPM_U2:
-               feature = USB_PORT_FEAT_U2_TIMEOUT;
                break;
        default:
                dev_warn(&udev->dev, "%s: Can't disable non-U1 or U2 state.\n",
@@@ -4856,7 -4854,7 +4854,7 @@@ static void hub_port_connect_change(str
                        udev->state != USB_STATE_NOTATTACHED) {
                if (portstatus & USB_PORT_STAT_ENABLE) {
                        status = 0;             /* Nothing to do */
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
                } else if (udev->state == USB_STATE_SUSPENDED &&
                                udev->persist_enabled) {
                        /* For a suspended device, treat this as a
index ea2b9c37430562b661164490db438a410d7a8e2f,488ac66aae9e3cf9c9346ba25250be424b34160f..6e04e302dc3a85b0dba95cc90c12e97323fa635c
@@@ -12,6 -12,7 +12,7 @@@
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/hid.h>
+ #include <linux/idr.h>
  #include <linux/cdev.h>
  #include <linux/mutex.h>
  #include <linux/poll.h>
  #include <linux/usb/g_hid.h>
  
  #include "u_f.h"
+ #include "u_hid.h"
+ #define HIDG_MINORS   4
  
  static int major, minors;
  static struct class *hidg_class;
+ static DEFINE_IDA(hidg_ida);
+ static DEFINE_MUTEX(hidg_ida_lock); /* protects access to hidg_ida */
  
  /*-------------------------------------------------------------------------*/
  /*                            HID gadget struct                            */
@@@ -160,6 -166,26 +166,26 @@@ static struct usb_descriptor_header *hi
        NULL,
  };
  
+ /*-------------------------------------------------------------------------*/
+ /*                                 Strings                                 */
+ #define CT_FUNC_HID_IDX       0
+ static struct usb_string ct_func_string_defs[] = {
+       [CT_FUNC_HID_IDX].s     = "HID Interface",
+       {},                     /* end of list */
+ };
+ static struct usb_gadget_strings ct_func_string_table = {
+       .language       = 0x0409,       /* en-US */
+       .strings        = ct_func_string_defs,
+ };
+ static struct usb_gadget_strings *ct_func_strings[] = {
+       &ct_func_string_table,
+       NULL,
+ };
  /*-------------------------------------------------------------------------*/
  /*                              Char Device                                */
  
@@@ -396,7 -422,7 +422,7 @@@ static int hidg_setup(struct usb_functi
  
        case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
                  | HID_REQ_SET_REPORT):
 -              VDBG(cdev, "set_report | wLenght=%d\n", ctrl->wLength);
 +              VDBG(cdev, "set_report | wLength=%d\n", ctrl->wLength);
                goto stall;
                break;
  
@@@ -552,13 -578,22 +578,22 @@@ const struct file_operations f_hidg_fop
        .llseek         = noop_llseek,
  };
  
- static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
+ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
  {
        struct usb_ep           *ep;
        struct f_hidg           *hidg = func_to_hidg(f);
+       struct usb_string       *us;
+       struct device           *device;
        int                     status;
        dev_t                   dev;
  
+       /* maybe allocate device-global string IDs, and patch descriptors */
+       us = usb_gstrings_attach(c->cdev, ct_func_strings,
+                                ARRAY_SIZE(ct_func_string_defs));
+       if (IS_ERR(us))
+               return PTR_ERR(us);
+       hidg_interface_desc.iInterface = us[CT_FUNC_HID_IDX].id;
        /* allocate instance-specific interface IDs, and patch descriptors */
        status = usb_interface_id(c, f);
        if (status < 0)
        if (status)
                goto fail_free_descs;
  
-       device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor);
+       device = device_create(hidg_class, NULL, dev, NULL,
+                              "%s%d", "hidg", hidg->minor);
+       if (IS_ERR(device)) {
+               status = PTR_ERR(device);
+               goto del;
+       }
  
        return 0;
+ del:
+       cdev_del(&hidg->cdev);
  fail_free_descs:
        usb_free_all_descriptors(f);
  fail:
        return status;
  }
  
- static void hidg_unbind(struct usb_configuration *c, struct usb_function *f)
+ static inline int hidg_get_minor(void)
  {
-       struct f_hidg *hidg = func_to_hidg(f);
+       int ret;
  
-       device_destroy(hidg_class, MKDEV(major, hidg->minor));
-       cdev_del(&hidg->cdev);
+       ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL);
  
-       /* disable/free request and end point */
-       usb_ep_disable(hidg->in_ep);
-       usb_ep_dequeue(hidg->in_ep, hidg->req);
-       kfree(hidg->req->buf);
-       usb_ep_free_request(hidg->in_ep, hidg->req);
-       usb_free_all_descriptors(f);
+       return ret;
+ }
  
-       kfree(hidg->report_desc);
-       kfree(hidg);
+ static inline struct f_hid_opts *to_f_hid_opts(struct config_item *item)
+ {
+       return container_of(to_config_group(item), struct f_hid_opts,
+                           func_inst.group);
  }
  
- /*-------------------------------------------------------------------------*/
- /*                                 Strings                                 */
+ CONFIGFS_ATTR_STRUCT(f_hid_opts);
+ CONFIGFS_ATTR_OPS(f_hid_opts);
  
- #define CT_FUNC_HID_IDX       0
+ static void hid_attr_release(struct config_item *item)
+ {
+       struct f_hid_opts *opts = to_f_hid_opts(item);
  
- static struct usb_string ct_func_string_defs[] = {
-       [CT_FUNC_HID_IDX].s     = "HID Interface",
-       {},                     /* end of list */
- };
+       usb_put_function_instance(&opts->func_inst);
+ }
  
- static struct usb_gadget_strings ct_func_string_table = {
-       .language       = 0x0409,       /* en-US */
-       .strings        = ct_func_string_defs,
+ static struct configfs_item_operations hidg_item_ops = {
+       .release        = hid_attr_release,
+       .show_attribute = f_hid_opts_attr_show,
+       .store_attribute = f_hid_opts_attr_store,
  };
  
- static struct usb_gadget_strings *ct_func_strings[] = {
-       &ct_func_string_table,
+ #define F_HID_OPT(name, prec, limit)                                  \
+ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
+ {                                                                     \
+       int result;                                                     \
+                                                                       \
+       mutex_lock(&opts->lock);                                        \
+       result = sprintf(page, "%d\n", opts->name);                     \
+       mutex_unlock(&opts->lock);                                      \
+                                                                       \
+       return result;                                                  \
+ }                                                                     \
+                                                                       \
+ static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts,     \
+                                        const char *page, size_t len)  \
+ {                                                                     \
+       int ret;                                                        \
+       u##prec num;                                                    \
+                                                                       \
+       mutex_lock(&opts->lock);                                        \
+       if (opts->refcnt) {                                             \
+               ret = -EBUSY;                                           \
+               goto end;                                               \
+       }                                                               \
+                                                                       \
+       ret = kstrtou##prec(page, 0, &num);                             \
+       if (ret)                                                        \
+               goto end;                                               \
+                                                                       \
+       if (num > limit) {                                              \
+               ret = -EINVAL;                                          \
+               goto end;                                               \
+       }                                                               \
+       opts->name = num;                                               \
+       ret = len;                                                      \
+                                                                       \
+ end:                                                                  \
+       mutex_unlock(&opts->lock);                                      \
+       return ret;                                                     \
+ }                                                                     \
+                                                                       \
+ static struct f_hid_opts_attribute f_hid_opts_##name =                        \
+       __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
+                       f_hid_opts_##name##_store)
+ F_HID_OPT(subclass, 8, 255);
+ F_HID_OPT(protocol, 8, 255);
+ F_HID_OPT(report_length, 16, 65536);
+ static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
+ {
+       int result;
+       mutex_lock(&opts->lock);
+       result = opts->report_desc_length;
+       memcpy(page, opts->report_desc, opts->report_desc_length);
+       mutex_unlock(&opts->lock);
+       return result;
+ }
+ static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
+                                           const char *page, size_t len)
+ {
+       int ret = -EBUSY;
+       char *d;
+       mutex_lock(&opts->lock);
+       if (opts->refcnt)
+               goto end;
+       if (len > PAGE_SIZE) {
+               ret = -ENOSPC;
+               goto end;
+       }
+       d = kmemdup(page, len, GFP_KERNEL);
+       if (!d) {
+               ret = -ENOMEM;
+               goto end;
+       }
+       kfree(opts->report_desc);
+       opts->report_desc = d;
+       opts->report_desc_length = len;
+       opts->report_desc_alloc = true;
+       ret = len;
+ end:
+       mutex_unlock(&opts->lock);
+       return ret;
+ }
+ static struct f_hid_opts_attribute f_hid_opts_report_desc =
+       __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR,
+                       f_hid_opts_report_desc_show,
+                       f_hid_opts_report_desc_store);
+ static struct configfs_attribute *hid_attrs[] = {
+       &f_hid_opts_subclass.attr,
+       &f_hid_opts_protocol.attr,
+       &f_hid_opts_report_length.attr,
+       &f_hid_opts_report_desc.attr,
        NULL,
  };
  
- /*-------------------------------------------------------------------------*/
- /*                             usb_configuration                           */
+ static struct config_item_type hid_func_type = {
+       .ct_item_ops    = &hidg_item_ops,
+       .ct_attrs       = hid_attrs,
+       .ct_owner       = THIS_MODULE,
+ };
  
- int __init hidg_bind_config(struct usb_configuration *c,
-                           struct hidg_func_descriptor *fdesc, int index)
+ static inline void hidg_put_minor(int minor)
  {
-       struct f_hidg *hidg;
-       int status;
+       ida_simple_remove(&hidg_ida, minor);
+ }
  
-       if (index >= minors)
-               return -ENOENT;
+ static void hidg_free_inst(struct usb_function_instance *f)
+ {
+       struct f_hid_opts *opts;
  
-       /* maybe allocate device-global string IDs, and patch descriptors */
-       if (ct_func_string_defs[CT_FUNC_HID_IDX].id == 0) {
-               status = usb_string_id(c->cdev);
-               if (status < 0)
-                       return status;
-               ct_func_string_defs[CT_FUNC_HID_IDX].id = status;
-               hidg_interface_desc.iInterface = status;
+       opts = container_of(f, struct f_hid_opts, func_inst);
+       mutex_lock(&hidg_ida_lock);
+       hidg_put_minor(opts->minor);
+       if (idr_is_empty(&hidg_ida.idr))
+               ghid_cleanup();
+       mutex_unlock(&hidg_ida_lock);
+       if (opts->report_desc_alloc)
+               kfree(opts->report_desc);
+       kfree(opts);
+ }
+ static struct usb_function_instance *hidg_alloc_inst(void)
+ {
+       struct f_hid_opts *opts;
+       struct usb_function_instance *ret;
+       int status = 0;
+       opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+       if (!opts)
+               return ERR_PTR(-ENOMEM);
+       mutex_init(&opts->lock);
+       opts->func_inst.free_func_inst = hidg_free_inst;
+       ret = &opts->func_inst;
+       mutex_lock(&hidg_ida_lock);
+       if (idr_is_empty(&hidg_ida.idr)) {
+               status = ghid_setup(NULL, HIDG_MINORS);
+               if (status)  {
+                       ret = ERR_PTR(status);
+                       kfree(opts);
+                       goto unlock;
+               }
+       }
+       opts->minor = hidg_get_minor();
+       if (opts->minor < 0) {
+               ret = ERR_PTR(opts->minor);
+               kfree(opts);
+               if (idr_is_empty(&hidg_ida.idr))
+                       ghid_cleanup();
+               goto unlock;
        }
+       config_group_init_type_name(&opts->func_inst.group, "", &hid_func_type);
+ unlock:
+       mutex_unlock(&hidg_ida_lock);
+       return ret;
+ }
+ static void hidg_free(struct usb_function *f)
+ {
+       struct f_hidg *hidg;
+       struct f_hid_opts *opts;
+       hidg = func_to_hidg(f);
+       opts = container_of(f->fi, struct f_hid_opts, func_inst);
+       kfree(hidg->report_desc);
+       kfree(hidg);
+       mutex_lock(&opts->lock);
+       --opts->refcnt;
+       mutex_unlock(&opts->lock);
+ }
+ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f)
+ {
+       struct f_hidg *hidg = func_to_hidg(f);
+       device_destroy(hidg_class, MKDEV(major, hidg->minor));
+       cdev_del(&hidg->cdev);
+       /* disable/free request and end point */
+       usb_ep_disable(hidg->in_ep);
+       usb_ep_dequeue(hidg->in_ep, hidg->req);
+       kfree(hidg->req->buf);
+       usb_ep_free_request(hidg->in_ep, hidg->req);
+       usb_free_all_descriptors(f);
+ }
+ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
+ {
+       struct f_hidg *hidg;
+       struct f_hid_opts *opts;
  
        /* allocate and initialize one new instance */
-       hidg = kzalloc(sizeof *hidg, GFP_KERNEL);
+       hidg = kzalloc(sizeof(*hidg), GFP_KERNEL);
        if (!hidg)
-               return -ENOMEM;
-       hidg->minor = index;
-       hidg->bInterfaceSubClass = fdesc->subclass;
-       hidg->bInterfaceProtocol = fdesc->protocol;
-       hidg->report_length = fdesc->report_length;
-       hidg->report_desc_length = fdesc->report_desc_length;
-       hidg->report_desc = kmemdup(fdesc->report_desc,
-                                   fdesc->report_desc_length,
-                                   GFP_KERNEL);
-       if (!hidg->report_desc) {
-               kfree(hidg);
-               return -ENOMEM;
+               return ERR_PTR(-ENOMEM);
+       opts = container_of(fi, struct f_hid_opts, func_inst);
+       mutex_lock(&opts->lock);
+       ++opts->refcnt;
+       hidg->minor = opts->minor;
+       hidg->bInterfaceSubClass = opts->subclass;
+       hidg->bInterfaceProtocol = opts->protocol;
+       hidg->report_length = opts->report_length;
+       hidg->report_desc_length = opts->report_desc_length;
+       if (opts->report_desc) {
+               hidg->report_desc = kmemdup(opts->report_desc,
+                                           opts->report_desc_length,
+                                           GFP_KERNEL);
+               if (!hidg->report_desc) {
+                       kfree(hidg);
+                       mutex_unlock(&opts->lock);
+                       return ERR_PTR(-ENOMEM);
+               }
        }
  
+       mutex_unlock(&opts->lock);
        hidg->func.name    = "hid";
-       hidg->func.strings = ct_func_strings;
        hidg->func.bind    = hidg_bind;
        hidg->func.unbind  = hidg_unbind;
        hidg->func.set_alt = hidg_set_alt;
        hidg->func.disable = hidg_disable;
        hidg->func.setup   = hidg_setup;
+       hidg->func.free_func = hidg_free;
  
        /* this could me made configurable at some point */
        hidg->qlen         = 4;
  
-       status = usb_add_function(c, &hidg->func);
-       if (status)
-               kfree(hidg);
-       return status;
+       return &hidg->func;
  }
  
- int __init ghid_setup(struct usb_gadget *g, int count)
+ DECLARE_USB_FUNCTION_INIT(hid, hidg_alloc_inst, hidg_alloc);
+ MODULE_LICENSE("GPL");
+ MODULE_AUTHOR("Fabien Chouteau");
+ int ghid_setup(struct usb_gadget *g, int count)
  {
        int status;
        dev_t dev;
  
        hidg_class = class_create(THIS_MODULE, "hidg");
+       if (IS_ERR(hidg_class)) {
+               status = PTR_ERR(hidg_class);
+               hidg_class = NULL;
+               return status;
+       }
  
        status = alloc_chrdev_region(&dev, 0, count, "hidg");
-       if (!status) {
-               major = MAJOR(dev);
-               minors = count;
+       if (status) {
+               class_destroy(hidg_class);
+               hidg_class = NULL;
+               return status;
        }
  
-       return status;
+       major = MAJOR(dev);
+       minors = count;
+       return 0;
  }
  
  void ghid_cleanup(void)
diff --combined drivers/usb/host/xhci.c
index cf3413116affd4fcc8ac35d496a8e12fb52f43d3,5be1bff9b4eba0dfe8937dbae8070eb0b2a57260..01fcbb5eb06e7ec3d03bcd81d90941f889c5654a
@@@ -2912,10 -2912,11 +2912,11 @@@ static void xhci_setup_input_ctx_for_qu
  }
  
  void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
-               struct usb_device *udev, unsigned int ep_index)
+                       unsigned int ep_index, struct xhci_td *td)
  {
        struct xhci_dequeue_state deq_state;
        struct xhci_virt_ep *ep;
+       struct usb_device *udev = td->urb->dev;
  
        xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep,
                        "Cleaning up stalled endpoint ring");
         * or it will attempt to resend it on the next doorbell ring.
         */
        xhci_find_new_dequeue_state(xhci, udev->slot_id,
-                       ep_index, ep->stopped_stream, ep->stopped_td,
-                       &deq_state);
+                       ep_index, ep->stopped_stream, td, &deq_state);
  
        if (!deq_state.new_deq_ptr || !deq_state.new_deq_seg)
                return;
@@@ -4009,6 -4009,7 +4009,7 @@@ static int __maybe_unused xhci_change_m
        slot_ctx = xhci_get_slot_ctx(xhci, command->in_ctx);
        slot_ctx->dev_info2 &= cpu_to_le32(~((u32) MAX_EXIT));
        slot_ctx->dev_info2 |= cpu_to_le32(max_exit_latency);
+       slot_ctx->dev_state = 0;
  
        xhci_dbg_trace(xhci, trace_xhci_dbg_context_change,
                        "Set up evaluate context for LPM MEL change.");
        return ret;
  }
  
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
  
  /* BESL to HIRD Encoding array for USB2 LPM */
  static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000,
@@@ -4244,8 -4245,24 +4245,8 @@@ int xhci_update_device(struct usb_hcd *
        return 0;
  }
  
 -#else
 -
 -int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 -                              struct usb_device *udev, int enable)
 -{
 -      return 0;
 -}
 -
 -int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
 -{
 -      return 0;
 -}
 -
 -#endif /* CONFIG_PM_RUNTIME */
 -
  /*---------------------- USB 3.0 Link PM functions ------------------------*/
  
 -#ifdef CONFIG_PM
  /* Service interval in nanoseconds = 2^(bInterval - 1) * 125us * 1000ns / 1us */
  static unsigned long long xhci_service_interval_to_ns(
                struct usb_endpoint_descriptor *desc)
@@@ -4676,17 -4693,6 +4677,17 @@@ int xhci_disable_usb3_lpm_timeout(struc
  }
  #else /* CONFIG_PM */
  
 +int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 +                              struct usb_device *udev, int enable)
 +{
 +      return 0;
 +}
 +
 +int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
 +{
 +      return 0;
 +}
 +
  int xhci_enable_usb3_lpm_timeout(struct usb_hcd *hcd,
                        struct usb_device *udev, enum usb3_link_state state)
  {
index 29be0e654ecce7749d2c921a486a2b0b295722a1,e120d87778b24c69cf42fd7d667eb3b5bc4a900d..000fd892455f7de0f31c94f44aad116d1c244f61
@@@ -708,7 -708,7 +708,7 @@@ static void msm_otg_start_host(struct u
  
  static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
  {
-       struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
+       struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
        struct usb_hcd *hcd;
  
        /*
         * only peripheral configuration.
         */
        if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
-               dev_info(otg->phy->dev, "Host mode is not supported\n");
+               dev_info(otg->usb_phy->dev, "Host mode is not supported\n");
                return -ENODEV;
        }
  
        if (!host) {
-               if (otg->phy->state == OTG_STATE_A_HOST) {
-                       pm_runtime_get_sync(otg->phy->dev);
-                       msm_otg_start_host(otg->phy, 0);
+               if (otg->state == OTG_STATE_A_HOST) {
+                       pm_runtime_get_sync(otg->usb_phy->dev);
+                       msm_otg_start_host(otg->usb_phy, 0);
                        otg->host = NULL;
-                       otg->phy->state = OTG_STATE_UNDEFINED;
+                       otg->state = OTG_STATE_UNDEFINED;
                        schedule_work(&motg->sm_work);
                } else {
                        otg->host = NULL;
        hcd->power_budget = motg->pdata->power_budget;
  
        otg->host = host;
-       dev_dbg(otg->phy->dev, "host driver registered w/ tranceiver\n");
+       dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n");
  
        /*
         * Kick the state machine work, if peripheral is not supported
         * or peripheral is already registered with us.
         */
        if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
-               pm_runtime_get_sync(otg->phy->dev);
+               pm_runtime_get_sync(otg->usb_phy->dev);
                schedule_work(&motg->sm_work);
        }
  
@@@ -782,23 -782,23 +782,23 @@@ static void msm_otg_start_peripheral(st
  static int msm_otg_set_peripheral(struct usb_otg *otg,
                                        struct usb_gadget *gadget)
  {
-       struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
+       struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy);
  
        /*
         * Fail peripheral registration if this board can support
         * only host configuration.
         */
        if (motg->pdata->mode == USB_DR_MODE_HOST) {
-               dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
+               dev_info(otg->usb_phy->dev, "Peripheral mode is not supported\n");
                return -ENODEV;
        }
  
        if (!gadget) {
-               if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
-                       pm_runtime_get_sync(otg->phy->dev);
-                       msm_otg_start_peripheral(otg->phy, 0);
+               if (otg->state == OTG_STATE_B_PERIPHERAL) {
+                       pm_runtime_get_sync(otg->usb_phy->dev);
+                       msm_otg_start_peripheral(otg->usb_phy, 0);
                        otg->gadget = NULL;
-                       otg->phy->state = OTG_STATE_UNDEFINED;
+                       otg->state = OTG_STATE_UNDEFINED;
                        schedule_work(&motg->sm_work);
                } else {
                        otg->gadget = NULL;
                return 0;
        }
        otg->gadget = gadget;
-       dev_dbg(otg->phy->dev, "peripheral driver registered w/ tranceiver\n");
+       dev_dbg(otg->usb_phy->dev,
+               "peripheral driver registered w/ tranceiver\n");
  
        /*
         * Kick the state machine work, if host is not supported
         * or host is already registered with us.
         */
        if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
-               pm_runtime_get_sync(otg->phy->dev);
+               pm_runtime_get_sync(otg->usb_phy->dev);
                schedule_work(&motg->sm_work);
        }
  
@@@ -1170,20 -1171,20 +1171,20 @@@ static void msm_otg_sm_work(struct work
        struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
        struct usb_otg *otg = motg->phy.otg;
  
-       switch (otg->phy->state) {
+       switch (otg->state) {
        case OTG_STATE_UNDEFINED:
-               dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
-               msm_otg_reset(otg->phy);
+               dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n");
+               msm_otg_reset(otg->usb_phy);
                msm_otg_init_sm(motg);
-               otg->phy->state = OTG_STATE_B_IDLE;
+               otg->state = OTG_STATE_B_IDLE;
                /* FALL THROUGH */
        case OTG_STATE_B_IDLE:
-               dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
+               dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n");
                if (!test_bit(ID, &motg->inputs) && otg->host) {
                        /* disable BSV bit */
                        writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
-                       msm_otg_start_host(otg->phy, 1);
-                       otg->phy->state = OTG_STATE_A_HOST;
+                       msm_otg_start_host(otg->usb_phy, 1);
+                       otg->state = OTG_STATE_A_HOST;
                } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
                        switch (motg->chg_state) {
                        case USB_CHG_STATE_UNDEFINED:
                                case USB_CDP_CHARGER:
                                        msm_otg_notify_charger(motg,
                                                        IDEV_CHG_MAX);
-                                       msm_otg_start_peripheral(otg->phy, 1);
-                                       otg->phy->state
+                                       msm_otg_start_peripheral(otg->usb_phy,
+                                                                1);
+                                       otg->state
                                                = OTG_STATE_B_PERIPHERAL;
                                        break;
                                case USB_SDP_CHARGER:
                                        msm_otg_notify_charger(motg, IUNIT);
-                                       msm_otg_start_peripheral(otg->phy, 1);
-                                       otg->phy->state
+                                       msm_otg_start_peripheral(otg->usb_phy,
+                                                                1);
+                                       otg->state
                                                = OTG_STATE_B_PERIPHERAL;
                                        break;
                                default:
                         * is incremented in charger detection work.
                         */
                        if (cancel_delayed_work_sync(&motg->chg_work)) {
-                               pm_runtime_put_sync(otg->phy->dev);
-                               msm_otg_reset(otg->phy);
+                               pm_runtime_put_sync(otg->usb_phy->dev);
+                               msm_otg_reset(otg->usb_phy);
                        }
                        msm_otg_notify_charger(motg, 0);
                        motg->chg_state = USB_CHG_STATE_UNDEFINED;
                        motg->chg_type = USB_INVALID_CHARGER;
                }
  
-               if (otg->phy->state == OTG_STATE_B_IDLE)
-                       pm_runtime_put_sync(otg->phy->dev);
+               if (otg->state == OTG_STATE_B_IDLE)
+                       pm_runtime_put_sync(otg->usb_phy->dev);
                break;
        case OTG_STATE_B_PERIPHERAL:
-               dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
+               dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
                if (!test_bit(B_SESS_VLD, &motg->inputs) ||
                                !test_bit(ID, &motg->inputs)) {
                        msm_otg_notify_charger(motg, 0);
-                       msm_otg_start_peripheral(otg->phy, 0);
+                       msm_otg_start_peripheral(otg->usb_phy, 0);
                        motg->chg_state = USB_CHG_STATE_UNDEFINED;
                        motg->chg_type = USB_INVALID_CHARGER;
-                       otg->phy->state = OTG_STATE_B_IDLE;
-                       msm_otg_reset(otg->phy);
+                       otg->state = OTG_STATE_B_IDLE;
+                       msm_otg_reset(otg->usb_phy);
                        schedule_work(w);
                }
                break;
        case OTG_STATE_A_HOST:
-               dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
+               dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n");
                if (test_bit(ID, &motg->inputs)) {
-                       msm_otg_start_host(otg->phy, 0);
-                       otg->phy->state = OTG_STATE_B_IDLE;
-                       msm_otg_reset(otg->phy);
+                       msm_otg_start_host(otg->usb_phy, 0);
+                       otg->state = OTG_STATE_B_IDLE;
+                       msm_otg_reset(otg->usb_phy);
                        schedule_work(w);
                }
                break;
@@@ -1303,7 -1306,7 +1306,7 @@@ static int msm_otg_mode_show(struct seq
        struct msm_otg *motg = s->private;
        struct usb_otg *otg = motg->phy.otg;
  
-       switch (otg->phy->state) {
+       switch (otg->state) {
        case OTG_STATE_A_HOST:
                seq_puts(s, "host\n");
                break;
@@@ -1353,7 -1356,7 +1356,7 @@@ static ssize_t msm_otg_mode_write(struc
  
        switch (req_mode) {
        case USB_DR_MODE_UNKNOWN:
-               switch (otg->phy->state) {
+               switch (otg->state) {
                case OTG_STATE_A_HOST:
                case OTG_STATE_B_PERIPHERAL:
                        set_bit(ID, &motg->inputs);
                }
                break;
        case USB_DR_MODE_PERIPHERAL:
-               switch (otg->phy->state) {
+               switch (otg->state) {
                case OTG_STATE_B_IDLE:
                case OTG_STATE_A_HOST:
                        set_bit(ID, &motg->inputs);
                }
                break;
        case USB_DR_MODE_HOST:
-               switch (otg->phy->state) {
+               switch (otg->state) {
                case OTG_STATE_B_IDLE:
                case OTG_STATE_B_PERIPHERAL:
                        clear_bit(ID, &motg->inputs);
                goto out;
        }
  
-       pm_runtime_get_sync(otg->phy->dev);
+       pm_runtime_get_sync(otg->usb_phy->dev);
        schedule_work(&motg->sm_work);
  out:
        return status;
@@@ -1505,10 -1508,8 +1508,8 @@@ static int msm_otg_read_dt(struct platf
        }
  
        pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
-       if (!pdata->phy_init_seq) {
-               dev_warn(&pdev->dev, "No space for PHY init sequence\n");
+       if (!pdata->phy_init_seq)
                return 0;
-       }
  
        ret = of_property_read_u32_array(node, "qcom,phy-init-sequence",
                                         pdata->phy_init_seq, words);
@@@ -1530,10 -1531,8 +1531,8 @@@ static int msm_otg_probe(struct platfor
        void __iomem *phy_select;
  
        motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL);
-       if (!motg) {
-               dev_err(&pdev->dev, "unable to allocate msm_otg\n");
+       if (!motg)
                return -ENOMEM;
-       }
  
        pdata = dev_get_platdata(&pdev->dev);
        if (!pdata) {
  
        motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
                                     GFP_KERNEL);
-       if (!motg->phy.otg) {
-               dev_err(&pdev->dev, "unable to allocate msm_otg\n");
+       if (!motg->phy.otg)
                return -ENOMEM;
-       }
  
        phy = &motg->phy;
        phy->dev = &pdev->dev;
  
        phy->io_ops = &msm_otg_io_ops;
  
-       phy->otg->phy = &motg->phy;
+       phy->otg->usb_phy = &motg->phy;
        phy->otg->set_host = msm_otg_set_host;
        phy->otg->set_peripheral = msm_otg_set_peripheral;
  
@@@ -1761,7 -1758,7 +1758,7 @@@ static int msm_otg_remove(struct platfo
        return 0;
  }
  
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
  static int msm_otg_runtime_idle(struct device *dev)
  {
        struct msm_otg *motg = dev_get_drvdata(dev);
         * This 1 sec delay also prevents entering into LPM immediately
         * after asynchronous interrupt.
         */
-       if (otg->phy->state != OTG_STATE_UNDEFINED)
+       if (otg->state != OTG_STATE_UNDEFINED)
                pm_schedule_suspend(dev, 1000);
  
        return -EAGAIN;
index 8bfc47c2982872691eec85e1c44f182b0a18e13d,bc310112eae921fa97c92d251407febafed4a03e..3658662898fcb170fcdca07a8a676383e4d70347
@@@ -56,6 -56,14 +56,14 @@@ DEVICE(funsoft, FUNSOFT_IDS)
        { USB_DEVICE(0x8087, 0x0716) }
  DEVICE(flashloader, FLASHLOADER_IDS);
  
+ /* Google Serial USB SubClass */
+ #define GOOGLE_IDS()                                          \
+       { USB_VENDOR_AND_INTERFACE_INFO(0x18d1,                 \
+                                       USB_CLASS_VENDOR_SPEC,  \
+                                       0x50,                   \
+                                       0x01) }
+ DEVICE(google, GOOGLE_IDS);
  /* ViVOpay USB Serial Driver */
  #define VIVOPAY_IDS()                 \
        { USB_DEVICE(0x1d5f, 0x1004) }  /* ViVOpay 8800 */
@@@ -64,7 -72,7 +72,7 @@@ DEVICE(vivopay, VIVOPAY_IDS)
  /* Motorola USB Phone driver */
  #define MOTO_IDS()                    \
        { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */    \
 -      { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */    \
 +      { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Motorola phone */    \
        { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */         \
        { USB_DEVICE(0x22b8, 0x2c84) }, /* Motorola VE240 phone */      \
        { USB_DEVICE(0x22b8, 0x2c64) }  /* Motorola V950 phone */
@@@ -97,6 -105,7 +105,7 @@@ static struct usb_serial_driver * cons
        &zio_device,
        &funsoft_device,
        &flashloader_device,
+       &google_device,
        &vivopay_device,
        &moto_modem_device,
        &novatel_gps_device,
@@@ -111,6 -120,7 +120,7 @@@ static const struct usb_device_id id_ta
        ZIO_IDS(),
        FUNSOFT_IDS(),
        FLASHLOADER_IDS(),
+       GOOGLE_IDS(),
        VIVOPAY_IDS(),
        MOTO_IDS(),
        NOVATEL_IDS(),
index 2d81e1d8ee307811f471c020c8a3f3854a3e7ebc,05bc379b9e62a229c0a73b9b9e2cf49144eed316..57bf3ad41fb63554ac4ea0bf52b87919e75e3768
@@@ -164,10 -164,10 +164,10 @@@ void usb_stor_show_sense(const struct u
                         unsigned char asc,
                         unsigned char ascq)
  {
 -      const char *what, *keystr;
 +      const char *what, *keystr, *fmt;
  
        keystr = scsi_sense_key_string(key);
 -      what = scsi_extd_sense_format(asc, ascq);
 +      what = scsi_extd_sense_format(asc, ascq, &fmt);
  
        if (keystr == NULL)
                keystr = "(Unknown Key)";
                what = "(unknown ASC/ASCQ)";
  
        usb_stor_dbg(us, "%s: ", keystr);
 -      US_DEBUGPX(what, ascq);
 -      US_DEBUGPX("\n");
 +      if (fmt)
 +              US_DEBUGPX("%s (%s%x)\n", what, fmt, ascq);
 +      else
 +              US_DEBUGPX("%s\n", what);
  }
  
int usb_stor_dbg(const struct us_data *us, const char *fmt, ...)
void usb_stor_dbg(const struct us_data *us, const char *fmt, ...)
  {
        va_list args;
-       int r;
  
        va_start(args, fmt);
  
-       r = dev_vprintk_emit(LOGLEVEL_DEBUG, &us->pusb_dev->dev, fmt, args);
 -      dev_vprintk_emit(7, &us->pusb_dev->dev, fmt, args);
++      dev_vprintk_emit(LOGLEVEL_DEBUG, &us->pusb_dev->dev, fmt, args);
  
        va_end(args);
-       return r;
  }
  EXPORT_SYMBOL_GPL(usb_stor_dbg);
index 4047edfb64e1d25314b2ecea18a37972d75e7874,004ebc12bc21faab4d36a0ac32feb848a65cce51..6cdabdc119a73bc172d5b2e52f024113bde09d3b
@@@ -66,7 -66,7 +66,7 @@@ enum 
  /* Overrides scsi_pointer */
  struct uas_cmd_info {
        unsigned int state;
-       unsigned int stream;
+       unsigned int uas_tag;
        struct urb *cmd_urb;
        struct urb *data_in_urb;
        struct urb *data_out_urb;
@@@ -173,30 -173,15 +173,15 @@@ static void uas_sense(struct urb *urb, 
        cmnd->result = sense_iu->status;
  }
  
- /*
-  * scsi-tags go from 0 - (nr_tags - 1), uas tags need to match stream-ids,
-  * which go from 1 - nr_streams. And we use 1 for untagged commands.
-  */
- static int uas_get_tag(struct scsi_cmnd *cmnd)
- {
-       int tag;
-       if (cmnd->flags & SCMD_TAGGED)
-               tag = cmnd->request->tag + 2;
-       else
-               tag = 1;
-       return tag;
- }
  static void uas_log_cmd_state(struct scsi_cmnd *cmnd, const char *prefix,
                              int status)
  {
        struct uas_cmd_info *ci = (void *)&cmnd->SCp;
+       struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
  
        scmd_printk(KERN_INFO, cmnd,
-                   "%s %d tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ",
-                   prefix, status, uas_get_tag(cmnd),
+                   "%s %d uas-tag %d inflight:%s%s%s%s%s%s%s%s%s%s%s%s ",
+                   prefix, status, cmdinfo->uas_tag,
                    (ci->state & SUBMIT_STATUS_URB)     ? " s-st"  : "",
                    (ci->state & ALLOC_DATA_IN_URB)     ? " a-in"  : "",
                    (ci->state & SUBMIT_DATA_IN_URB)    ? " s-in"  : "",
@@@ -242,7 -227,7 +227,7 @@@ static int uas_try_complete(struct scsi
                              DATA_OUT_URB_INFLIGHT |
                              COMMAND_ABORTED))
                return -EBUSY;
-       devinfo->cmnd[uas_get_tag(cmnd) - 1] = NULL;
+       devinfo->cmnd[cmdinfo->uas_tag - 1] = NULL;
        uas_free_unsubmitted_urbs(cmnd);
        cmnd->scsi_done(cmnd);
        return 0;
@@@ -289,7 -274,7 +274,7 @@@ static void uas_stat_cmplt(struct urb *
        idx = be16_to_cpup(&iu->tag) - 1;
        if (idx >= MAX_CMNDS || !devinfo->cmnd[idx]) {
                dev_err(&urb->dev->dev,
-                       "stat urb: no pending cmd for tag %d\n", idx + 1);
+                       "stat urb: no pending cmd for uas-tag %d\n", idx + 1);
                goto out;
        }
  
@@@ -427,7 -412,8 +412,8 @@@ static struct urb *uas_alloc_data_urb(s
                goto out;
        usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length,
                          uas_data_cmplt, cmnd);
-       urb->stream_id = cmdinfo->stream;
+       if (devinfo->use_streams)
+               urb->stream_id = cmdinfo->uas_tag;
        urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
        urb->sg = sdb->table.sgl;
   out:
@@@ -451,7 -437,8 +437,8 @@@ static struct urb *uas_alloc_sense_urb(
  
        usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
                          uas_stat_cmplt, cmnd->device->host);
-       urb->stream_id = cmdinfo->stream;
+       if (devinfo->use_streams)
+               urb->stream_id = cmdinfo->uas_tag;
        urb->transfer_flags |= URB_FREE_BUFFER;
   out:
        return urb;
@@@ -465,6 -452,7 +452,7 @@@ static struct urb *uas_alloc_cmd_urb(st
  {
        struct usb_device *udev = devinfo->udev;
        struct scsi_device *sdev = cmnd->device;
+       struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
        struct urb *urb = usb_alloc_urb(0, gfp);
        struct command_iu *iu;
        int len;
                goto free;
  
        iu->iu_id = IU_ID_COMMAND;
-       iu->tag = cpu_to_be16(uas_get_tag(cmnd));
+       iu->tag = cpu_to_be16(cmdinfo->uas_tag);
        iu->prio_attr = UAS_SIMPLE_TAG;
        iu->len = len;
        int_to_scsilun(sdev->lun, &iu->lun);
@@@ -608,8 -596,7 +596,7 @@@ static int uas_queuecommand_lck(struct 
        struct uas_dev_info *devinfo = sdev->hostdata;
        struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
        unsigned long flags;
-       unsigned int stream;
-       int err;
+       int idx, err;
  
        BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer));
  
                return 0;
        }
  
-       stream = uas_get_tag(cmnd);
-       if (devinfo->cmnd[stream - 1]) {
+       /* Find a free uas-tag */
+       for (idx = 0; idx < devinfo->qdepth; idx++) {
+               if (!devinfo->cmnd[idx])
+                       break;
+       }
+       if (idx == devinfo->qdepth) {
                spin_unlock_irqrestore(&devinfo->lock, flags);
                return SCSI_MLQUEUE_DEVICE_BUSY;
        }
        cmnd->scsi_done = done;
  
        memset(cmdinfo, 0, sizeof(*cmdinfo));
-       cmdinfo->stream = stream;
+       cmdinfo->uas_tag = idx + 1; /* uas-tag == usb-stream-id, so 1 based */
        cmdinfo->state = SUBMIT_STATUS_URB | ALLOC_CMD_URB | SUBMIT_CMD_URB;
  
        switch (cmnd->sc_data_direction) {
                break;
        }
  
-       if (!devinfo->use_streams) {
+       if (!devinfo->use_streams)
                cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB);
-               cmdinfo->stream = 0;
-       }
  
        err = uas_submit_urbs(cmnd, devinfo, GFP_ATOMIC);
        if (err) {
                uas_add_work(cmdinfo);
        }
  
-       devinfo->cmnd[stream - 1] = cmnd;
+       devinfo->cmnd[idx] = cmnd;
        spin_unlock_irqrestore(&devinfo->lock, flags);
        return 0;
  }
@@@ -702,7 -691,7 +691,7 @@@ static int uas_eh_abort_handler(struct 
        cmdinfo->state |= COMMAND_ABORTED;
  
        /* Drop all refs to this cmnd, kill data urbs to break their ref */
-       devinfo->cmnd[uas_get_tag(cmnd) - 1] = NULL;
+       devinfo->cmnd[cmdinfo->uas_tag - 1] = NULL;
        if (cmdinfo->state & DATA_IN_URB_INFLIGHT)
                data_in_urb = usb_get_urb(cmdinfo->data_in_urb);
        if (cmdinfo->state & DATA_OUT_URB_INFLIGHT)
@@@ -799,7 -788,8 +788,7 @@@ static int uas_slave_configure(struct s
        if (devinfo->flags & US_FL_NO_REPORT_OPCODES)
                sdev->no_report_opcodes = 1;
  
 -      scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
 -      scsi_activate_tcq(sdev, devinfo->qdepth - 2);
 +      scsi_change_queue_depth(sdev, devinfo->qdepth - 2);
        return 0;
  }
  
@@@ -816,14 -806,7 +805,7 @@@ static struct scsi_host_template uas_ho
        .sg_tablesize = SG_NONE,
        .cmd_per_lun = 1,       /* until we override it */
        .skip_settle_delay = 1,
-       /*
-        * The uas drivers expects tags not to be bigger than the maximum
-        * per-device queue depth, which is not true with the blk-mq tag
-        * allocator.
-        */
-       .disable_blk_mq = true,
 -      .ordered_tag = 1,
 +      .use_blk_tags = 1,
  };
  
  #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
diff --combined include/linux/pci_ids.h
index 97fb9f69aaedbba28dc16d6de018116d1b1c3f42,5decad77d8edbc436447e03ab8316b629cc9bf23..e63c02a93f6be81a0a3c1d3f81cde7e798aa7e6a
  #define PCI_DEVICE_ID_AMD_15H_M10H_F3 0x1403
  #define PCI_DEVICE_ID_AMD_15H_M30H_NB_F3 0x141d
  #define PCI_DEVICE_ID_AMD_15H_M30H_NB_F4 0x141e
 +#define PCI_DEVICE_ID_AMD_15H_M60H_NB_F3 0x1573
 +#define PCI_DEVICE_ID_AMD_15H_M60H_NB_F4 0x1574
  #define PCI_DEVICE_ID_AMD_15H_NB_F0   0x1600
  #define PCI_DEVICE_ID_AMD_15H_NB_F1   0x1601
  #define PCI_DEVICE_ID_AMD_15H_NB_F2   0x1602
  #define PCI_DEVICE_ID_AMD_8131_BRIDGE 0x7450
  #define PCI_DEVICE_ID_AMD_8131_APIC   0x7451
  #define PCI_DEVICE_ID_AMD_8132_BRIDGE 0x7458
+ #define PCI_DEVICE_ID_AMD_NL_USB      0x7912
  #define PCI_DEVICE_ID_AMD_CS5535_IDE    0x208F
  #define PCI_DEVICE_ID_AMD_CS5536_ISA    0x2090
  #define PCI_DEVICE_ID_AMD_CS5536_FLASH  0x2091
diff --combined include/linux/usb/hcd.h
index 668898e29d0ef3cd21301eebf4e8c2a1070525dc,9cf7e3594609b20f4768daf661594fc3e6d146e2..086bf13307e6cbe860c95602a2d9001d05270f1c
@@@ -93,7 -93,7 +93,7 @@@ struct usb_hcd 
  
        struct timer_list       rh_timer;       /* drives root-hub polling */
        struct urb              *status_urb;    /* the current status urb */
 -#ifdef CONFIG_PM_RUNTIME
 +#ifdef CONFIG_PM
        struct work_struct      wakeup_work;    /* for remote wakeup */
  #endif
  
@@@ -379,6 -379,9 +379,9 @@@ struct hc_driver 
        int     (*disable_usb3_lpm_timeout)(struct usb_hcd *,
                        struct usb_device *, enum usb3_link_state state);
        int     (*find_raw_port_number)(struct usb_hcd *, int);
+       /* Call for power on/off the port if necessary */
+       int     (*port_power)(struct usb_hcd *hcd, int portnum, bool enable);
  };
  
  static inline int hcd_giveback_urb_in_bh(struct usb_hcd *hcd)
@@@ -625,13 -628,16 +628,13 @@@ extern int usb_find_interface_driver(st
  extern void usb_root_hub_lost_power(struct usb_device *rhdev);
  extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
  extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
 -#endif /* CONFIG_PM */
 -
 -#ifdef CONFIG_PM_RUNTIME
  extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
  #else
  static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
  {
        return;
  }
 -#endif /* CONFIG_PM_RUNTIME */
 +#endif /* CONFIG_PM */
  
  /*-------------------------------------------------------------------------*/