aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/chipidea/ci_hdrc_pci.c3
-rw-r--r--drivers/usb/class/cdc-acm.c54
-rw-r--r--drivers/usb/core/buffer.c26
-rw-r--r--drivers/usb/core/devio.c63
-rw-r--r--drivers/usb/core/driver.c29
-rw-r--r--drivers/usb/core/hcd.c16
-rw-r--r--drivers/usb/core/hub.c82
-rw-r--r--drivers/usb/core/message.c23
-rw-r--r--drivers/usb/core/otg_whitelist.h5
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/core/usb.c1
-rw-r--r--drivers/usb/dwc2/core_intr.c6
-rw-r--r--drivers/usb/host/Kconfig8
-rw-r--r--drivers/usb/host/ehci-atmel.c102
-rw-r--r--drivers/usb/host/ehci-fsl.c1
-rw-r--r--drivers/usb/host/ehci-grlib.c1
-rw-r--r--drivers/usb/host/ehci-hcd.c6
-rw-r--r--drivers/usb/host/ehci-hub.c8
-rw-r--r--drivers/usb/host/ehci-pci.c27
-rw-r--r--drivers/usb/host/ehci-platform.c92
-rw-r--r--drivers/usb/host/ehci-pmcmsp.c1
-rw-r--r--drivers/usb/host/ehci-ppc-of.c1
-rw-r--r--drivers/usb/host/ehci-sead3.c1
-rw-r--r--drivers/usb/host/ehci-sh.c1
-rw-r--r--drivers/usb/host/ehci-tilegx.c1
-rw-r--r--drivers/usb/host/ehci-xilinx-of.c1
-rw-r--r--drivers/usb/host/ehci.h2
-rw-r--r--drivers/usb/host/fhci-hub.c9
-rw-r--r--drivers/usb/host/fotg210-hcd.c4
-rw-r--r--drivers/usb/host/fusbh200-hcd.c4
-rw-r--r--drivers/usb/host/imx21-hcd.c5
-rw-r--r--drivers/usb/host/isp116x-hcd.c5
-rw-r--r--drivers/usb/host/isp1362-hcd.c8
-rw-r--r--drivers/usb/host/max3421-hcd.c6
-rw-r--r--drivers/usb/host/ohci-at91.c132
-rw-r--r--drivers/usb/host/ohci-da8xx.c1
-rw-r--r--drivers/usb/host/ohci-hub.c10
-rw-r--r--drivers/usb/host/ohci-jz4740.c1
-rw-r--r--drivers/usb/host/ohci-platform.c83
-rw-r--r--drivers/usb/host/ohci-ppc-of.c1
-rw-r--r--drivers/usb/host/ohci-s3c2410.c6
-rw-r--r--drivers/usb/host/ohci-sm501.c1
-rw-r--r--drivers/usb/host/ohci-tilegx.c1
-rw-r--r--drivers/usb/host/ohci-tmio.c1
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c10
-rw-r--r--drivers/usb/host/pci-quirks.c46
-rw-r--r--drivers/usb/host/r8a66597-hcd.c13
-rw-r--r--drivers/usb/host/sl811-hcd.c10
-rw-r--r--drivers/usb/host/u132-hcd.c10
-rw-r--r--drivers/usb/host/uhci-grlib.c1
-rw-r--r--drivers/usb/host/uhci-hub.c5
-rw-r--r--drivers/usb/host/uhci-platform.c1
-rw-r--r--drivers/usb/host/xhci-dbg.c2
-rw-r--r--drivers/usb/host/xhci-mem.c31
-rw-r--r--drivers/usb/host/xhci-ring.c12
-rw-r--r--drivers/usb/host/xhci.c78
-rw-r--r--drivers/usb/host/xhci.h12
-rw-r--r--drivers/usb/image/microtek.c4
-rw-r--r--drivers/usb/isp1760/isp1760-hcd.c13
-rw-r--r--drivers/usb/misc/uss720.c12
-rw-r--r--drivers/usb/phy/phy.c2
-rw-r--r--drivers/usb/serial/cp210x.c1
-rw-r--r--drivers/usb/serial/mos7840.c60
-rw-r--r--drivers/usb/serial/option.c60
-rw-r--r--drivers/usb/storage/unusual_devs.h9
-rw-r--r--drivers/usb/storage/unusual_uas.h7
-rw-r--r--drivers/usb/usbip/vhci_hcd.c3
-rw-r--r--drivers/usb/wusbcore/rh.c4
68 files changed, 667 insertions, 582 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c
index 241ae3444fde..4df669437211 100644
--- a/drivers/usb/chipidea/ci_hdrc_pci.c
+++ b/drivers/usb/chipidea/ci_hdrc_pci.c
@@ -111,6 +111,9 @@ static void ci_hdrc_pci_remove(struct pci_dev *pdev)
111 * PCI device structure 111 * PCI device structure
112 * 112 *
113 * Check "pci.h" for details 113 * Check "pci.h" for details
114 *
115 * Note: ehci-pci driver may try to probe the device first. You have to add an
116 * ID to the bypass_pci_id_table in ehci-pci driver to prevent this.
114 */ 117 */
115static const struct pci_device_id ci_hdrc_pci_id_table[] = { 118static const struct pci_device_id ci_hdrc_pci_id_table[] = {
116 { 119 {
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 546a17e8ad5b..e78720b59d67 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1091,6 +1091,7 @@ static int acm_probe(struct usb_interface *intf,
1091 unsigned long quirks; 1091 unsigned long quirks;
1092 int num_rx_buf; 1092 int num_rx_buf;
1093 int i; 1093 int i;
1094 unsigned int elength = 0;
1094 int combined_interfaces = 0; 1095 int combined_interfaces = 0;
1095 struct device *tty_dev; 1096 struct device *tty_dev;
1096 int rv = -ENOMEM; 1097 int rv = -ENOMEM;
@@ -1136,9 +1137,12 @@ static int acm_probe(struct usb_interface *intf,
1136 dev_err(&intf->dev, "skipping garbage\n"); 1137 dev_err(&intf->dev, "skipping garbage\n");
1137 goto next_desc; 1138 goto next_desc;
1138 } 1139 }
1140 elength = buffer[0];
1139 1141
1140 switch (buffer[2]) { 1142 switch (buffer[2]) {
1141 case USB_CDC_UNION_TYPE: /* we've found it */ 1143 case USB_CDC_UNION_TYPE: /* we've found it */
1144 if (elength < sizeof(struct usb_cdc_union_desc))
1145 goto next_desc;
1142 if (union_header) { 1146 if (union_header) {
1143 dev_err(&intf->dev, "More than one " 1147 dev_err(&intf->dev, "More than one "
1144 "union descriptor, skipping ...\n"); 1148 "union descriptor, skipping ...\n");
@@ -1147,29 +1151,36 @@ static int acm_probe(struct usb_interface *intf,
1147 union_header = (struct usb_cdc_union_desc *)buffer; 1151 union_header = (struct usb_cdc_union_desc *)buffer;
1148 break; 1152 break;
1149 case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/ 1153 case USB_CDC_COUNTRY_TYPE: /* export through sysfs*/
1154 if (elength < sizeof(struct usb_cdc_country_functional_desc))
1155 goto next_desc;
1150 cfd = (struct usb_cdc_country_functional_desc *)buffer; 1156 cfd = (struct usb_cdc_country_functional_desc *)buffer;
1151 break; 1157 break;
1152 case USB_CDC_HEADER_TYPE: /* maybe check version */ 1158 case USB_CDC_HEADER_TYPE: /* maybe check version */
1153 break; /* for now we ignore it */ 1159 break; /* for now we ignore it */
1154 case USB_CDC_ACM_TYPE: 1160 case USB_CDC_ACM_TYPE:
1161 if (elength < 4)
1162 goto next_desc;
1155 ac_management_function = buffer[3]; 1163 ac_management_function = buffer[3];
1156 break; 1164 break;
1157 case USB_CDC_CALL_MANAGEMENT_TYPE: 1165 case USB_CDC_CALL_MANAGEMENT_TYPE:
1166 if (elength < 5)
1167 goto next_desc;
1158 call_management_function = buffer[3]; 1168 call_management_function = buffer[3];
1159 call_interface_num = buffer[4]; 1169 call_interface_num = buffer[4];
1160 break; 1170 break;
1161 default: 1171 default:
1162 /* there are LOTS more CDC descriptors that 1172 /*
1173 * there are LOTS more CDC descriptors that
1163 * could legitimately be found here. 1174 * could legitimately be found here.
1164 */ 1175 */
1165 dev_dbg(&intf->dev, "Ignoring descriptor: " 1176 dev_dbg(&intf->dev, "Ignoring descriptor: "
1166 "type %02x, length %d\n", 1177 "type %02x, length %ud\n",
1167 buffer[2], buffer[0]); 1178 buffer[2], elength);
1168 break; 1179 break;
1169 } 1180 }
1170next_desc: 1181next_desc:
1171 buflen -= buffer[0]; 1182 buflen -= elength;
1172 buffer += buffer[0]; 1183 buffer += elength;
1173 } 1184 }
1174 1185
1175 if (!union_header) { 1186 if (!union_header) {
@@ -1287,10 +1298,8 @@ made_compressed_probe:
1287 dev_dbg(&intf->dev, "interfaces are valid\n"); 1298 dev_dbg(&intf->dev, "interfaces are valid\n");
1288 1299
1289 acm = kzalloc(sizeof(struct acm), GFP_KERNEL); 1300 acm = kzalloc(sizeof(struct acm), GFP_KERNEL);
1290 if (acm == NULL) { 1301 if (acm == NULL)
1291 dev_err(&intf->dev, "out of memory (acm kzalloc)\n");
1292 goto alloc_fail; 1302 goto alloc_fail;
1293 }
1294 1303
1295 minor = acm_alloc_minor(acm); 1304 minor = acm_alloc_minor(acm);
1296 if (minor == ACM_TTY_MINORS) { 1305 if (minor == ACM_TTY_MINORS) {
@@ -1329,42 +1338,32 @@ made_compressed_probe:
1329 acm->quirks = quirks; 1338 acm->quirks = quirks;
1330 1339
1331 buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); 1340 buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
1332 if (!buf) { 1341 if (!buf)
1333 dev_err(&intf->dev, "out of memory (ctrl buffer alloc)\n");
1334 goto alloc_fail2; 1342 goto alloc_fail2;
1335 }
1336 acm->ctrl_buffer = buf; 1343 acm->ctrl_buffer = buf;
1337 1344
1338 if (acm_write_buffers_alloc(acm) < 0) { 1345 if (acm_write_buffers_alloc(acm) < 0)
1339 dev_err(&intf->dev, "out of memory (write buffer alloc)\n");
1340 goto alloc_fail4; 1346 goto alloc_fail4;
1341 }
1342 1347
1343 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL); 1348 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
1344 if (!acm->ctrlurb) { 1349 if (!acm->ctrlurb)
1345 dev_err(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
1346 goto alloc_fail5; 1350 goto alloc_fail5;
1347 } 1351
1348 for (i = 0; i < num_rx_buf; i++) { 1352 for (i = 0; i < num_rx_buf; i++) {
1349 struct acm_rb *rb = &(acm->read_buffers[i]); 1353 struct acm_rb *rb = &(acm->read_buffers[i]);
1350 struct urb *urb; 1354 struct urb *urb;
1351 1355
1352 rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL, 1356 rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
1353 &rb->dma); 1357 &rb->dma);
1354 if (!rb->base) { 1358 if (!rb->base)
1355 dev_err(&intf->dev, "out of memory "
1356 "(read bufs usb_alloc_coherent)\n");
1357 goto alloc_fail6; 1359 goto alloc_fail6;
1358 }
1359 rb->index = i; 1360 rb->index = i;
1360 rb->instance = acm; 1361 rb->instance = acm;
1361 1362
1362 urb = usb_alloc_urb(0, GFP_KERNEL); 1363 urb = usb_alloc_urb(0, GFP_KERNEL);
1363 if (!urb) { 1364 if (!urb)
1364 dev_err(&intf->dev,
1365 "out of memory (read urbs usb_alloc_urb)\n");
1366 goto alloc_fail6; 1365 goto alloc_fail6;
1367 } 1366
1368 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1367 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1369 urb->transfer_dma = rb->dma; 1368 urb->transfer_dma = rb->dma;
1370 if (acm->is_int_ep) { 1369 if (acm->is_int_ep) {
@@ -1389,11 +1388,8 @@ made_compressed_probe:
1389 struct acm_wb *snd = &(acm->wb[i]); 1388 struct acm_wb *snd = &(acm->wb[i]);
1390 1389
1391 snd->urb = usb_alloc_urb(0, GFP_KERNEL); 1390 snd->urb = usb_alloc_urb(0, GFP_KERNEL);
1392 if (snd->urb == NULL) { 1391 if (snd->urb == NULL)
1393 dev_err(&intf->dev,
1394 "out of memory (write urbs usb_alloc_urb)\n");
1395 goto alloc_fail7; 1392 goto alloc_fail7;
1396 }
1397 1393
1398 if (usb_endpoint_xfer_int(epwrite)) 1394 if (usb_endpoint_xfer_int(epwrite))
1399 usb_fill_int_urb(snd->urb, usb_dev, 1395 usb_fill_int_urb(snd->urb, usb_dev,
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 684ef70dc09d..506b969ea7fd 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -22,17 +22,25 @@
22 */ 22 */
23 23
24/* FIXME tune these based on pool statistics ... */ 24/* FIXME tune these based on pool statistics ... */
25static const size_t pool_max[HCD_BUFFER_POOLS] = { 25static size_t pool_max[HCD_BUFFER_POOLS] = {
26 /* platforms without dma-friendly caches might need to 26 32, 128, 512, 2048,
27 * prevent cacheline sharing...
28 */
29 32,
30 128,
31 512,
32 PAGE_SIZE / 2
33 /* bigger --> allocate pages */
34}; 27};
35 28
29void __init usb_init_pool_max(void)
30{
31 /*
32 * The pool_max values must never be smaller than
33 * ARCH_KMALLOC_MINALIGN.
34 */
35 if (ARCH_KMALLOC_MINALIGN <= 32)
36 ; /* Original value is okay */
37 else if (ARCH_KMALLOC_MINALIGN <= 64)
38 pool_max[0] = 64;
39 else if (ARCH_KMALLOC_MINALIGN <= 128)
40 pool_max[0] = 0; /* Don't use this pool */
41 else
42 BUILD_BUG(); /* We don't allow this */
43}
36 44
37/* SETUP primitives */ 45/* SETUP primitives */
38 46
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 0b59731c3021..66abdbcfbfa5 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1689,7 +1689,7 @@ static struct async *reap_as(struct usb_dev_state *ps)
1689 for (;;) { 1689 for (;;) {
1690 __set_current_state(TASK_INTERRUPTIBLE); 1690 __set_current_state(TASK_INTERRUPTIBLE);
1691 as = async_getcompleted(ps); 1691 as = async_getcompleted(ps);
1692 if (as) 1692 if (as || !connected(ps))
1693 break; 1693 break;
1694 if (signal_pending(current)) 1694 if (signal_pending(current))
1695 break; 1695 break;
@@ -1712,7 +1712,7 @@ static int proc_reapurb(struct usb_dev_state *ps, void __user *arg)
1712 } 1712 }
1713 if (signal_pending(current)) 1713 if (signal_pending(current))
1714 return -EINTR; 1714 return -EINTR;
1715 return -EIO; 1715 return -ENODEV;
1716} 1716}
1717 1717
1718static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg) 1718static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
@@ -1721,10 +1721,11 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
1721 struct async *as; 1721 struct async *as;
1722 1722
1723 as = async_getcompleted(ps); 1723 as = async_getcompleted(ps);
1724 retval = -EAGAIN;
1725 if (as) { 1724 if (as) {
1726 retval = processcompl(as, (void __user * __user *)arg); 1725 retval = processcompl(as, (void __user * __user *)arg);
1727 free_async(as); 1726 free_async(as);
1727 } else {
1728 retval = (connected(ps) ? -EAGAIN : -ENODEV);
1728 } 1729 }
1729 return retval; 1730 return retval;
1730} 1731}
@@ -1854,7 +1855,7 @@ static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg)
1854 } 1855 }
1855 if (signal_pending(current)) 1856 if (signal_pending(current))
1856 return -EINTR; 1857 return -EINTR;
1857 return -EIO; 1858 return -ENODEV;
1858} 1859}
1859 1860
1860static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg) 1861static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *arg)
@@ -1862,11 +1863,12 @@ static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *ar
1862 int retval; 1863 int retval;
1863 struct async *as; 1864 struct async *as;
1864 1865
1865 retval = -EAGAIN;
1866 as = async_getcompleted(ps); 1866 as = async_getcompleted(ps);
1867 if (as) { 1867 if (as) {
1868 retval = processcompl_compat(as, (void __user * __user *)arg); 1868 retval = processcompl_compat(as, (void __user * __user *)arg);
1869 free_async(as); 1869 free_async(as);
1870 } else {
1871 retval = (connected(ps) ? -EAGAIN : -ENODEV);
1870 } 1872 }
1871 return retval; 1873 return retval;
1872} 1874}
@@ -2038,7 +2040,8 @@ static int proc_get_capabilities(struct usb_dev_state *ps, void __user *arg)
2038{ 2040{
2039 __u32 caps; 2041 __u32 caps;
2040 2042
2041 caps = USBDEVFS_CAP_ZERO_PACKET | USBDEVFS_CAP_NO_PACKET_SIZE_LIM; 2043 caps = USBDEVFS_CAP_ZERO_PACKET | USBDEVFS_CAP_NO_PACKET_SIZE_LIM |
2044 USBDEVFS_CAP_REAP_AFTER_DISCONNECT;
2042 if (!ps->dev->bus->no_stop_on_short) 2045 if (!ps->dev->bus->no_stop_on_short)
2043 caps |= USBDEVFS_CAP_BULK_CONTINUATION; 2046 caps |= USBDEVFS_CAP_BULK_CONTINUATION;
2044 if (ps->dev->bus->sg_tablesize) 2047 if (ps->dev->bus->sg_tablesize)
@@ -2138,6 +2141,32 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2138 return -EPERM; 2141 return -EPERM;
2139 2142
2140 usb_lock_device(dev); 2143 usb_lock_device(dev);
2144
2145 /* Reap operations are allowed even after disconnection */
2146 switch (cmd) {
2147 case USBDEVFS_REAPURB:
2148 snoop(&dev->dev, "%s: REAPURB\n", __func__);
2149 ret = proc_reapurb(ps, p);
2150 goto done;
2151
2152 case USBDEVFS_REAPURBNDELAY:
2153 snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
2154 ret = proc_reapurbnonblock(ps, p);
2155 goto done;
2156
2157#ifdef CONFIG_COMPAT
2158 case USBDEVFS_REAPURB32:
2159 snoop(&dev->dev, "%s: REAPURB32\n", __func__);
2160 ret = proc_reapurb_compat(ps, p);
2161 goto done;
2162
2163 case USBDEVFS_REAPURBNDELAY32:
2164 snoop(&dev->dev, "%s: REAPURBNDELAY32\n", __func__);
2165 ret = proc_reapurbnonblock_compat(ps, p);
2166 goto done;
2167#endif
2168 }
2169
2141 if (!connected(ps)) { 2170 if (!connected(ps)) {
2142 usb_unlock_device(dev); 2171 usb_unlock_device(dev);
2143 return -ENODEV; 2172 return -ENODEV;
@@ -2231,16 +2260,6 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2231 inode->i_mtime = CURRENT_TIME; 2260 inode->i_mtime = CURRENT_TIME;
2232 break; 2261 break;
2233 2262
2234 case USBDEVFS_REAPURB32:
2235 snoop(&dev->dev, "%s: REAPURB32\n", __func__);
2236 ret = proc_reapurb_compat(ps, p);
2237 break;
2238
2239 case USBDEVFS_REAPURBNDELAY32:
2240 snoop(&dev->dev, "%s: REAPURBNDELAY32\n", __func__);
2241 ret = proc_reapurbnonblock_compat(ps, p);
2242 break;
2243
2244 case USBDEVFS_IOCTL32: 2263 case USBDEVFS_IOCTL32:
2245 snoop(&dev->dev, "%s: IOCTL32\n", __func__); 2264 snoop(&dev->dev, "%s: IOCTL32\n", __func__);
2246 ret = proc_ioctl_compat(ps, ptr_to_compat(p)); 2265 ret = proc_ioctl_compat(ps, ptr_to_compat(p));
@@ -2252,16 +2271,6 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2252 ret = proc_unlinkurb(ps, p); 2271 ret = proc_unlinkurb(ps, p);
2253 break; 2272 break;
2254 2273
2255 case USBDEVFS_REAPURB:
2256 snoop(&dev->dev, "%s: REAPURB\n", __func__);
2257 ret = proc_reapurb(ps, p);
2258 break;
2259
2260 case USBDEVFS_REAPURBNDELAY:
2261 snoop(&dev->dev, "%s: REAPURBNDELAY\n", __func__);
2262 ret = proc_reapurbnonblock(ps, p);
2263 break;
2264
2265 case USBDEVFS_DISCSIGNAL: 2274 case USBDEVFS_DISCSIGNAL:
2266 snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__); 2275 snoop(&dev->dev, "%s: DISCSIGNAL\n", __func__);
2267 ret = proc_disconnectsignal(ps, p); 2276 ret = proc_disconnectsignal(ps, p);
@@ -2304,6 +2313,8 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2304 ret = proc_free_streams(ps, p); 2313 ret = proc_free_streams(ps, p);
2305 break; 2314 break;
2306 } 2315 }
2316
2317 done:
2307 usb_unlock_device(dev); 2318 usb_unlock_device(dev);
2308 if (ret >= 0) 2319 if (ret >= 0)
2309 inode->i_atime = CURRENT_TIME; 2320 inode->i_atime = CURRENT_TIME;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 874dec31a111..818369afff63 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -275,21 +275,6 @@ static int usb_unbind_device(struct device *dev)
275 return 0; 275 return 0;
276} 276}
277 277
278/*
279 * Cancel any pending scheduled resets
280 *
281 * [see usb_queue_reset_device()]
282 *
283 * Called after unconfiguring / when releasing interfaces. See
284 * comments in __usb_queue_reset_device() regarding
285 * udev->reset_running.
286 */
287static void usb_cancel_queued_reset(struct usb_interface *iface)
288{
289 if (iface->reset_running == 0)
290 cancel_work_sync(&iface->reset_ws);
291}
292
293/* called from driver core with dev locked */ 278/* called from driver core with dev locked */
294static int usb_probe_interface(struct device *dev) 279static int usb_probe_interface(struct device *dev)
295{ 280{
@@ -380,7 +365,6 @@ static int usb_probe_interface(struct device *dev)
380 usb_set_intfdata(intf, NULL); 365 usb_set_intfdata(intf, NULL);
381 intf->needs_remote_wakeup = 0; 366 intf->needs_remote_wakeup = 0;
382 intf->condition = USB_INTERFACE_UNBOUND; 367 intf->condition = USB_INTERFACE_UNBOUND;
383 usb_cancel_queued_reset(intf);
384 368
385 /* If the LPM disable succeeded, balance the ref counts. */ 369 /* If the LPM disable succeeded, balance the ref counts. */
386 if (!lpm_disable_error) 370 if (!lpm_disable_error)
@@ -425,7 +409,6 @@ static int usb_unbind_interface(struct device *dev)
425 usb_disable_interface(udev, intf, false); 409 usb_disable_interface(udev, intf, false);
426 410
427 driver->disconnect(intf); 411 driver->disconnect(intf);
428 usb_cancel_queued_reset(intf);
429 412
430 /* Free streams */ 413 /* Free streams */
431 for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { 414 for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
@@ -1797,6 +1780,18 @@ static int autosuspend_check(struct usb_device *udev)
1797 dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n"); 1780 dev_dbg(&udev->dev, "remote wakeup needed for autosuspend\n");
1798 return -EOPNOTSUPP; 1781 return -EOPNOTSUPP;
1799 } 1782 }
1783
1784 /*
1785 * If the device is a direct child of the root hub and the HCD
1786 * doesn't handle wakeup requests, don't allow autosuspend when
1787 * wakeup is needed.
1788 */
1789 if (w && udev->parent == udev->bus->root_hub &&
1790 bus_to_hcd(udev->bus)->cant_recv_wakeups) {
1791 dev_dbg(&udev->dev, "HCD doesn't handle wakeup requests\n");
1792 return -EOPNOTSUPP;
1793 }
1794
1800 udev->do_remote_wakeup = w; 1795 udev->do_remote_wakeup = w;
1801 return 0; 1796 return 0;
1802} 1797}
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 11cee55ae397..45a915ccd71c 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1618,6 +1618,7 @@ static int unlink1(struct usb_hcd *hcd, struct urb *urb, int status)
1618int usb_hcd_unlink_urb (struct urb *urb, int status) 1618int usb_hcd_unlink_urb (struct urb *urb, int status)
1619{ 1619{
1620 struct usb_hcd *hcd; 1620 struct usb_hcd *hcd;
1621 struct usb_device *udev = urb->dev;
1621 int retval = -EIDRM; 1622 int retval = -EIDRM;
1622 unsigned long flags; 1623 unsigned long flags;
1623 1624
@@ -1629,20 +1630,19 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
1629 spin_lock_irqsave(&hcd_urb_unlink_lock, flags); 1630 spin_lock_irqsave(&hcd_urb_unlink_lock, flags);
1630 if (atomic_read(&urb->use_count) > 0) { 1631 if (atomic_read(&urb->use_count) > 0) {
1631 retval = 0; 1632 retval = 0;
1632 usb_get_dev(urb->dev); 1633 usb_get_dev(udev);
1633 } 1634 }
1634 spin_unlock_irqrestore(&hcd_urb_unlink_lock, flags); 1635 spin_unlock_irqrestore(&hcd_urb_unlink_lock, flags);
1635 if (retval == 0) { 1636 if (retval == 0) {
1636 hcd = bus_to_hcd(urb->dev->bus); 1637 hcd = bus_to_hcd(urb->dev->bus);
1637 retval = unlink1(hcd, urb, status); 1638 retval = unlink1(hcd, urb, status);
1638 usb_put_dev(urb->dev); 1639 if (retval == 0)
1640 retval = -EINPROGRESS;
1641 else if (retval != -EIDRM && retval != -EBUSY)
1642 dev_dbg(&udev->dev, "hcd_unlink_urb %p fail %d\n",
1643 urb, retval);
1644 usb_put_dev(udev);
1639 } 1645 }
1640
1641 if (retval == 0)
1642 retval = -EINPROGRESS;
1643 else if (retval != -EIDRM && retval != -EBUSY)
1644 dev_dbg(&urb->dev->dev, "hcd_unlink_urb %p fail %d\n",
1645 urb, retval);
1646 return retval; 1646 return retval;
1647} 1647}
1648 1648
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index aeb50bb6ba9c..58d2cde0ebe2 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2896,10 +2896,12 @@ static int port_is_suspended(struct usb_hub *hub, unsigned portstatus)
2896 */ 2896 */
2897static int check_port_resume_type(struct usb_device *udev, 2897static int check_port_resume_type(struct usb_device *udev,
2898 struct usb_hub *hub, int port1, 2898 struct usb_hub *hub, int port1,
2899 int status, unsigned portchange, unsigned portstatus) 2899 int status, u16 portchange, u16 portstatus)
2900{ 2900{
2901 struct usb_port *port_dev = hub->ports[port1 - 1]; 2901 struct usb_port *port_dev = hub->ports[port1 - 1];
2902 int retries = 3;
2902 2903
2904 retry:
2903 /* Is a warm reset needed to recover the connection? */ 2905 /* Is a warm reset needed to recover the connection? */
2904 if (status == 0 && udev->reset_resume 2906 if (status == 0 && udev->reset_resume
2905 && hub_port_warm_reset_required(hub, port1, portstatus)) { 2907 && hub_port_warm_reset_required(hub, port1, portstatus)) {
@@ -2907,10 +2909,17 @@ static int check_port_resume_type(struct usb_device *udev,
2907 } 2909 }
2908 /* Is the device still present? */ 2910 /* Is the device still present? */
2909 else if (status || port_is_suspended(hub, portstatus) || 2911 else if (status || port_is_suspended(hub, portstatus) ||
2910 !port_is_power_on(hub, portstatus) || 2912 !port_is_power_on(hub, portstatus)) {
2911 !(portstatus & USB_PORT_STAT_CONNECTION)) {
2912 if (status >= 0) 2913 if (status >= 0)
2913 status = -ENODEV; 2914 status = -ENODEV;
2915 } else if (!(portstatus & USB_PORT_STAT_CONNECTION)) {
2916 if (retries--) {
2917 usleep_range(200, 300);
2918 status = hub_port_status(hub, port1, &portstatus,
2919 &portchange);
2920 goto retry;
2921 }
2922 status = -ENODEV;
2914 } 2923 }
2915 2924
2916 /* Can't do a normal resume if the port isn't enabled, 2925 /* Can't do a normal resume if the port isn't enabled,
@@ -4655,9 +4664,13 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4655 if (!(portstatus & USB_PORT_STAT_CONNECTION) || 4664 if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
4656 test_bit(port1, hub->removed_bits)) { 4665 test_bit(port1, hub->removed_bits)) {
4657 4666
4658 /* maybe switch power back on (e.g. root hub was reset) */ 4667 /*
4668 * maybe switch power back on (e.g. root hub was reset)
4669 * but only if the port isn't owned by someone else.
4670 */
4659 if (hub_is_port_power_switchable(hub) 4671 if (hub_is_port_power_switchable(hub)
4660 && !port_is_power_on(hub, portstatus)) 4672 && !port_is_power_on(hub, portstatus)
4673 && !port_dev->port_owner)
4661 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 4674 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
4662 4675
4663 if (portstatus & USB_PORT_STAT_ENABLE) 4676 if (portstatus & USB_PORT_STAT_ENABLE)
@@ -4882,7 +4895,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
4882static void port_event(struct usb_hub *hub, int port1) 4895static void port_event(struct usb_hub *hub, int port1)
4883 __must_hold(&port_dev->status_lock) 4896 __must_hold(&port_dev->status_lock)
4884{ 4897{
4885 int connect_change, reset_device = 0; 4898 int connect_change;
4886 struct usb_port *port_dev = hub->ports[port1 - 1]; 4899 struct usb_port *port_dev = hub->ports[port1 - 1];
4887 struct usb_device *udev = port_dev->child; 4900 struct usb_device *udev = port_dev->child;
4888 struct usb_device *hdev = hub->hdev; 4901 struct usb_device *hdev = hub->hdev;
@@ -4970,30 +4983,14 @@ static void port_event(struct usb_hub *hub, int port1)
4970 if (hub_port_reset(hub, port1, NULL, 4983 if (hub_port_reset(hub, port1, NULL,
4971 HUB_BH_RESET_TIME, true) < 0) 4984 HUB_BH_RESET_TIME, true) < 0)
4972 hub_port_disable(hub, port1, 1); 4985 hub_port_disable(hub, port1, 1);
4973 } else 4986 } else {
4974 reset_device = 1; 4987 usb_unlock_port(port_dev);
4975 } 4988 usb_lock_device(udev);
4976 4989 usb_reset_device(udev);
4977 /* 4990 usb_unlock_device(udev);
4978 * On disconnect USB3 protocol ports transit from U0 to 4991 usb_lock_port(port_dev);
4979 * SS.Inactive to Rx.Detect. If this happens a warm- 4992 connect_change = 0;
4980 * reset is not needed, but a (re)connect may happen 4993 }
4981 * before hub_wq runs and sees the disconnect, and the
4982 * device may be an unknown state.
4983 *
4984 * If the port went through SS.Inactive without hub_wq
4985 * seeing it the C_LINK_STATE change flag will be set,
4986 * and we reset the dev to put it in a known state.
4987 */
4988 if (reset_device || (udev && hub_is_superspeed(hub->hdev)
4989 && (portchange & USB_PORT_STAT_C_LINK_STATE)
4990 && (portstatus & USB_PORT_STAT_CONNECTION))) {
4991 usb_unlock_port(port_dev);
4992 usb_lock_device(udev);
4993 usb_reset_device(udev);
4994 usb_unlock_device(udev);
4995 usb_lock_port(port_dev);
4996 connect_change = 0;
4997 } 4994 }
4998 4995
4999 if (connect_change) 4996 if (connect_change)
@@ -5589,26 +5586,19 @@ EXPORT_SYMBOL_GPL(usb_reset_device);
5589 * possible; depending on how the driver attached to each interface 5586 * possible; depending on how the driver attached to each interface
5590 * handles ->pre_reset(), the second reset might happen or not. 5587 * handles ->pre_reset(), the second reset might happen or not.
5591 * 5588 *
5592 * - If a driver is unbound and it had a pending reset, the reset will 5589 * - If the reset is delayed so long that the interface is unbound from
5593 * be cancelled. 5590 * its driver, the reset will be skipped.
5594 *
5595 * - This function can be called during .probe() or .disconnect()
5596 * times. On return from .disconnect(), any pending resets will be
5597 * cancelled.
5598 *
5599 * There is no no need to lock/unlock the @reset_ws as schedule_work()
5600 * does its own.
5601 * 5591 *
5602 * NOTE: We don't do any reference count tracking because it is not 5592 * - This function can be called during .probe(). It can also be called
5603 * needed. The lifecycle of the work_struct is tied to the 5593 * during .disconnect(), but doing so is pointless because the reset
5604 * usb_interface. Before destroying the interface we cancel the 5594 * will not occur. If you really want to reset the device during
5605 * work_struct, so the fact that work_struct is queued and or 5595 * .disconnect(), call usb_reset_device() directly -- but watch out
5606 * running means the interface (and thus, the device) exist and 5596 * for nested unbinding issues!
5607 * are referenced.
5608 */ 5597 */
5609void usb_queue_reset_device(struct usb_interface *iface) 5598void usb_queue_reset_device(struct usb_interface *iface)
5610{ 5599{
5611 schedule_work(&iface->reset_ws); 5600 if (schedule_work(&iface->reset_ws))
5601 usb_get_intf(iface);
5612} 5602}
5613EXPORT_SYMBOL_GPL(usb_queue_reset_device); 5603EXPORT_SYMBOL_GPL(usb_queue_reset_device);
5614 5604
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f7b7713cfb2a..f368d2053da5 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1551,6 +1551,7 @@ static void usb_release_interface(struct device *dev)
1551 altsetting_to_usb_interface_cache(intf->altsetting); 1551 altsetting_to_usb_interface_cache(intf->altsetting);
1552 1552
1553 kref_put(&intfc->ref, usb_release_interface_cache); 1553 kref_put(&intfc->ref, usb_release_interface_cache);
1554 usb_put_dev(interface_to_usbdev(intf));
1554 kfree(intf); 1555 kfree(intf);
1555} 1556}
1556 1557
@@ -1626,24 +1627,6 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev,
1626 1627
1627/* 1628/*
1628 * Internal function to queue a device reset 1629 * Internal function to queue a device reset
1629 *
1630 * This is initialized into the workstruct in 'struct
1631 * usb_device->reset_ws' that is launched by
1632 * message.c:usb_set_configuration() when initializing each 'struct
1633 * usb_interface'.
1634 *
1635 * It is safe to get the USB device without reference counts because
1636 * the life cycle of @iface is bound to the life cycle of @udev. Then,
1637 * this function will be ran only if @iface is alive (and before
1638 * freeing it any scheduled instances of it will have been cancelled).
1639 *
1640 * We need to set a flag (usb_dev->reset_running) because when we call
1641 * the reset, the interfaces might be unbound. The current interface
1642 * cannot try to remove the queued work as it would cause a deadlock
1643 * (you cannot remove your work from within your executing
1644 * workqueue). This flag lets it know, so that
1645 * usb_cancel_queued_reset() doesn't try to do it.
1646 *
1647 * See usb_queue_reset_device() for more details 1630 * See usb_queue_reset_device() for more details
1648 */ 1631 */
1649static void __usb_queue_reset_device(struct work_struct *ws) 1632static void __usb_queue_reset_device(struct work_struct *ws)
@@ -1655,11 +1638,10 @@ static void __usb_queue_reset_device(struct work_struct *ws)
1655 1638
1656 rc = usb_lock_device_for_reset(udev, iface); 1639 rc = usb_lock_device_for_reset(udev, iface);
1657 if (rc >= 0) { 1640 if (rc >= 0) {
1658 iface->reset_running = 1;
1659 usb_reset_device(udev); 1641 usb_reset_device(udev);
1660 iface->reset_running = 0;
1661 usb_unlock_device(udev); 1642 usb_unlock_device(udev);
1662 } 1643 }
1644 usb_put_intf(iface); /* Undo _get_ in usb_queue_reset_device() */
1663} 1645}
1664 1646
1665 1647
@@ -1854,6 +1836,7 @@ free_interfaces:
1854 dev_set_name(&intf->dev, "%d-%s:%d.%d", 1836 dev_set_name(&intf->dev, "%d-%s:%d.%d",
1855 dev->bus->busnum, dev->devpath, 1837 dev->bus->busnum, dev->devpath,
1856 configuration, alt->desc.bInterfaceNumber); 1838 configuration, alt->desc.bInterfaceNumber);
1839 usb_get_dev(dev);
1857 } 1840 }
1858 kfree(new_interfaces); 1841 kfree(new_interfaces);
1859 1842
diff --git a/drivers/usb/core/otg_whitelist.h b/drivers/usb/core/otg_whitelist.h
index de0c9c9d7091..a6315abe7b7c 100644
--- a/drivers/usb/core/otg_whitelist.h
+++ b/drivers/usb/core/otg_whitelist.h
@@ -55,6 +55,11 @@ static int is_targeted(struct usb_device *dev)
55 le16_to_cpu(dev->descriptor.idProduct) == 0xbadd)) 55 le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
56 return 0; 56 return 0;
57 57
58 /* OTG PET device is always targeted (see OTG 2.0 ECN 6.4.2) */
59 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
60 le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
61 return 1;
62
58 /* NOTE: can't use usb_match_id() since interface caches 63 /* NOTE: can't use usb_match_id() since interface caches
59 * aren't set up yet. this is cut/paste from that code. 64 * aren't set up yet. this is cut/paste from that code.
60 */ 65 */
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 0ffb4ed0a945..41e510ae8c83 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -179,6 +179,10 @@ static const struct usb_device_id usb_quirk_list[] = {
179 { USB_DEVICE(0x0b05, 0x17e0), .driver_info = 179 { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
180 USB_QUIRK_IGNORE_REMOTE_WAKEUP }, 180 USB_QUIRK_IGNORE_REMOTE_WAKEUP },
181 181
182 /* Protocol and OTG Electrical Test Device */
183 { USB_DEVICE(0x1a0a, 0x0200), .driver_info =
184 USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
185
182 { } /* terminating entry must be last */ 186 { } /* terminating entry must be last */
183}; 187};
184 188
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 2a92b97f0144..b1fb9aef0f5b 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1049,6 +1049,7 @@ static int __init usb_init(void)
1049 pr_info("%s: USB support disabled\n", usbcore_name); 1049 pr_info("%s: USB support disabled\n", usbcore_name);
1050 return 0; 1050 return 0;
1051 } 1051 }
1052 usb_init_pool_max();
1052 1053
1053 retval = usb_debugfs_init(); 1054 retval = usb_debugfs_init();
1054 if (retval) 1055 if (retval)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index ad43c5bc1ef1..02e3e2d4ea56 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -476,13 +476,13 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
476 u32 gintsts; 476 u32 gintsts;
477 irqreturn_t retval = IRQ_NONE; 477 irqreturn_t retval = IRQ_NONE;
478 478
479 spin_lock(&hsotg->lock);
480
479 if (!dwc2_is_controller_alive(hsotg)) { 481 if (!dwc2_is_controller_alive(hsotg)) {
480 dev_warn(hsotg->dev, "Controller is dead\n"); 482 dev_warn(hsotg->dev, "Controller is dead\n");
481 goto out; 483 goto out;
482 } 484 }
483 485
484 spin_lock(&hsotg->lock);
485
486 gintsts = dwc2_read_common_intr(hsotg); 486 gintsts = dwc2_read_common_intr(hsotg);
487 if (gintsts & ~GINTSTS_PRTINT) 487 if (gintsts & ~GINTSTS_PRTINT)
488 retval = IRQ_HANDLED; 488 retval = IRQ_HANDLED;
@@ -515,8 +515,8 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
515 } 515 }
516 } 516 }
517 517
518 spin_unlock(&hsotg->lock);
519out: 518out:
519 spin_unlock(&hsotg->lock);
520 return retval; 520 return retval;
521} 521}
522EXPORT_SYMBOL_GPL(dwc2_handle_common_intr); 522EXPORT_SYMBOL_GPL(dwc2_handle_common_intr);
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3de291b6ac04..5ad60e46dc2b 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -219,7 +219,7 @@ config USB_EHCI_TEGRA
219 219
220config USB_EHCI_HCD_PPC_OF 220config USB_EHCI_HCD_PPC_OF
221 bool "EHCI support for PPC USB controller on OF platform bus" 221 bool "EHCI support for PPC USB controller on OF platform bus"
222 depends on PPC_OF 222 depends on PPC
223 default y 223 default y
224 ---help--- 224 ---help---
225 Enables support for the USB controller present on the PowerPC 225 Enables support for the USB controller present on the PowerPC
@@ -480,7 +480,7 @@ config USB_OHCI_ATH79
480 480
481config USB_OHCI_HCD_PPC_OF_BE 481config USB_OHCI_HCD_PPC_OF_BE
482 bool "OHCI support for OF platform bus (big endian)" 482 bool "OHCI support for OF platform bus (big endian)"
483 depends on PPC_OF 483 depends on PPC
484 select USB_OHCI_BIG_ENDIAN_DESC 484 select USB_OHCI_BIG_ENDIAN_DESC
485 select USB_OHCI_BIG_ENDIAN_MMIO 485 select USB_OHCI_BIG_ENDIAN_MMIO
486 ---help--- 486 ---help---
@@ -489,7 +489,7 @@ config USB_OHCI_HCD_PPC_OF_BE
489 489
490config USB_OHCI_HCD_PPC_OF_LE 490config USB_OHCI_HCD_PPC_OF_LE
491 bool "OHCI support for OF platform bus (little endian)" 491 bool "OHCI support for OF platform bus (little endian)"
492 depends on PPC_OF 492 depends on PPC
493 select USB_OHCI_LITTLE_ENDIAN 493 select USB_OHCI_LITTLE_ENDIAN
494 ---help--- 494 ---help---
495 Enables support for little-endian USB controllers present on the 495 Enables support for little-endian USB controllers present on the
@@ -497,7 +497,7 @@ config USB_OHCI_HCD_PPC_OF_LE
497 497
498config USB_OHCI_HCD_PPC_OF 498config USB_OHCI_HCD_PPC_OF
499 bool 499 bool
500 depends on PPC_OF 500 depends on PPC
501 default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE 501 default USB_OHCI_HCD_PPC_OF_BE || USB_OHCI_HCD_PPC_OF_LE
502 502
503config USB_OHCI_HCD_PCI 503config USB_OHCI_HCD_PCI
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 56a88506febe..663f7908b15c 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -27,44 +27,66 @@
27#define DRIVER_DESC "EHCI Atmel driver" 27#define DRIVER_DESC "EHCI Atmel driver"
28 28
29static const char hcd_name[] = "ehci-atmel"; 29static const char hcd_name[] = "ehci-atmel";
30static struct hc_driver __read_mostly ehci_atmel_hc_driver;
31 30
32/* interface and function clocks */ 31/* interface and function clocks */
33static struct clk *iclk, *fclk, *uclk; 32#define hcd_to_atmel_ehci_priv(h) \
34static int clocked; 33 ((struct atmel_ehci_priv *)hcd_to_ehci(h)->priv)
34
35struct atmel_ehci_priv {
36 struct clk *iclk;
37 struct clk *fclk;
38 struct clk *uclk;
39 bool clocked;
40};
41
42static struct hc_driver __read_mostly ehci_atmel_hc_driver;
43
44static const struct ehci_driver_overrides ehci_atmel_drv_overrides __initconst = {
45 .extra_priv_size = sizeof(struct atmel_ehci_priv),
46};
35 47
36/*-------------------------------------------------------------------------*/ 48/*-------------------------------------------------------------------------*/
37 49
38static void atmel_start_clock(void) 50static void atmel_start_clock(struct atmel_ehci_priv *atmel_ehci)
39{ 51{
52 if (atmel_ehci->clocked)
53 return;
40 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 54 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
41 clk_set_rate(uclk, 48000000); 55 clk_set_rate(atmel_ehci->uclk, 48000000);
42 clk_prepare_enable(uclk); 56 clk_prepare_enable(atmel_ehci->uclk);
43 } 57 }
44 clk_prepare_enable(iclk); 58 clk_prepare_enable(atmel_ehci->iclk);
45 clk_prepare_enable(fclk); 59 clk_prepare_enable(atmel_ehci->fclk);
46 clocked = 1; 60 atmel_ehci->clocked = true;
47} 61}
48 62
49static void atmel_stop_clock(void) 63static void atmel_stop_clock(struct atmel_ehci_priv *atmel_ehci)
50{ 64{
51 clk_disable_unprepare(fclk); 65 if (!atmel_ehci->clocked)
52 clk_disable_unprepare(iclk); 66 return;
67 clk_disable_unprepare(atmel_ehci->fclk);
68 clk_disable_unprepare(atmel_ehci->iclk);
53 if (IS_ENABLED(CONFIG_COMMON_CLK)) 69 if (IS_ENABLED(CONFIG_COMMON_CLK))
54 clk_disable_unprepare(uclk); 70 clk_disable_unprepare(atmel_ehci->uclk);
55 clocked = 0; 71 atmel_ehci->clocked = false;
56} 72}
57 73
58static void atmel_start_ehci(struct platform_device *pdev) 74static void atmel_start_ehci(struct platform_device *pdev)
59{ 75{
76 struct usb_hcd *hcd = platform_get_drvdata(pdev);
77 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
78
60 dev_dbg(&pdev->dev, "start\n"); 79 dev_dbg(&pdev->dev, "start\n");
61 atmel_start_clock(); 80 atmel_start_clock(atmel_ehci);
62} 81}
63 82
64static void atmel_stop_ehci(struct platform_device *pdev) 83static void atmel_stop_ehci(struct platform_device *pdev)
65{ 84{
85 struct usb_hcd *hcd = platform_get_drvdata(pdev);
86 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
87
66 dev_dbg(&pdev->dev, "stop\n"); 88 dev_dbg(&pdev->dev, "stop\n");
67 atmel_stop_clock(); 89 atmel_stop_clock(atmel_ehci);
68} 90}
69 91
70/*-------------------------------------------------------------------------*/ 92/*-------------------------------------------------------------------------*/
@@ -75,6 +97,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
75 const struct hc_driver *driver = &ehci_atmel_hc_driver; 97 const struct hc_driver *driver = &ehci_atmel_hc_driver;
76 struct resource *res; 98 struct resource *res;
77 struct ehci_hcd *ehci; 99 struct ehci_hcd *ehci;
100 struct atmel_ehci_priv *atmel_ehci;
78 int irq; 101 int irq;
79 int retval; 102 int retval;
80 103
@@ -105,6 +128,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
105 retval = -ENOMEM; 128 retval = -ENOMEM;
106 goto fail_create_hcd; 129 goto fail_create_hcd;
107 } 130 }
131 atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
108 132
109 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 133 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
110 hcd->regs = devm_ioremap_resource(&pdev->dev, res); 134 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -116,23 +140,23 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
116 hcd->rsrc_start = res->start; 140 hcd->rsrc_start = res->start;
117 hcd->rsrc_len = resource_size(res); 141 hcd->rsrc_len = resource_size(res);
118 142
119 iclk = devm_clk_get(&pdev->dev, "ehci_clk"); 143 atmel_ehci->iclk = devm_clk_get(&pdev->dev, "ehci_clk");
120 if (IS_ERR(iclk)) { 144 if (IS_ERR(atmel_ehci->iclk)) {
121 dev_err(&pdev->dev, "Error getting interface clock\n"); 145 dev_err(&pdev->dev, "Error getting interface clock\n");
122 retval = -ENOENT; 146 retval = -ENOENT;
123 goto fail_request_resource; 147 goto fail_request_resource;
124 } 148 }
125 fclk = devm_clk_get(&pdev->dev, "uhpck"); 149 atmel_ehci->fclk = devm_clk_get(&pdev->dev, "uhpck");
126 if (IS_ERR(fclk)) { 150 if (IS_ERR(atmel_ehci->fclk)) {
127 dev_err(&pdev->dev, "Error getting function clock\n"); 151 dev_err(&pdev->dev, "Error getting function clock\n");
128 retval = -ENOENT; 152 retval = -ENOENT;
129 goto fail_request_resource; 153 goto fail_request_resource;
130 } 154 }
131 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 155 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
132 uclk = devm_clk_get(&pdev->dev, "usb_clk"); 156 atmel_ehci->uclk = devm_clk_get(&pdev->dev, "usb_clk");
133 if (IS_ERR(uclk)) { 157 if (IS_ERR(atmel_ehci->uclk)) {
134 dev_err(&pdev->dev, "failed to get uclk\n"); 158 dev_err(&pdev->dev, "failed to get uclk\n");
135 retval = PTR_ERR(uclk); 159 retval = PTR_ERR(atmel_ehci->uclk);
136 goto fail_request_resource; 160 goto fail_request_resource;
137 } 161 }
138 } 162 }
@@ -169,11 +193,35 @@ static int ehci_atmel_drv_remove(struct platform_device *pdev)
169 usb_put_hcd(hcd); 193 usb_put_hcd(hcd);
170 194
171 atmel_stop_ehci(pdev); 195 atmel_stop_ehci(pdev);
172 fclk = iclk = NULL;
173 196
174 return 0; 197 return 0;
175} 198}
176 199
200#ifdef CONFIG_PM
201static int ehci_atmel_drv_suspend(struct device *dev)
202{
203 struct usb_hcd *hcd = dev_get_drvdata(dev);
204 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
205 int ret;
206
207 ret = ehci_suspend(hcd, false);
208 if (ret)
209 return ret;
210
211 atmel_stop_clock(atmel_ehci);
212 return 0;
213}
214
215static int ehci_atmel_drv_resume(struct device *dev)
216{
217 struct usb_hcd *hcd = dev_get_drvdata(dev);
218 struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
219
220 atmel_start_clock(atmel_ehci);
221 return ehci_resume(hcd, false);
222}
223#endif
224
177#ifdef CONFIG_OF 225#ifdef CONFIG_OF
178static const struct of_device_id atmel_ehci_dt_ids[] = { 226static const struct of_device_id atmel_ehci_dt_ids[] = {
179 { .compatible = "atmel,at91sam9g45-ehci" }, 227 { .compatible = "atmel,at91sam9g45-ehci" },
@@ -183,12 +231,16 @@ static const struct of_device_id atmel_ehci_dt_ids[] = {
183MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids); 231MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids);
184#endif 232#endif
185 233
234static SIMPLE_DEV_PM_OPS(ehci_atmel_pm_ops, ehci_atmel_drv_suspend,
235 ehci_atmel_drv_resume);
236
186static struct platform_driver ehci_atmel_driver = { 237static struct platform_driver ehci_atmel_driver = {
187 .probe = ehci_atmel_drv_probe, 238 .probe = ehci_atmel_drv_probe,
188 .remove = ehci_atmel_drv_remove, 239 .remove = ehci_atmel_drv_remove,
189 .shutdown = usb_hcd_platform_shutdown, 240 .shutdown = usb_hcd_platform_shutdown,
190 .driver = { 241 .driver = {
191 .name = "atmel-ehci", 242 .name = "atmel-ehci",
243 .pm = &ehci_atmel_pm_ops,
192 .of_match_table = of_match_ptr(atmel_ehci_dt_ids), 244 .of_match_table = of_match_ptr(atmel_ehci_dt_ids),
193 }, 245 },
194}; 246};
@@ -199,7 +251,7 @@ static int __init ehci_atmel_init(void)
199 return -ENODEV; 251 return -ENODEV;
200 252
201 pr_info("%s: " DRIVER_DESC "\n", hcd_name); 253 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
202 ehci_init_driver(&ehci_atmel_hc_driver, NULL); 254 ehci_init_driver(&ehci_atmel_hc_driver, &ehci_atmel_drv_overrides);
203 return platform_driver_register(&ehci_atmel_driver); 255 return platform_driver_register(&ehci_atmel_driver);
204} 256}
205module_init(ehci_atmel_init); 257module_init(ehci_atmel_init);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index fb7bd0c7dc15..ab4eee3df97a 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -709,7 +709,6 @@ static struct platform_driver ehci_fsl_driver = {
709 .shutdown = usb_hcd_platform_shutdown, 709 .shutdown = usb_hcd_platform_shutdown,
710 .driver = { 710 .driver = {
711 .name = "fsl-ehci", 711 .name = "fsl-ehci",
712 .owner = THIS_MODULE,
713 .pm = EHCI_FSL_PM_OPS, 712 .pm = EHCI_FSL_PM_OPS,
714 }, 713 },
715}; 714};
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index 495b6fbcbcd9..21650044b09e 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -187,7 +187,6 @@ static struct platform_driver ehci_grlib_driver = {
187 .shutdown = usb_hcd_platform_shutdown, 187 .shutdown = usb_hcd_platform_shutdown,
188 .driver = { 188 .driver = {
189 .name = "grlib-ehci", 189 .name = "grlib-ehci",
190 .owner = THIS_MODULE,
191 .of_match_table = ehci_hcd_grlib_of_match, 190 .of_match_table = ehci_hcd_grlib_of_match,
192 }, 191 },
193}; 192};
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 38bfeedae1d0..85e56d1abd23 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1110,7 +1110,7 @@ int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1110EXPORT_SYMBOL_GPL(ehci_suspend); 1110EXPORT_SYMBOL_GPL(ehci_suspend);
1111 1111
1112/* Returns 0 if power was preserved, 1 if power was lost */ 1112/* Returns 0 if power was preserved, 1 if power was lost */
1113int ehci_resume(struct usb_hcd *hcd, bool hibernated) 1113int ehci_resume(struct usb_hcd *hcd, bool force_reset)
1114{ 1114{
1115 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 1115 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
1116 1116
@@ -1124,12 +1124,12 @@ int ehci_resume(struct usb_hcd *hcd, bool hibernated)
1124 return 0; /* Controller is dead */ 1124 return 0; /* Controller is dead */
1125 1125
1126 /* 1126 /*
1127 * If CF is still set and we aren't resuming from hibernation 1127 * If CF is still set and reset isn't forced
1128 * then we maintained suspend power. 1128 * then we maintained suspend power.
1129 * Just undo the effect of ehci_suspend(). 1129 * Just undo the effect of ehci_suspend().
1130 */ 1130 */
1131 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF && 1131 if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF &&
1132 !hibernated) { 1132 !force_reset) {
1133 int mask = INTR_MASK; 1133 int mask = INTR_MASK;
1134 1134
1135 ehci_prepare_ports_for_controller_resume(ehci); 1135 ehci_prepare_ports_for_controller_resume(ehci);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 118edb7bdca2..87cf86f38b36 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -700,15 +700,15 @@ ehci_hub_descriptor (
700 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 700 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
701 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 701 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
702 702
703 temp = 0x0008; /* per-port overcurrent reporting */ 703 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
704 if (HCS_PPC (ehci->hcs_params)) 704 if (HCS_PPC (ehci->hcs_params))
705 temp |= 0x0001; /* per-port power control */ 705 temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */
706 else 706 else
707 temp |= 0x0002; /* no power switching */ 707 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
708#if 0 708#if 0
709// re-enable when we support USB_PORT_FEAT_INDICATOR below. 709// re-enable when we support USB_PORT_FEAT_INDICATOR below.
710 if (HCS_INDICATOR (ehci->hcs_params)) 710 if (HCS_INDICATOR (ehci->hcs_params))
711 temp |= 0x0080; /* per-port indicators (LEDs) */ 711 temp |= HUB_CHAR_PORTIND; /* per-port indicators (LEDs) */
712#endif 712#endif
713 desc->wHubCharacteristics = cpu_to_le16(temp); 713 desc->wHubCharacteristics = cpu_to_le16(temp);
714} 714}
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 851006a0d97b..2a5d2fd76040 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -43,6 +43,24 @@ static inline bool is_intel_quark_x1000(struct pci_dev *pdev)
43} 43}
44 44
45/* 45/*
46 * This is the list of PCI IDs for the devices that have EHCI USB class and
47 * specific drivers for that. One of the example is a ChipIdea device installed
48 * on some Intel MID platforms.
49 */
50static const struct pci_device_id bypass_pci_id_table[] = {
51 /* ChipIdea on Intel MID platform */
52 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0811), },
53 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0829), },
54 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xe006), },
55 {}
56};
57
58static inline bool is_bypassed_id(struct pci_dev *pdev)
59{
60 return !!pci_match_id(bypass_pci_id_table, pdev);
61}
62
63/*
46 * 0x84 is the offset of in/out threshold register, 64 * 0x84 is the offset of in/out threshold register,
47 * and it is the same offset as the register of 'hostpc'. 65 * and it is the same offset as the register of 'hostpc'.
48 */ 66 */
@@ -352,6 +370,13 @@ static const struct ehci_driver_overrides pci_overrides __initconst = {
352 370
353/*-------------------------------------------------------------------------*/ 371/*-------------------------------------------------------------------------*/
354 372
373static int ehci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
374{
375 if (is_bypassed_id(pdev))
376 return -ENODEV;
377 return usb_hcd_pci_probe(pdev, id);
378}
379
355/* PCI driver selection metadata; PCI hotplugging uses this */ 380/* PCI driver selection metadata; PCI hotplugging uses this */
356static const struct pci_device_id pci_ids [] = { { 381static const struct pci_device_id pci_ids [] = { {
357 /* handle any USB 2.0 EHCI controller */ 382 /* handle any USB 2.0 EHCI controller */
@@ -370,7 +395,7 @@ static struct pci_driver ehci_pci_driver = {
370 .name = (char *) hcd_name, 395 .name = (char *) hcd_name,
371 .id_table = pci_ids, 396 .id_table = pci_ids,
372 397
373 .probe = usb_hcd_pci_probe, 398 .probe = ehci_pci_probe,
374 .remove = usb_hcd_pci_remove, 399 .remove = usb_hcd_pci_remove,
375 .shutdown = usb_hcd_pci_shutdown, 400 .shutdown = usb_hcd_pci_shutdown,
376 401
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 8557803e6154..d8a75a51d6d4 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -43,7 +43,8 @@
43struct ehci_platform_priv { 43struct ehci_platform_priv {
44 struct clk *clks[EHCI_MAX_CLKS]; 44 struct clk *clks[EHCI_MAX_CLKS];
45 struct reset_control *rst; 45 struct reset_control *rst;
46 struct phy *phy; 46 struct phy **phys;
47 int num_phys;
47}; 48};
48 49
49static const char hcd_name[] = "ehci-platform"; 50static const char hcd_name[] = "ehci-platform";
@@ -78,7 +79,7 @@ static int ehci_platform_power_on(struct platform_device *dev)
78{ 79{
79 struct usb_hcd *hcd = platform_get_drvdata(dev); 80 struct usb_hcd *hcd = platform_get_drvdata(dev);
80 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); 81 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
81 int clk, ret; 82 int clk, ret, phy_num;
82 83
83 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) { 84 for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) {
84 ret = clk_prepare_enable(priv->clks[clk]); 85 ret = clk_prepare_enable(priv->clks[clk]);
@@ -86,20 +87,28 @@ static int ehci_platform_power_on(struct platform_device *dev)
86 goto err_disable_clks; 87 goto err_disable_clks;
87 } 88 }
88 89
89 if (priv->phy) { 90 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
90 ret = phy_init(priv->phy); 91 if (priv->phys[phy_num]) {
91 if (ret) 92 ret = phy_init(priv->phys[phy_num]);
92 goto err_disable_clks; 93 if (ret)
93 94 goto err_exit_phy;
94 ret = phy_power_on(priv->phy); 95 ret = phy_power_on(priv->phys[phy_num]);
95 if (ret) 96 if (ret) {
96 goto err_exit_phy; 97 phy_exit(priv->phys[phy_num]);
98 goto err_exit_phy;
99 }
100 }
97 } 101 }
98 102
99 return 0; 103 return 0;
100 104
101err_exit_phy: 105err_exit_phy:
102 phy_exit(priv->phy); 106 while (--phy_num >= 0) {
107 if (priv->phys[phy_num]) {
108 phy_power_off(priv->phys[phy_num]);
109 phy_exit(priv->phys[phy_num]);
110 }
111 }
103err_disable_clks: 112err_disable_clks:
104 while (--clk >= 0) 113 while (--clk >= 0)
105 clk_disable_unprepare(priv->clks[clk]); 114 clk_disable_unprepare(priv->clks[clk]);
@@ -111,11 +120,13 @@ static void ehci_platform_power_off(struct platform_device *dev)
111{ 120{
112 struct usb_hcd *hcd = platform_get_drvdata(dev); 121 struct usb_hcd *hcd = platform_get_drvdata(dev);
113 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); 122 struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
114 int clk; 123 int clk, phy_num;
115 124
116 if (priv->phy) { 125 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
117 phy_power_off(priv->phy); 126 if (priv->phys[phy_num]) {
118 phy_exit(priv->phy); 127 phy_power_off(priv->phys[phy_num]);
128 phy_exit(priv->phys[phy_num]);
129 }
119 } 130 }
120 131
121 for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--) 132 for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--)
@@ -143,7 +154,8 @@ static int ehci_platform_probe(struct platform_device *dev)
143 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); 154 struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev);
144 struct ehci_platform_priv *priv; 155 struct ehci_platform_priv *priv;
145 struct ehci_hcd *ehci; 156 struct ehci_hcd *ehci;
146 int err, irq, clk = 0; 157 const char *phy_name;
158 int err, irq, phy_num, clk = 0;
147 159
148 if (usb_disabled()) 160 if (usb_disabled())
149 return -ENODEV; 161 return -ENODEV;
@@ -155,7 +167,8 @@ static int ehci_platform_probe(struct platform_device *dev)
155 if (!pdata) 167 if (!pdata)
156 pdata = &ehci_platform_defaults; 168 pdata = &ehci_platform_defaults;
157 169
158 err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); 170 err = dma_coerce_mask_and_coherent(&dev->dev,
171 pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32));
159 if (err) 172 if (err)
160 return err; 173 return err;
161 174
@@ -185,12 +198,42 @@ static int ehci_platform_probe(struct platform_device *dev)
185 if (of_property_read_bool(dev->dev.of_node, "big-endian")) 198 if (of_property_read_bool(dev->dev.of_node, "big-endian"))
186 ehci->big_endian_mmio = ehci->big_endian_desc = 1; 199 ehci->big_endian_mmio = ehci->big_endian_desc = 1;
187 200
188 priv->phy = devm_phy_get(&dev->dev, "usb"); 201 if (of_property_read_bool(dev->dev.of_node,
189 if (IS_ERR(priv->phy)) { 202 "needs-reset-on-resume"))
190 err = PTR_ERR(priv->phy); 203 pdata->reset_on_resume = 1;
191 if (err == -EPROBE_DEFER) 204
192 goto err_put_hcd; 205 priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
193 priv->phy = NULL; 206 "phys", "#phy-cells");
207 priv->num_phys = priv->num_phys > 0 ? priv->num_phys : 1;
208
209 priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
210 sizeof(struct phy *), GFP_KERNEL);
211 if (!priv->phys)
212 return -ENOMEM;
213
214 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
215 err = of_property_read_string_index(
216 dev->dev.of_node,
217 "phy-names", phy_num,
218 &phy_name);
219
220 if (err < 0) {
221 if (priv->num_phys > 1) {
222 dev_err(&dev->dev, "phy-names not provided");
223 goto err_put_hcd;
224 } else
225 phy_name = "usb";
226 }
227
228 priv->phys[phy_num] = devm_phy_get(&dev->dev,
229 phy_name);
230 if (IS_ERR(priv->phys[phy_num])) {
231 err = PTR_ERR(priv->phys[phy_num]);
232 if ((priv->num_phys > 1) ||
233 (err == -EPROBE_DEFER))
234 goto err_put_hcd;
235 priv->phys[phy_num] = NULL;
236 }
194 } 237 }
195 238
196 for (clk = 0; clk < EHCI_MAX_CLKS; clk++) { 239 for (clk = 0; clk < EHCI_MAX_CLKS; clk++) {
@@ -340,7 +383,7 @@ static int ehci_platform_resume(struct device *dev)
340 return err; 383 return err;
341 } 384 }
342 385
343 ehci_resume(hcd, false); 386 ehci_resume(hcd, pdata->reset_on_resume);
344 return 0; 387 return 0;
345} 388}
346#endif /* CONFIG_PM_SLEEP */ 389#endif /* CONFIG_PM_SLEEP */
@@ -349,6 +392,7 @@ static const struct of_device_id vt8500_ehci_ids[] = {
349 { .compatible = "via,vt8500-ehci", }, 392 { .compatible = "via,vt8500-ehci", },
350 { .compatible = "wm,prizm-ehci", }, 393 { .compatible = "wm,prizm-ehci", },
351 { .compatible = "generic-ehci", }, 394 { .compatible = "generic-ehci", },
395 { .compatible = "cavium,octeon-6335-ehci", },
352 {} 396 {}
353}; 397};
354MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); 398MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c
index 7d75465d97c7..342816a7f8b1 100644
--- a/drivers/usb/host/ehci-pmcmsp.c
+++ b/drivers/usb/host/ehci-pmcmsp.c
@@ -325,6 +325,5 @@ static struct platform_driver ehci_hcd_msp_driver = {
325 .remove = ehci_hcd_msp_drv_remove, 325 .remove = ehci_hcd_msp_drv_remove,
326 .driver = { 326 .driver = {
327 .name = "pmcmsp-ehci", 327 .name = "pmcmsp-ehci",
328 .owner = THIS_MODULE,
329 }, 328 },
330}; 329};
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 547924796d29..1a10c8d542ca 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -234,7 +234,6 @@ static struct platform_driver ehci_hcd_ppc_of_driver = {
234 .shutdown = usb_hcd_platform_shutdown, 234 .shutdown = usb_hcd_platform_shutdown,
235 .driver = { 235 .driver = {
236 .name = "ppc-of-ehci", 236 .name = "ppc-of-ehci",
237 .owner = THIS_MODULE,
238 .of_match_table = ehci_hcd_ppc_of_match, 237 .of_match_table = ehci_hcd_ppc_of_match,
239 }, 238 },
240}; 239};
diff --git a/drivers/usb/host/ehci-sead3.c b/drivers/usb/host/ehci-sead3.c
index 9b6e8d0eac43..3d86cc2ffe68 100644
--- a/drivers/usb/host/ehci-sead3.c
+++ b/drivers/usb/host/ehci-sead3.c
@@ -178,7 +178,6 @@ static struct platform_driver ehci_hcd_sead3_driver = {
178 .shutdown = usb_hcd_platform_shutdown, 178 .shutdown = usb_hcd_platform_shutdown,
179 .driver = { 179 .driver = {
180 .name = "sead3-ehci", 180 .name = "sead3-ehci",
181 .owner = THIS_MODULE,
182 .pm = SEAD3_EHCI_PMOPS, 181 .pm = SEAD3_EHCI_PMOPS,
183 } 182 }
184}; 183};
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index 0e0ce684aff3..5caf88d679e4 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -189,7 +189,6 @@ static struct platform_driver ehci_hcd_sh_driver = {
189 .shutdown = ehci_hcd_sh_shutdown, 189 .shutdown = ehci_hcd_sh_shutdown,
190 .driver = { 190 .driver = {
191 .name = "sh_ehci", 191 .name = "sh_ehci",
192 .owner = THIS_MODULE,
193 }, 192 },
194}; 193};
195 194
diff --git a/drivers/usb/host/ehci-tilegx.c b/drivers/usb/host/ehci-tilegx.c
index 0d247673c3ca..bdb93b6a356f 100644
--- a/drivers/usb/host/ehci-tilegx.c
+++ b/drivers/usb/host/ehci-tilegx.c
@@ -210,7 +210,6 @@ static struct platform_driver ehci_hcd_tilegx_driver = {
210 .shutdown = ehci_hcd_tilegx_drv_shutdown, 210 .shutdown = ehci_hcd_tilegx_drv_shutdown,
211 .driver = { 211 .driver = {
212 .name = "tilegx-ehci", 212 .name = "tilegx-ehci",
213 .owner = THIS_MODULE,
214 } 213 }
215}; 214};
216 215
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index a2328361dc80..f54480850bb8 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -236,7 +236,6 @@ static struct platform_driver ehci_hcd_xilinx_of_driver = {
236 .shutdown = usb_hcd_platform_shutdown, 236 .shutdown = usb_hcd_platform_shutdown,
237 .driver = { 237 .driver = {
238 .name = "xilinx-of-ehci", 238 .name = "xilinx-of-ehci",
239 .owner = THIS_MODULE,
240 .of_match_table = ehci_hcd_xilinx_of_match, 239 .of_match_table = ehci_hcd_xilinx_of_match,
241 }, 240 },
242}; 241};
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 6f0577b0a5ae..52ef0844a180 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -871,7 +871,7 @@ extern int ehci_handshake(struct ehci_hcd *ehci, void __iomem *ptr,
871 871
872#ifdef CONFIG_PM 872#ifdef CONFIG_PM
873extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup); 873extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup);
874extern int ehci_resume(struct usb_hcd *hcd, bool hibernated); 874extern int ehci_resume(struct usb_hcd *hcd, bool force_reset);
875#endif /* CONFIG_PM */ 875#endif /* CONFIG_PM */
876 876
877extern int ehci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 877extern int ehci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
diff --git a/drivers/usb/host/fhci-hub.c b/drivers/usb/host/fhci-hub.c
index 6af2512f8378..70116a65262c 100644
--- a/drivers/usb/host/fhci-hub.c
+++ b/drivers/usb/host/fhci-hub.c
@@ -32,8 +32,8 @@ static u8 root_hub_des[] = {
32 0x09, /* blength */ 32 0x09, /* blength */
33 0x29, /* bDescriptorType;hub-descriptor */ 33 0x29, /* bDescriptorType;hub-descriptor */
34 0x01, /* bNbrPorts */ 34 0x01, /* bNbrPorts */
35 0x00, /* wHubCharacteristics */ 35 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM, /* wHubCharacteristics */
36 0x00, 36 0x00, /* per-port power, no overcurrent */
37 0x01, /* bPwrOn2pwrGood;2ms */ 37 0x01, /* bPwrOn2pwrGood;2ms */
38 0x00, /* bHubContrCurrent;0mA */ 38 0x00, /* bHubContrCurrent;0mA */
39 0x00, /* DeviceRemoveable */ 39 0x00, /* DeviceRemoveable */
@@ -208,7 +208,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
208{ 208{
209 struct fhci_hcd *fhci = hcd_to_fhci(hcd); 209 struct fhci_hcd *fhci = hcd_to_fhci(hcd);
210 int retval = 0; 210 int retval = 0;
211 int len = 0;
212 struct usb_hub_status *hub_status; 211 struct usb_hub_status *hub_status;
213 struct usb_port_status *port_status; 212 struct usb_port_status *port_status;
214 unsigned long flags; 213 unsigned long flags;
@@ -272,8 +271,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
272 break; 271 break;
273 case GetHubDescriptor: 272 case GetHubDescriptor:
274 memcpy(buf, root_hub_des, sizeof(root_hub_des)); 273 memcpy(buf, root_hub_des, sizeof(root_hub_des));
275 buf[3] = 0x11; /* per-port power, no ovrcrnt */
276 len = (buf[0] < wLength) ? buf[0] : wLength;
277 break; 274 break;
278 case GetHubStatus: 275 case GetHubStatus:
279 hub_status = (struct usb_hub_status *)buf; 276 hub_status = (struct usb_hub_status *)buf;
@@ -281,7 +278,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
281 cpu_to_le16(fhci->vroot_hub->hub.wHubStatus); 278 cpu_to_le16(fhci->vroot_hub->hub.wHubStatus);
282 hub_status->wHubChange = 279 hub_status->wHubChange =
283 cpu_to_le16(fhci->vroot_hub->hub.wHubChange); 280 cpu_to_le16(fhci->vroot_hub->hub.wHubChange);
284 len = 4;
285 break; 281 break;
286 case GetPortStatus: 282 case GetPortStatus:
287 port_status = (struct usb_port_status *)buf; 283 port_status = (struct usb_port_status *)buf;
@@ -289,7 +285,6 @@ int fhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
289 cpu_to_le16(fhci->vroot_hub->port.wPortStatus); 285 cpu_to_le16(fhci->vroot_hub->port.wPortStatus);
290 port_status->wPortChange = 286 port_status->wPortChange =
291 cpu_to_le16(fhci->vroot_hub->port.wPortChange); 287 cpu_to_le16(fhci->vroot_hub->port.wPortChange);
292 len = 4;
293 break; 288 break;
294 case SetHubFeature: 289 case SetHubFeature:
295 switch (wValue) { 290 switch (wValue) {
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index ecf02b2623e8..475b21fd373b 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -1521,8 +1521,8 @@ fotg210_hub_descriptor(
1521 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 1521 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
1522 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 1522 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
1523 1523
1524 temp = 0x0008; /* per-port overcurrent reporting */ 1524 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
1525 temp |= 0x0002; /* no power switching */ 1525 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
1526 desc->wHubCharacteristics = cpu_to_le16(temp); 1526 desc->wHubCharacteristics = cpu_to_le16(temp);
1527} 1527}
1528 1528
diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
index 664d2aa1239c..a83eefefffda 100644
--- a/drivers/usb/host/fusbh200-hcd.c
+++ b/drivers/usb/host/fusbh200-hcd.c
@@ -1479,8 +1479,8 @@ fusbh200_hub_descriptor (
1479 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 1479 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
1480 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 1480 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
1481 1481
1482 temp = 0x0008; /* per-port overcurrent reporting */ 1482 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
1483 temp |= 0x0002; /* no power switching */ 1483 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
1484 desc->wHubCharacteristics = cpu_to_le16(temp); 1484 desc->wHubCharacteristics = cpu_to_le16(temp);
1485} 1485}
1486 1486
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index eb4efba9f1ad..6a2ad550b120 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -1482,9 +1482,8 @@ static int get_hub_descriptor(struct usb_hcd *hcd,
1482 desc->bDescLength = 9; 1482 desc->bDescLength = 9;
1483 desc->bPwrOn2PwrGood = 0; 1483 desc->bPwrOn2PwrGood = 0;
1484 desc->wHubCharacteristics = (__force __u16) cpu_to_le16( 1484 desc->wHubCharacteristics = (__force __u16) cpu_to_le16(
1485 0x0002 | /* No power switching */ 1485 HUB_CHAR_NO_LPSM | /* No power switching */
1486 0x0010 | /* No over current protection */ 1486 HUB_CHAR_NO_OCPM); /* No over current protection */
1487 0);
1488 1487
1489 desc->u.hs.DeviceRemovable[0] = 1 << 1; 1488 desc->u.hs.DeviceRemovable[0] = 1 << 1;
1490 desc->u.hs.DeviceRemovable[1] = ~0; 1489 desc->u.hs.DeviceRemovable[1] = ~0;
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 31c9c4d0fa0b..113d0cc6cc43 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -948,7 +948,10 @@ static void isp116x_hub_descriptor(struct isp116x *isp116x,
948 desc->bHubContrCurrent = 0; 948 desc->bHubContrCurrent = 0;
949 desc->bNbrPorts = (u8) (reg & 0x3); 949 desc->bNbrPorts = (u8) (reg & 0x3);
950 /* Power switching, device type, overcurrent. */ 950 /* Power switching, device type, overcurrent. */
951 desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) & 0x1f)); 951 desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) &
952 (HUB_CHAR_LPSM |
953 HUB_CHAR_COMPOUND |
954 HUB_CHAR_OCPM)));
952 desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff); 955 desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff);
953 /* ports removable, and legacy PortPwrCtrlMask */ 956 /* ports removable, and legacy PortPwrCtrlMask */
954 desc->u.hs.DeviceRemovable[0] = 0; 957 desc->u.hs.DeviceRemovable[0] = 0;
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 75e5876f9d7c..b32ab60cad1e 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -1543,8 +1543,12 @@ static void isp1362_hub_descriptor(struct isp1362_hcd *isp1362_hcd,
1543 desc->bHubContrCurrent = 0; 1543 desc->bHubContrCurrent = 0;
1544 desc->bNbrPorts = reg & 0x3; 1544 desc->bNbrPorts = reg & 0x3;
1545 /* Power switching, device type, overcurrent. */ 1545 /* Power switching, device type, overcurrent. */
1546 desc->wHubCharacteristics = cpu_to_le16((reg >> 8) & 0x1f); 1546 desc->wHubCharacteristics = cpu_to_le16((reg >> 8) &
1547 DBG(0, "%s: hubcharacteristics = %02x\n", __func__, cpu_to_le16((reg >> 8) & 0x1f)); 1547 (HUB_CHAR_LPSM |
1548 HUB_CHAR_COMPOUND |
1549 HUB_CHAR_OCPM));
1550 DBG(0, "%s: hubcharacteristics = %02x\n", __func__,
1551 desc->wHubCharacteristics);
1548 desc->bPwrOn2PwrGood = (reg >> 24) & 0xff; 1552 desc->bPwrOn2PwrGood = (reg >> 24) & 0xff;
1549 /* ports removable, and legacy PortPwrCtrlMask */ 1553 /* ports removable, and legacy PortPwrCtrlMask */
1550 desc->u.hs.DeviceRemovable[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1; 1554 desc->u.hs.DeviceRemovable[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1;
diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 6234c75da33f..a98833cbfcf3 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -55,6 +55,7 @@
55 * single thread (max3421_spi_thread). 55 * single thread (max3421_spi_thread).
56 */ 56 */
57 57
58#include <linux/jiffies.h>
58#include <linux/module.h> 59#include <linux/module.h>
59#include <linux/spi/spi.h> 60#include <linux/spi/spi.h>
60#include <linux/usb.h> 61#include <linux/usb.h>
@@ -1291,7 +1292,7 @@ max3421_handle_irqs(struct usb_hcd *hcd)
1291 char sbuf[16 * 16], *dp, *end; 1292 char sbuf[16 * 16], *dp, *end;
1292 int i; 1293 int i;
1293 1294
1294 if (jiffies - last_time > 5*HZ) { 1295 if (time_after(jiffies, last_time + 5*HZ)) {
1295 dp = sbuf; 1296 dp = sbuf;
1296 end = sbuf + sizeof(sbuf); 1297 end = sbuf + sizeof(sbuf);
1297 *dp = '\0'; 1298 *dp = '\0';
@@ -1660,7 +1661,8 @@ hub_descriptor(struct usb_hub_descriptor *desc)
1660 */ 1661 */
1661 desc->bDescriptorType = 0x29; /* hub descriptor */ 1662 desc->bDescriptorType = 0x29; /* hub descriptor */
1662 desc->bDescLength = 9; 1663 desc->bDescLength = 9;
1663 desc->wHubCharacteristics = cpu_to_le16(0x0001); 1664 desc->wHubCharacteristics = cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM |
1665 HUB_CHAR_COMMON_OCPM);
1664 desc->bNbrPorts = 1; 1666 desc->bNbrPorts = 1;
1665} 1667}
1666 1668
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index dc9e4e61f1c8..7cce85a1f7dc 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -33,7 +33,17 @@
33 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++) 33 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
34 34
35/* interface, function and usb clocks; sometimes also an AHB clock */ 35/* interface, function and usb clocks; sometimes also an AHB clock */
36static struct clk *iclk, *fclk, *uclk, *hclk; 36#define hcd_to_ohci_at91_priv(h) \
37 ((struct ohci_at91_priv *)hcd_to_ohci(h)->priv)
38
39struct ohci_at91_priv {
40 struct clk *iclk;
41 struct clk *fclk;
42 struct clk *uclk;
43 struct clk *hclk;
44 bool clocked;
45 bool wakeup; /* Saved wake-up state for resume */
46};
37/* interface and function clocks; sometimes also an AHB clock */ 47/* interface and function clocks; sometimes also an AHB clock */
38 48
39#define DRIVER_DESC "OHCI Atmel driver" 49#define DRIVER_DESC "OHCI Atmel driver"
@@ -41,45 +51,53 @@ static struct clk *iclk, *fclk, *uclk, *hclk;
41static const char hcd_name[] = "ohci-atmel"; 51static const char hcd_name[] = "ohci-atmel";
42 52
43static struct hc_driver __read_mostly ohci_at91_hc_driver; 53static struct hc_driver __read_mostly ohci_at91_hc_driver;
44static int clocked; 54
55static const struct ohci_driver_overrides ohci_at91_drv_overrides __initconst = {
56 .extra_priv_size = sizeof(struct ohci_at91_priv),
57};
45 58
46extern int usb_disabled(void); 59extern int usb_disabled(void);
47 60
48/*-------------------------------------------------------------------------*/ 61/*-------------------------------------------------------------------------*/
49 62
50static void at91_start_clock(void) 63static void at91_start_clock(struct ohci_at91_priv *ohci_at91)
51{ 64{
65 if (ohci_at91->clocked)
66 return;
52 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 67 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
53 clk_set_rate(uclk, 48000000); 68 clk_set_rate(ohci_at91->uclk, 48000000);
54 clk_prepare_enable(uclk); 69 clk_prepare_enable(ohci_at91->uclk);
55 } 70 }
56 clk_prepare_enable(hclk); 71 clk_prepare_enable(ohci_at91->hclk);
57 clk_prepare_enable(iclk); 72 clk_prepare_enable(ohci_at91->iclk);
58 clk_prepare_enable(fclk); 73 clk_prepare_enable(ohci_at91->fclk);
59 clocked = 1; 74 ohci_at91->clocked = true;
60} 75}
61 76
62static void at91_stop_clock(void) 77static void at91_stop_clock(struct ohci_at91_priv *ohci_at91)
63{ 78{
64 clk_disable_unprepare(fclk); 79 if (!ohci_at91->clocked)
65 clk_disable_unprepare(iclk); 80 return;
66 clk_disable_unprepare(hclk); 81 clk_disable_unprepare(ohci_at91->fclk);
82 clk_disable_unprepare(ohci_at91->iclk);
83 clk_disable_unprepare(ohci_at91->hclk);
67 if (IS_ENABLED(CONFIG_COMMON_CLK)) 84 if (IS_ENABLED(CONFIG_COMMON_CLK))
68 clk_disable_unprepare(uclk); 85 clk_disable_unprepare(ohci_at91->uclk);
69 clocked = 0; 86 ohci_at91->clocked = false;
70} 87}
71 88
72static void at91_start_hc(struct platform_device *pdev) 89static void at91_start_hc(struct platform_device *pdev)
73{ 90{
74 struct usb_hcd *hcd = platform_get_drvdata(pdev); 91 struct usb_hcd *hcd = platform_get_drvdata(pdev);
75 struct ohci_regs __iomem *regs = hcd->regs; 92 struct ohci_regs __iomem *regs = hcd->regs;
93 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
76 94
77 dev_dbg(&pdev->dev, "start\n"); 95 dev_dbg(&pdev->dev, "start\n");
78 96
79 /* 97 /*
80 * Start the USB clocks. 98 * Start the USB clocks.
81 */ 99 */
82 at91_start_clock(); 100 at91_start_clock(ohci_at91);
83 101
84 /* 102 /*
85 * The USB host controller must remain in reset. 103 * The USB host controller must remain in reset.
@@ -91,6 +109,7 @@ static void at91_stop_hc(struct platform_device *pdev)
91{ 109{
92 struct usb_hcd *hcd = platform_get_drvdata(pdev); 110 struct usb_hcd *hcd = platform_get_drvdata(pdev);
93 struct ohci_regs __iomem *regs = hcd->regs; 111 struct ohci_regs __iomem *regs = hcd->regs;
112 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
94 113
95 dev_dbg(&pdev->dev, "stop\n"); 114 dev_dbg(&pdev->dev, "stop\n");
96 115
@@ -102,7 +121,7 @@ static void at91_stop_hc(struct platform_device *pdev)
102 /* 121 /*
103 * Stop the USB clocks. 122 * Stop the USB clocks.
104 */ 123 */
105 at91_stop_clock(); 124 at91_stop_clock(ohci_at91);
106} 125}
107 126
108 127
@@ -128,7 +147,8 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
128 struct at91_usbh_data *board; 147 struct at91_usbh_data *board;
129 struct ohci_hcd *ohci; 148 struct ohci_hcd *ohci;
130 int retval; 149 int retval;
131 struct usb_hcd *hcd = NULL; 150 struct usb_hcd *hcd;
151 struct ohci_at91_priv *ohci_at91;
132 struct device *dev = &pdev->dev; 152 struct device *dev = &pdev->dev;
133 struct resource *res; 153 struct resource *res;
134 int irq; 154 int irq;
@@ -142,6 +162,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
142 hcd = usb_create_hcd(driver, dev, "at91"); 162 hcd = usb_create_hcd(driver, dev, "at91");
143 if (!hcd) 163 if (!hcd)
144 return -ENOMEM; 164 return -ENOMEM;
165 ohci_at91 = hcd_to_ohci_at91_priv(hcd);
145 166
146 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 167 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
147 hcd->regs = devm_ioremap_resource(dev, res); 168 hcd->regs = devm_ioremap_resource(dev, res);
@@ -152,29 +173,29 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
152 hcd->rsrc_start = res->start; 173 hcd->rsrc_start = res->start;
153 hcd->rsrc_len = resource_size(res); 174 hcd->rsrc_len = resource_size(res);
154 175
155 iclk = devm_clk_get(dev, "ohci_clk"); 176 ohci_at91->iclk = devm_clk_get(dev, "ohci_clk");
156 if (IS_ERR(iclk)) { 177 if (IS_ERR(ohci_at91->iclk)) {
157 dev_err(dev, "failed to get ohci_clk\n"); 178 dev_err(dev, "failed to get ohci_clk\n");
158 retval = PTR_ERR(iclk); 179 retval = PTR_ERR(ohci_at91->iclk);
159 goto err; 180 goto err;
160 } 181 }
161 fclk = devm_clk_get(dev, "uhpck"); 182 ohci_at91->fclk = devm_clk_get(dev, "uhpck");
162 if (IS_ERR(fclk)) { 183 if (IS_ERR(ohci_at91->fclk)) {
163 dev_err(dev, "failed to get uhpck\n"); 184 dev_err(dev, "failed to get uhpck\n");
164 retval = PTR_ERR(fclk); 185 retval = PTR_ERR(ohci_at91->fclk);
165 goto err; 186 goto err;
166 } 187 }
167 hclk = devm_clk_get(dev, "hclk"); 188 ohci_at91->hclk = devm_clk_get(dev, "hclk");
168 if (IS_ERR(hclk)) { 189 if (IS_ERR(ohci_at91->hclk)) {
169 dev_err(dev, "failed to get hclk\n"); 190 dev_err(dev, "failed to get hclk\n");
170 retval = PTR_ERR(hclk); 191 retval = PTR_ERR(ohci_at91->hclk);
171 goto err; 192 goto err;
172 } 193 }
173 if (IS_ENABLED(CONFIG_COMMON_CLK)) { 194 if (IS_ENABLED(CONFIG_COMMON_CLK)) {
174 uclk = devm_clk_get(dev, "usb_clk"); 195 ohci_at91->uclk = devm_clk_get(dev, "usb_clk");
175 if (IS_ERR(uclk)) { 196 if (IS_ERR(ohci_at91->uclk)) {
176 dev_err(dev, "failed to get uclk\n"); 197 dev_err(dev, "failed to get uclk\n");
177 retval = PTR_ERR(uclk); 198 retval = PTR_ERR(ohci_at91->uclk);
178 goto err; 199 goto err;
179 } 200 }
180 } 201 }
@@ -347,11 +368,13 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
347 */ 368 */
348 369
349 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); 370 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
350 desc->wHubCharacteristics |= cpu_to_le16(0x0001); 371 desc->wHubCharacteristics |=
372 cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM);
351 373
352 if (pdata->overcurrent_supported) { 374 if (pdata->overcurrent_supported) {
353 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM); 375 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM);
354 desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001); 376 desc->wHubCharacteristics |=
377 cpu_to_le16(HUB_CHAR_INDV_PORT_OCPM);
355 } 378 }
356 379
357 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", 380 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
@@ -593,19 +616,27 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev)
593#ifdef CONFIG_PM 616#ifdef CONFIG_PM
594 617
595static int 618static int
596ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg) 619ohci_hcd_at91_drv_suspend(struct device *dev)
597{ 620{
598 struct usb_hcd *hcd = platform_get_drvdata(pdev); 621 struct usb_hcd *hcd = dev_get_drvdata(dev);
599 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 622 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
600 bool do_wakeup = device_may_wakeup(&pdev->dev); 623 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
601 int ret; 624 int ret;
602 625
603 if (do_wakeup) 626 /*
627 * Disable wakeup if we are going to sleep with slow clock mode
628 * enabled.
629 */
630 ohci_at91->wakeup = device_may_wakeup(dev)
631 && !at91_suspend_entering_slow_clock();
632
633 if (ohci_at91->wakeup)
604 enable_irq_wake(hcd->irq); 634 enable_irq_wake(hcd->irq);
605 635
606 ret = ohci_suspend(hcd, do_wakeup); 636 ret = ohci_suspend(hcd, ohci_at91->wakeup);
607 if (ret) { 637 if (ret) {
608 disable_irq_wake(hcd->irq); 638 if (ohci_at91->wakeup)
639 disable_irq_wake(hcd->irq);
609 return ret; 640 return ret;
610 } 641 }
611 /* 642 /*
@@ -615,7 +646,7 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
615 * 646 *
616 * REVISIT: some boards will be able to turn VBUS off... 647 * REVISIT: some boards will be able to turn VBUS off...
617 */ 648 */
618 if (at91_suspend_entering_slow_clock()) { 649 if (!ohci_at91->wakeup) {
619 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); 650 ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
620 ohci->hc_control &= OHCI_CTRL_RWC; 651 ohci->hc_control &= OHCI_CTRL_RWC;
621 ohci_writel(ohci, ohci->hc_control, &ohci->regs->control); 652 ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
@@ -623,38 +654,37 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
623 654
624 /* flush the writes */ 655 /* flush the writes */
625 (void) ohci_readl (ohci, &ohci->regs->control); 656 (void) ohci_readl (ohci, &ohci->regs->control);
626 at91_stop_clock(); 657 at91_stop_clock(ohci_at91);
627 } 658 }
628 659
629 return ret; 660 return ret;
630} 661}
631 662
632static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) 663static int ohci_hcd_at91_drv_resume(struct device *dev)
633{ 664{
634 struct usb_hcd *hcd = platform_get_drvdata(pdev); 665 struct usb_hcd *hcd = dev_get_drvdata(dev);
666 struct ohci_at91_priv *ohci_at91 = hcd_to_ohci_at91_priv(hcd);
635 667
636 if (device_may_wakeup(&pdev->dev)) 668 if (ohci_at91->wakeup)
637 disable_irq_wake(hcd->irq); 669 disable_irq_wake(hcd->irq);
638 670
639 if (!clocked) 671 at91_start_clock(ohci_at91);
640 at91_start_clock();
641 672
642 ohci_resume(hcd, false); 673 ohci_resume(hcd, false);
643 return 0; 674 return 0;
644} 675}
645#else
646#define ohci_hcd_at91_drv_suspend NULL
647#define ohci_hcd_at91_drv_resume NULL
648#endif 676#endif
649 677
678static SIMPLE_DEV_PM_OPS(ohci_hcd_at91_pm_ops, ohci_hcd_at91_drv_suspend,
679 ohci_hcd_at91_drv_resume);
680
650static struct platform_driver ohci_hcd_at91_driver = { 681static struct platform_driver ohci_hcd_at91_driver = {
651 .probe = ohci_hcd_at91_drv_probe, 682 .probe = ohci_hcd_at91_drv_probe,
652 .remove = ohci_hcd_at91_drv_remove, 683 .remove = ohci_hcd_at91_drv_remove,
653 .shutdown = usb_hcd_platform_shutdown, 684 .shutdown = usb_hcd_platform_shutdown,
654 .suspend = ohci_hcd_at91_drv_suspend,
655 .resume = ohci_hcd_at91_drv_resume,
656 .driver = { 685 .driver = {
657 .name = "at91_ohci", 686 .name = "at91_ohci",
687 .pm = &ohci_hcd_at91_pm_ops,
658 .of_match_table = of_match_ptr(at91_ohci_dt_ids), 688 .of_match_table = of_match_ptr(at91_ohci_dt_ids),
659 }, 689 },
660}; 690};
@@ -665,7 +695,7 @@ static int __init ohci_at91_init(void)
665 return -ENODEV; 695 return -ENODEV;
666 696
667 pr_info("%s: " DRIVER_DESC "\n", hcd_name); 697 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
668 ohci_init_driver(&ohci_at91_hc_driver, NULL); 698 ohci_init_driver(&ohci_at91_hc_driver, &ohci_at91_drv_overrides);
669 699
670 /* 700 /*
671 * The Atmel HW has some unusual quirks, which require Atmel-specific 701 * The Atmel HW has some unusual quirks, which require Atmel-specific
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 1c76999b2184..e5c33bc98ea4 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -431,7 +431,6 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
431 .resume = ohci_da8xx_resume, 431 .resume = ohci_da8xx_resume,
432#endif 432#endif
433 .driver = { 433 .driver = {
434 .owner = THIS_MODULE,
435 .name = "ohci", 434 .name = "ohci",
436 }, 435 },
437}; 436};
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 0aa17c937115..fe2aedd8a54d 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -544,15 +544,15 @@ ohci_hub_descriptor (
544 temp = 1 + (ohci->num_ports / 8); 544 temp = 1 + (ohci->num_ports / 8);
545 desc->bDescLength = 7 + 2 * temp; 545 desc->bDescLength = 7 + 2 * temp;
546 546
547 temp = 0; 547 temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM;
548 if (rh & RH_A_NPS) /* no power switching? */ 548 if (rh & RH_A_NPS) /* no power switching? */
549 temp |= 0x0002; 549 temp |= HUB_CHAR_NO_LPSM;
550 if (rh & RH_A_PSM) /* per-port power switching? */ 550 if (rh & RH_A_PSM) /* per-port power switching? */
551 temp |= 0x0001; 551 temp |= HUB_CHAR_INDV_PORT_LPSM;
552 if (rh & RH_A_NOCP) /* no overcurrent reporting? */ 552 if (rh & RH_A_NOCP) /* no overcurrent reporting? */
553 temp |= 0x0010; 553 temp |= HUB_CHAR_NO_OCPM;
554 else if (rh & RH_A_OCPM) /* per-port overcurrent reporting? */ 554 else if (rh & RH_A_OCPM) /* per-port overcurrent reporting? */
555 temp |= 0x0008; 555 temp |= HUB_CHAR_INDV_PORT_OCPM;
556 desc->wHubCharacteristics = cpu_to_le16(temp); 556 desc->wHubCharacteristics = cpu_to_le16(temp);
557 557
558 /* ports removable, and usb 1.0 legacy PortPwrCtrlMask */ 558 /* ports removable, and usb 1.0 legacy PortPwrCtrlMask */
diff --git a/drivers/usb/host/ohci-jz4740.c b/drivers/usb/host/ohci-jz4740.c
index 8ddd8f5470cb..4db78f169256 100644
--- a/drivers/usb/host/ohci-jz4740.c
+++ b/drivers/usb/host/ohci-jz4740.c
@@ -239,7 +239,6 @@ static struct platform_driver ohci_hcd_jz4740_driver = {
239 .remove = jz4740_ohci_remove, 239 .remove = jz4740_ohci_remove,
240 .driver = { 240 .driver = {
241 .name = "jz4740-ohci", 241 .name = "jz4740-ohci",
242 .owner = THIS_MODULE,
243 }, 242 },
244}; 243};
245 244
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index b81d202b15a2..185ceee52d47 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -38,7 +38,8 @@
38struct ohci_platform_priv { 38struct ohci_platform_priv {
39 struct clk *clks[OHCI_MAX_CLKS]; 39 struct clk *clks[OHCI_MAX_CLKS];
40 struct reset_control *rst; 40 struct reset_control *rst;
41 struct phy *phy; 41 struct phy **phys;
42 int num_phys;
42}; 43};
43 44
44static const char hcd_name[] = "ohci-platform"; 45static const char hcd_name[] = "ohci-platform";
@@ -47,7 +48,7 @@ static int ohci_platform_power_on(struct platform_device *dev)
47{ 48{
48 struct usb_hcd *hcd = platform_get_drvdata(dev); 49 struct usb_hcd *hcd = platform_get_drvdata(dev);
49 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); 50 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
50 int clk, ret; 51 int clk, ret, phy_num;
51 52
52 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) { 53 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
53 ret = clk_prepare_enable(priv->clks[clk]); 54 ret = clk_prepare_enable(priv->clks[clk]);
@@ -55,20 +56,28 @@ static int ohci_platform_power_on(struct platform_device *dev)
55 goto err_disable_clks; 56 goto err_disable_clks;
56 } 57 }
57 58
58 if (priv->phy) { 59 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
59 ret = phy_init(priv->phy); 60 if (priv->phys[phy_num]) {
60 if (ret) 61 ret = phy_init(priv->phys[phy_num]);
61 goto err_disable_clks; 62 if (ret)
62 63 goto err_exit_phy;
63 ret = phy_power_on(priv->phy); 64 ret = phy_power_on(priv->phys[phy_num]);
64 if (ret) 65 if (ret) {
65 goto err_exit_phy; 66 phy_exit(priv->phys[phy_num]);
67 goto err_exit_phy;
68 }
69 }
66 } 70 }
67 71
68 return 0; 72 return 0;
69 73
70err_exit_phy: 74err_exit_phy:
71 phy_exit(priv->phy); 75 while (--phy_num >= 0) {
76 if (priv->phys[phy_num]) {
77 phy_power_off(priv->phys[phy_num]);
78 phy_exit(priv->phys[phy_num]);
79 }
80 }
72err_disable_clks: 81err_disable_clks:
73 while (--clk >= 0) 82 while (--clk >= 0)
74 clk_disable_unprepare(priv->clks[clk]); 83 clk_disable_unprepare(priv->clks[clk]);
@@ -80,11 +89,13 @@ static void ohci_platform_power_off(struct platform_device *dev)
80{ 89{
81 struct usb_hcd *hcd = platform_get_drvdata(dev); 90 struct usb_hcd *hcd = platform_get_drvdata(dev);
82 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); 91 struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
83 int clk; 92 int clk, phy_num;
84 93
85 if (priv->phy) { 94 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
86 phy_power_off(priv->phy); 95 if (priv->phys[phy_num]) {
87 phy_exit(priv->phy); 96 phy_power_off(priv->phys[phy_num]);
97 phy_exit(priv->phys[phy_num]);
98 }
88 } 99 }
89 100
90 for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--) 101 for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
@@ -112,7 +123,8 @@ static int ohci_platform_probe(struct platform_device *dev)
112 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); 123 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev);
113 struct ohci_platform_priv *priv; 124 struct ohci_platform_priv *priv;
114 struct ohci_hcd *ohci; 125 struct ohci_hcd *ohci;
115 int err, irq, clk = 0; 126 const char *phy_name;
127 int err, irq, phy_num, clk = 0;
116 128
117 if (usb_disabled()) 129 if (usb_disabled())
118 return -ENODEV; 130 return -ENODEV;
@@ -160,12 +172,38 @@ static int ohci_platform_probe(struct platform_device *dev)
160 of_property_read_u32(dev->dev.of_node, "num-ports", 172 of_property_read_u32(dev->dev.of_node, "num-ports",
161 &ohci->num_ports); 173 &ohci->num_ports);
162 174
163 priv->phy = devm_phy_get(&dev->dev, "usb"); 175 priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
164 if (IS_ERR(priv->phy)) { 176 "phys", "#phy-cells");
165 err = PTR_ERR(priv->phy); 177 priv->num_phys = priv->num_phys > 0 ? priv->num_phys : 1;
166 if (err == -EPROBE_DEFER) 178
167 goto err_put_hcd; 179 priv->phys = devm_kcalloc(&dev->dev, priv->num_phys,
168 priv->phy = NULL; 180 sizeof(struct phy *), GFP_KERNEL);
181 if (!priv->phys)
182 return -ENOMEM;
183
184 for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
185 err = of_property_read_string_index(
186 dev->dev.of_node,
187 "phy-names", phy_num,
188 &phy_name);
189
190 if (err < 0) {
191 if (priv->num_phys > 1) {
192 dev_err(&dev->dev, "phy-names not provided");
193 goto err_put_hcd;
194 } else
195 phy_name = "usb";
196 }
197
198 priv->phys[phy_num] = devm_phy_get(&dev->dev,
199 phy_name);
200 if (IS_ERR(priv->phys[phy_num])) {
201 err = PTR_ERR(priv->phys[phy_num]);
202 if ((priv->num_phys > 1) ||
203 (err == -EPROBE_DEFER))
204 goto err_put_hcd;
205 priv->phys[phy_num] = NULL;
206 }
169 } 207 }
170 208
171 for (clk = 0; clk < OHCI_MAX_CLKS; clk++) { 209 for (clk = 0; clk < OHCI_MAX_CLKS; clk++) {
@@ -328,6 +366,7 @@ static int ohci_platform_resume(struct device *dev)
328 366
329static const struct of_device_id ohci_platform_ids[] = { 367static const struct of_device_id ohci_platform_ids[] = {
330 { .compatible = "generic-ohci", }, 368 { .compatible = "generic-ohci", },
369 { .compatible = "cavium,octeon-6335-ohci", },
331 { } 370 { }
332}; 371};
333MODULE_DEVICE_TABLE(of, ohci_platform_ids); 372MODULE_DEVICE_TABLE(of, ohci_platform_ids);
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 965e3e9e688a..4f87a5c61b08 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -229,7 +229,6 @@ static struct platform_driver ohci_hcd_ppc_of_driver = {
229 .shutdown = usb_hcd_platform_shutdown, 229 .shutdown = usb_hcd_platform_shutdown,
230 .driver = { 230 .driver = {
231 .name = "ppc-of-ohci", 231 .name = "ppc-of-ohci",
232 .owner = THIS_MODULE,
233 .of_match_table = ohci_hcd_ppc_of_match, 232 .of_match_table = ohci_hcd_ppc_of_match,
234 }, 233 },
235}; 234};
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 095113ea1fcb..7a1919ca543a 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -249,14 +249,14 @@ static int ohci_s3c2410_hub_control(
249 */ 249 */
250 250
251 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); 251 desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM);
252 desc->wHubCharacteristics |= cpu_to_le16(0x0001); 252 desc->wHubCharacteristics |= cpu_to_le16(
253 HUB_CHAR_INDV_PORT_LPSM);
253 254
254 if (info->enable_oc) { 255 if (info->enable_oc) {
255 desc->wHubCharacteristics &= ~cpu_to_le16( 256 desc->wHubCharacteristics &= ~cpu_to_le16(
256 HUB_CHAR_OCPM); 257 HUB_CHAR_OCPM);
257 desc->wHubCharacteristics |= cpu_to_le16( 258 desc->wHubCharacteristics |= cpu_to_le16(
258 0x0008 | 259 HUB_CHAR_INDV_PORT_OCPM);
259 0x0001);
260 } 260 }
261 261
262 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", 262 dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n",
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 4e81c804c73e..a8b8d8b8d9f3 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -265,7 +265,6 @@ static struct platform_driver ohci_hcd_sm501_driver = {
265 .suspend = ohci_sm501_suspend, 265 .suspend = ohci_sm501_suspend,
266 .resume = ohci_sm501_resume, 266 .resume = ohci_sm501_resume,
267 .driver = { 267 .driver = {
268 .owner = THIS_MODULE,
269 .name = "sm501-usb", 268 .name = "sm501-usb",
270 }, 269 },
271}; 270};
diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c
index bef6dfb0405a..e1b208da460a 100644
--- a/drivers/usb/host/ohci-tilegx.c
+++ b/drivers/usb/host/ohci-tilegx.c
@@ -199,7 +199,6 @@ static struct platform_driver ohci_hcd_tilegx_driver = {
199 .shutdown = ohci_hcd_tilegx_drv_shutdown, 199 .shutdown = ohci_hcd_tilegx_drv_shutdown,
200 .driver = { 200 .driver = {
201 .name = "tilegx-ohci", 201 .name = "tilegx-ohci",
202 .owner = THIS_MODULE,
203 } 202 }
204}; 203};
205 204
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index bb409588d39c..e9a6eec39142 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -368,6 +368,5 @@ static struct platform_driver ohci_hcd_tmio_driver = {
368 .resume = ohci_hcd_tmio_drv_resume, 368 .resume = ohci_hcd_tmio_drv_resume,
369 .driver = { 369 .driver = {
370 .name = "tmio-ohci", 370 .name = "tmio-ohci",
371 .owner = THIS_MODULE,
372 }, 371 },
373}; 372};
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 036924e640f5..ef7efb278b15 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -457,11 +457,11 @@ static void ehci_hub_descriptor(struct oxu_hcd *oxu,
457 memset(&desc->u.hs.DeviceRemovable[0], 0, temp); 457 memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
458 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 458 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
459 459
460 temp = 0x0008; /* per-port overcurrent reporting */ 460 temp = HUB_CHAR_INDV_PORT_OCPM; /* per-port overcurrent reporting */
461 if (HCS_PPC(oxu->hcs_params)) 461 if (HCS_PPC(oxu->hcs_params))
462 temp |= 0x0001; /* per-port power control */ 462 temp |= HUB_CHAR_INDV_PORT_LPSM; /* per-port power control */
463 else 463 else
464 temp |= 0x0002; /* no power switching */ 464 temp |= HUB_CHAR_NO_LPSM; /* no power switching */
465 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp); 465 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
466} 466}
467 467
@@ -2598,9 +2598,7 @@ static int oxu_hcd_init(struct usb_hcd *hcd)
2598 2598
2599 spin_lock_init(&oxu->lock); 2599 spin_lock_init(&oxu->lock);
2600 2600
2601 init_timer(&oxu->watchdog); 2601 setup_timer(&oxu->watchdog, oxu_watchdog, (unsigned long)oxu);
2602 oxu->watchdog.function = oxu_watchdog;
2603 oxu->watchdog.data = (unsigned long) oxu;
2604 2602
2605 /* 2603 /*
2606 * hw default: 1K periodic list heads, one per frame. 2604 * hw default: 1K periodic list heads, one per frame.
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index ce636466edb7..f9400564cb72 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -603,9 +603,9 @@ static void quirk_usb_handoff_ohci(struct pci_dev *pdev)
603 msleep(10); 603 msleep(10);
604 } 604 }
605 if (wait_time <= 0) 605 if (wait_time <= 0)
606 dev_warn(&pdev->dev, "OHCI: BIOS handoff failed" 606 dev_warn(&pdev->dev,
607 " (BIOS bug?) %08x\n", 607 "OHCI: BIOS handoff failed (BIOS bug?) %08x\n",
608 readl(base + OHCI_CONTROL)); 608 readl(base + OHCI_CONTROL));
609 } 609 }
610#endif 610#endif
611 611
@@ -733,8 +733,9 @@ static void ehci_bios_handoff(struct pci_dev *pdev,
733 * and hope nothing goes too wrong 733 * and hope nothing goes too wrong
734 */ 734 */
735 if (try_handoff) 735 if (try_handoff)
736 dev_warn(&pdev->dev, "EHCI: BIOS handoff failed" 736 dev_warn(&pdev->dev,
737 " (BIOS bug?) %08x\n", cap); 737 "EHCI: BIOS handoff failed (BIOS bug?) %08x\n",
738 cap);
738 pci_write_config_byte(pdev, offset + 2, 0); 739 pci_write_config_byte(pdev, offset + 2, 0);
739 } 740 }
740 741
@@ -781,8 +782,9 @@ static void quirk_usb_disable_ehci(struct pci_dev *pdev)
781 case 0: /* Illegal reserved cap, set cap=0 so we exit */ 782 case 0: /* Illegal reserved cap, set cap=0 so we exit */
782 cap = 0; /* then fallthrough... */ 783 cap = 0; /* then fallthrough... */
783 default: 784 default:
784 dev_warn(&pdev->dev, "EHCI: unrecognized capability " 785 dev_warn(&pdev->dev,
785 "%02x\n", cap & 0xff); 786 "EHCI: unrecognized capability %02x\n",
787 cap & 0xff);
786 } 788 }
787 offset = (cap >> 8) & 0xff; 789 offset = (cap >> 8) & 0xff;
788 } 790 }
@@ -893,8 +895,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
893 */ 895 */
894 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) { 896 if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) {
895 dev_warn(&xhci_pdev->dev, 897 dev_warn(&xhci_pdev->dev,
896 "CONFIG_USB_XHCI_HCD is turned off, " 898 "CONFIG_USB_XHCI_HCD is turned off, defaulting to EHCI.\n");
897 "defaulting to EHCI.\n");
898 dev_warn(&xhci_pdev->dev, 899 dev_warn(&xhci_pdev->dev,
899 "USB 3.0 devices will work at USB 2.0 speeds.\n"); 900 "USB 3.0 devices will work at USB 2.0 speeds.\n");
900 usb_disable_xhci_ports(xhci_pdev); 901 usb_disable_xhci_ports(xhci_pdev);
@@ -919,8 +920,9 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
919 920
920 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, 921 pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN,
921 &ports_available); 922 &ports_available);
922 dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled " 923 dev_dbg(&xhci_pdev->dev,
923 "under xHCI: 0x%x\n", ports_available); 924 "USB 3.0 ports that are now enabled under xHCI: 0x%x\n",
925 ports_available);
924 926
925 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register 927 /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register
926 * Indicate the USB 2.0 ports to be controlled by the xHCI host. 928 * Indicate the USB 2.0 ports to be controlled by the xHCI host.
@@ -941,8 +943,9 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev)
941 943
942 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, 944 pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR,
943 &ports_available); 945 &ports_available);
944 dev_dbg(&xhci_pdev->dev, "USB 2.0 ports that are now switched over " 946 dev_dbg(&xhci_pdev->dev,
945 "to xHCI: 0x%x\n", ports_available); 947 "USB 2.0 ports that are now switched over to xHCI: 0x%x\n",
948 ports_available);
946} 949}
947EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports); 950EXPORT_SYMBOL_GPL(usb_enable_intel_xhci_ports);
948 951
@@ -1010,8 +1013,9 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
1010 1013
1011 /* Assume a buggy BIOS and take HC ownership anyway */ 1014 /* Assume a buggy BIOS and take HC ownership anyway */
1012 if (timeout) { 1015 if (timeout) {
1013 dev_warn(&pdev->dev, "xHCI BIOS handoff failed" 1016 dev_warn(&pdev->dev,
1014 " (BIOS bug ?) %08x\n", val); 1017 "xHCI BIOS handoff failed (BIOS bug ?) %08x\n",
1018 val);
1015 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset); 1019 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
1016 } 1020 }
1017 } 1021 }
@@ -1039,8 +1043,8 @@ hc_init:
1039 if (timeout) { 1043 if (timeout) {
1040 val = readl(op_reg_base + XHCI_STS_OFFSET); 1044 val = readl(op_reg_base + XHCI_STS_OFFSET);
1041 dev_warn(&pdev->dev, 1045 dev_warn(&pdev->dev,
1042 "xHCI HW not ready after 5 sec (HC bug?) " 1046 "xHCI HW not ready after 5 sec (HC bug?) status = 0x%x\n",
1043 "status = 0x%x\n", val); 1047 val);
1044 } 1048 }
1045 1049
1046 /* Send the halt and disable interrupts command */ 1050 /* Send the halt and disable interrupts command */
@@ -1054,8 +1058,8 @@ hc_init:
1054 if (timeout) { 1058 if (timeout) {
1055 val = readl(op_reg_base + XHCI_STS_OFFSET); 1059 val = readl(op_reg_base + XHCI_STS_OFFSET);
1056 dev_warn(&pdev->dev, 1060 dev_warn(&pdev->dev,
1057 "xHCI HW did not halt within %d usec " 1061 "xHCI HW did not halt within %d usec status = 0x%x\n",
1058 "status = 0x%x\n", XHCI_MAX_HALT_USEC, val); 1062 XHCI_MAX_HALT_USEC, val);
1059 } 1063 }
1060 1064
1061 iounmap(base); 1065 iounmap(base);
@@ -1075,8 +1079,8 @@ static void quirk_usb_early_handoff(struct pci_dev *pdev)
1075 return; 1079 return;
1076 1080
1077 if (pci_enable_device(pdev) < 0) { 1081 if (pci_enable_device(pdev) < 0) {
1078 dev_warn(&pdev->dev, "Can't enable PCI device, " 1082 dev_warn(&pdev->dev,
1079 "BIOS handoff failed.\n"); 1083 "Can't enable PCI device, BIOS handoff failed.\n");
1080 return; 1084 return;
1081 } 1085 }
1082 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI) 1086 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index c4bcfaedeec9..bdc82fea0a1f 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2141,7 +2141,8 @@ static void r8a66597_hub_descriptor(struct r8a66597 *r8a66597,
2141 desc->bNbrPorts = r8a66597->max_root_hub; 2141 desc->bNbrPorts = r8a66597->max_root_hub;
2142 desc->bDescLength = 9; 2142 desc->bDescLength = 9;
2143 desc->bPwrOn2PwrGood = 0; 2143 desc->bPwrOn2PwrGood = 0;
2144 desc->wHubCharacteristics = cpu_to_le16(0x0011); 2144 desc->wHubCharacteristics =
2145 cpu_to_le16(HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_NO_OCPM);
2145 desc->u.hs.DeviceRemovable[0] = 2146 desc->u.hs.DeviceRemovable[0] =
2146 ((1 << r8a66597->max_root_hub) - 1) << 1; 2147 ((1 << r8a66597->max_root_hub) - 1) << 1;
2147 desc->u.hs.DeviceRemovable[1] = ~0; 2148 desc->u.hs.DeviceRemovable[1] = ~0;
@@ -2483,9 +2484,8 @@ static int r8a66597_probe(struct platform_device *pdev)
2483 r8a66597->max_root_hub = 2; 2484 r8a66597->max_root_hub = 2;
2484 2485
2485 spin_lock_init(&r8a66597->lock); 2486 spin_lock_init(&r8a66597->lock);
2486 init_timer(&r8a66597->rh_timer); 2487 setup_timer(&r8a66597->rh_timer, r8a66597_timer,
2487 r8a66597->rh_timer.function = r8a66597_timer; 2488 (unsigned long)r8a66597);
2488 r8a66597->rh_timer.data = (unsigned long)r8a66597;
2489 r8a66597->reg = reg; 2489 r8a66597->reg = reg;
2490 2490
2491 /* make sure no interrupts are pending */ 2491 /* make sure no interrupts are pending */
@@ -2496,9 +2496,8 @@ static int r8a66597_probe(struct platform_device *pdev)
2496 2496
2497 for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) { 2497 for (i = 0; i < R8A66597_MAX_NUM_PIPE; i++) {
2498 INIT_LIST_HEAD(&r8a66597->pipe_queue[i]); 2498 INIT_LIST_HEAD(&r8a66597->pipe_queue[i]);
2499 init_timer(&r8a66597->td_timer[i]); 2499 setup_timer(&r8a66597->td_timer[i], r8a66597_td_timer,
2500 r8a66597->td_timer[i].function = r8a66597_td_timer; 2500 (unsigned long)r8a66597);
2501 r8a66597->td_timer[i].data = (unsigned long)r8a66597;
2502 setup_timer(&r8a66597->interval_timer[i], 2501 setup_timer(&r8a66597->interval_timer[i],
2503 r8a66597_interval_timer, 2502 r8a66597_interval_timer,
2504 (unsigned long)r8a66597); 2503 (unsigned long)r8a66597);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 25fb1da8d3d7..4f4ba1ea9e9b 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1103,12 +1103,12 @@ sl811h_hub_descriptor (
1103 desc->bPwrOn2PwrGood = sl811->board->potpg; 1103 desc->bPwrOn2PwrGood = sl811->board->potpg;
1104 if (!desc->bPwrOn2PwrGood) 1104 if (!desc->bPwrOn2PwrGood)
1105 desc->bPwrOn2PwrGood = 10; 1105 desc->bPwrOn2PwrGood = 10;
1106 temp = 0x0001; 1106 temp = HUB_CHAR_INDV_PORT_LPSM;
1107 } else 1107 } else
1108 temp = 0x0002; 1108 temp = HUB_CHAR_NO_LPSM;
1109 1109
1110 /* no overcurrent errors detection/handling */ 1110 /* no overcurrent errors detection/handling */
1111 temp |= 0x0010; 1111 temp |= HUB_CHAR_NO_OCPM;
1112 1112
1113 desc->wHubCharacteristics = cpu_to_le16(temp); 1113 desc->wHubCharacteristics = cpu_to_le16(temp);
1114 1114
@@ -1691,9 +1691,7 @@ sl811h_probe(struct platform_device *dev)
1691 spin_lock_init(&sl811->lock); 1691 spin_lock_init(&sl811->lock);
1692 INIT_LIST_HEAD(&sl811->async); 1692 INIT_LIST_HEAD(&sl811->async);
1693 sl811->board = dev_get_platdata(&dev->dev); 1693 sl811->board = dev_get_platdata(&dev->dev);
1694 init_timer(&sl811->timer); 1694 setup_timer(&sl811->timer, sl811h_timer, (unsigned long)sl811);
1695 sl811->timer.function = sl811h_timer;
1696 sl811->timer.data = (unsigned long) sl811;
1697 sl811->addr_reg = addr_reg; 1695 sl811->addr_reg = addr_reg;
1698 sl811->data_reg = data_reg; 1696 sl811->data_reg = data_reg;
1699 1697
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 2894e54e5b9c..ad97e8a1ad1c 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -2590,15 +2590,15 @@ static int u132_roothub_descriptor(struct u132 *u132,
2590 desc->bNbrPorts = u132->num_ports; 2590 desc->bNbrPorts = u132->num_ports;
2591 temp = 1 + (u132->num_ports / 8); 2591 temp = 1 + (u132->num_ports / 8);
2592 desc->bDescLength = 7 + 2 * temp; 2592 desc->bDescLength = 7 + 2 * temp;
2593 temp = 0; 2593 temp = HUB_CHAR_COMMON_LPSM | HUB_CHAR_COMMON_OCPM;
2594 if (rh_a & RH_A_NPS) 2594 if (rh_a & RH_A_NPS)
2595 temp |= 0x0002; 2595 temp |= HUB_CHAR_NO_LPSM;
2596 if (rh_a & RH_A_PSM) 2596 if (rh_a & RH_A_PSM)
2597 temp |= 0x0001; 2597 temp |= HUB_CHAR_INDV_PORT_LPSM;
2598 if (rh_a & RH_A_NOCP) 2598 if (rh_a & RH_A_NOCP)
2599 temp |= 0x0010; 2599 temp |= HUB_CHAR_NO_OCPM;
2600 else if (rh_a & RH_A_OCPM) 2600 else if (rh_a & RH_A_OCPM)
2601 temp |= 0x0008; 2601 temp |= HUB_CHAR_INDV_PORT_OCPM;
2602 desc->wHubCharacteristics = cpu_to_le16(temp); 2602 desc->wHubCharacteristics = cpu_to_le16(temp);
2603 retval = u132_read_pcimem(u132, roothub.b, &rh_b); 2603 retval = u132_read_pcimem(u132, roothub.b, &rh_b);
2604 if (retval) 2604 if (retval)
diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
index 05f57ffdf9ab..0342991c9507 100644
--- a/drivers/usb/host/uhci-grlib.c
+++ b/drivers/usb/host/uhci-grlib.c
@@ -188,7 +188,6 @@ static struct platform_driver uhci_grlib_driver = {
188 .shutdown = uhci_hcd_grlib_shutdown, 188 .shutdown = uhci_hcd_grlib_shutdown,
189 .driver = { 189 .driver = {
190 .name = "grlib-uhci", 190 .name = "grlib-uhci",
191 .owner = THIS_MODULE,
192 .of_match_table = uhci_hcd_grlib_of_match, 191 .of_match_table = uhci_hcd_grlib_of_match,
193 }, 192 },
194}; 193};
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index 93e17b12fb33..19ba5eafb31e 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -17,8 +17,9 @@ static const __u8 root_hub_hub_des[] =
17 0x09, /* __u8 bLength; */ 17 0x09, /* __u8 bLength; */
18 0x29, /* __u8 bDescriptorType; Hub-descriptor */ 18 0x29, /* __u8 bDescriptorType; Hub-descriptor */
19 0x02, /* __u8 bNbrPorts; */ 19 0x02, /* __u8 bNbrPorts; */
20 0x0a, /* __u16 wHubCharacteristics; */ 20 HUB_CHAR_NO_LPSM | /* __u16 wHubCharacteristics; */
21 0x00, /* (per-port OC, no power switching) */ 21 HUB_CHAR_INDV_PORT_OCPM, /* (per-port OC, no power switching) */
22 0x00,
22 0x01, /* __u8 bPwrOn2pwrGood; 2ms */ 23 0x01, /* __u8 bPwrOn2pwrGood; 2ms */
23 0x00, /* __u8 bHubContrCurrent; 0 mA */ 24 0x00, /* __u8 bHubContrCurrent; 0 mA */
24 0x00, /* __u8 DeviceRemovable; *** 7 Ports max */ 25 0x00, /* __u8 DeviceRemovable; *** 7 Ports max */
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index cf8f46003f62..3a3e3eeba291 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -147,7 +147,6 @@ static struct platform_driver uhci_platform_driver = {
147 .shutdown = uhci_hcd_platform_shutdown, 147 .shutdown = uhci_hcd_platform_shutdown,
148 .driver = { 148 .driver = {
149 .name = "platform-uhci", 149 .name = "platform-uhci",
150 .owner = THIS_MODULE,
151 .of_match_table = platform_uhci_ids, 150 .of_match_table = platform_uhci_ids,
152 }, 151 },
153}; 152};
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index bb89175ca6e5..745717ec9c89 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -552,7 +552,7 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci,
552 552
553 if (ctx->type == XHCI_CTX_TYPE_INPUT) { 553 if (ctx->type == XHCI_CTX_TYPE_INPUT) {
554 struct xhci_input_control_ctx *ctrl_ctx = 554 struct xhci_input_control_ctx *ctrl_ctx =
555 xhci_get_input_control_ctx(xhci, ctx); 555 xhci_get_input_control_ctx(ctx);
556 if (!ctrl_ctx) { 556 if (!ctrl_ctx) {
557 xhci_warn(xhci, "Could not get input context, bad type.\n"); 557 xhci_warn(xhci, "Could not get input context, bad type.\n");
558 return; 558 return;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 5cb3d7a10017..f8336408ef07 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -535,7 +535,7 @@ static void xhci_free_container_ctx(struct xhci_hcd *xhci,
535 kfree(ctx); 535 kfree(ctx);
536} 536}
537 537
538struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, 538struct xhci_input_control_ctx *xhci_get_input_control_ctx(
539 struct xhci_container_ctx *ctx) 539 struct xhci_container_ctx *ctx)
540{ 540{
541 if (ctx->type != XHCI_CTX_TYPE_INPUT) 541 if (ctx->type != XHCI_CTX_TYPE_INPUT)
@@ -784,8 +784,7 @@ void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
784 * Reinstalls the "normal" endpoint ring (at its previous dequeue mark, 784 * Reinstalls the "normal" endpoint ring (at its previous dequeue mark,
785 * not at the beginning of the ring). 785 * not at the beginning of the ring).
786 */ 786 */
787void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, 787void xhci_setup_no_streams_ep_input_ctx(struct xhci_ep_ctx *ep_ctx,
788 struct xhci_ep_ctx *ep_ctx,
789 struct xhci_virt_ep *ep) 788 struct xhci_virt_ep *ep)
790{ 789{
791 dma_addr_t addr; 790 dma_addr_t addr;
@@ -833,9 +832,8 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
833static void xhci_init_endpoint_timer(struct xhci_hcd *xhci, 832static void xhci_init_endpoint_timer(struct xhci_hcd *xhci,
834 struct xhci_virt_ep *ep) 833 struct xhci_virt_ep *ep)
835{ 834{
836 init_timer(&ep->stop_cmd_timer); 835 setup_timer(&ep->stop_cmd_timer, xhci_stop_endpoint_command_watchdog,
837 ep->stop_cmd_timer.data = (unsigned long) ep; 836 (unsigned long)ep);
838 ep->stop_cmd_timer.function = xhci_stop_endpoint_command_watchdog;
839 ep->xhci = xhci; 837 ep->xhci = xhci;
840} 838}
841 839
@@ -1342,8 +1340,7 @@ static u32 xhci_get_endpoint_mult(struct usb_device *udev,
1342 return ep->ss_ep_comp.bmAttributes; 1340 return ep->ss_ep_comp.bmAttributes;
1343} 1341}
1344 1342
1345static u32 xhci_get_endpoint_type(struct usb_device *udev, 1343static u32 xhci_get_endpoint_type(struct usb_host_endpoint *ep)
1346 struct usb_host_endpoint *ep)
1347{ 1344{
1348 int in; 1345 int in;
1349 u32 type; 1346 u32 type;
@@ -1376,8 +1373,7 @@ static u32 xhci_get_endpoint_type(struct usb_device *udev,
1376 * Basically, this is the maxpacket size, multiplied by the burst size 1373 * Basically, this is the maxpacket size, multiplied by the burst size
1377 * and mult size. 1374 * and mult size.
1378 */ 1375 */
1379static u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci, 1376static u32 xhci_get_max_esit_payload(struct usb_device *udev,
1380 struct usb_device *udev,
1381 struct usb_host_endpoint *ep) 1377 struct usb_host_endpoint *ep)
1382{ 1378{
1383 int max_burst; 1379 int max_burst;
@@ -1418,7 +1414,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1418 ep_index = xhci_get_endpoint_index(&ep->desc); 1414 ep_index = xhci_get_endpoint_index(&ep->desc);
1419 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 1415 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
1420 1416
1421 endpoint_type = xhci_get_endpoint_type(udev, ep); 1417 endpoint_type = xhci_get_endpoint_type(ep);
1422 if (!endpoint_type) 1418 if (!endpoint_type)
1423 return -EINVAL; 1419 return -EINVAL;
1424 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type); 1420 ep_ctx->ep_info2 = cpu_to_le32(endpoint_type);
@@ -1484,7 +1480,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1484 } 1480 }
1485 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) | 1481 ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet) |
1486 MAX_BURST(max_burst)); 1482 MAX_BURST(max_burst));
1487 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep); 1483 max_esit_payload = xhci_get_max_esit_payload(udev, ep);
1488 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload)); 1484 ep_ctx->tx_info = cpu_to_le32(MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload));
1489 1485
1490 /* 1486 /*
@@ -1773,7 +1769,7 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1773 return command; 1769 return command;
1774} 1770}
1775 1771
1776void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv) 1772void xhci_urb_free_priv(struct urb_priv *urb_priv)
1777{ 1773{
1778 if (urb_priv) { 1774 if (urb_priv) {
1779 kfree(urb_priv->td[0]); 1775 kfree(urb_priv->td[0]);
@@ -1926,7 +1922,7 @@ static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
1926} 1922}
1927 1923
1928/* TRB math checks for xhci_trb_in_td(), using the command and event rings. */ 1924/* TRB math checks for xhci_trb_in_td(), using the command and event rings. */
1929static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci, gfp_t mem_flags) 1925static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci)
1930{ 1926{
1931 struct { 1927 struct {
1932 dma_addr_t input_dma; 1928 dma_addr_t input_dma;
@@ -2452,7 +2448,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2452 flags); 2448 flags);
2453 if (!xhci->event_ring) 2449 if (!xhci->event_ring)
2454 goto fail; 2450 goto fail;
2455 if (xhci_check_trb_in_td_math(xhci, flags) < 0) 2451 if (xhci_check_trb_in_td_math(xhci) < 0)
2456 goto fail; 2452 goto fail;
2457 2453
2458 xhci->erst.entries = dma_alloc_coherent(dev, 2454 xhci->erst.entries = dma_alloc_coherent(dev,
@@ -2509,9 +2505,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2509 xhci_print_ir_set(xhci, 0); 2505 xhci_print_ir_set(xhci, 0);
2510 2506
2511 /* init command timeout timer */ 2507 /* init command timeout timer */
2512 init_timer(&xhci->cmd_timer); 2508 setup_timer(&xhci->cmd_timer, xhci_handle_command_timeout,
2513 xhci->cmd_timer.data = (unsigned long) xhci; 2509 (unsigned long)xhci);
2514 xhci->cmd_timer.function = xhci_handle_command_timeout;
2515 2510
2516 /* 2511 /*
2517 * XXX: Might need to set the Interrupter Moderation Register to 2512 * XXX: Might need to set the Interrupter Moderation Register to
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index e692e769c50c..88da8d629820 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -299,7 +299,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
299 * seconds), then it should assume that the there are 299 * seconds), then it should assume that the there are
300 * larger problems with the xHC and assert HCRST. 300 * larger problems with the xHC and assert HCRST.
301 */ 301 */
302 ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring, 302 ret = xhci_handshake(&xhci->op_regs->cmd_ring,
303 CMD_RING_RUNNING, 0, 5 * 1000 * 1000); 303 CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
304 if (ret < 0) { 304 if (ret < 0) {
305 xhci_err(xhci, "Stopped the command ring failed, " 305 xhci_err(xhci, "Stopped the command ring failed, "
@@ -609,7 +609,7 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
609 609
610 spin_unlock(&xhci->lock); 610 spin_unlock(&xhci->lock);
611 usb_hcd_giveback_urb(hcd, urb, status); 611 usb_hcd_giveback_urb(hcd, urb, status);
612 xhci_urb_free_priv(xhci, urb_priv); 612 xhci_urb_free_priv(urb_priv);
613 spin_lock(&xhci->lock); 613 spin_lock(&xhci->lock);
614 } 614 }
615} 615}
@@ -1110,7 +1110,7 @@ static void xhci_handle_cmd_config_ep(struct xhci_hcd *xhci, int slot_id,
1110 * is not waiting on the configure endpoint command. 1110 * is not waiting on the configure endpoint command.
1111 */ 1111 */
1112 virt_dev = xhci->devs[slot_id]; 1112 virt_dev = xhci->devs[slot_id];
1113 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 1113 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
1114 if (!ctrl_ctx) { 1114 if (!ctrl_ctx) {
1115 xhci_warn(xhci, "Could not get input context, bad type.\n"); 1115 xhci_warn(xhci, "Could not get input context, bad type.\n");
1116 return; 1116 return;
@@ -2354,8 +2354,8 @@ static int handle_tx_event(struct xhci_hcd *xhci,
2354 status = 0; 2354 status = 0;
2355 break; 2355 break;
2356 } 2356 }
2357 xhci_warn(xhci, "ERROR Unknown event condition, HC probably " 2357 xhci_warn(xhci, "ERROR Unknown event condition %u, HC probably busted\n",
2358 "busted\n"); 2358 trb_comp_code);
2359 goto cleanup; 2359 goto cleanup;
2360 } 2360 }
2361 2361
@@ -2497,7 +2497,7 @@ cleanup:
2497 urb = td->urb; 2497 urb = td->urb;
2498 urb_priv = urb->hcpriv; 2498 urb_priv = urb->hcpriv;
2499 2499
2500 xhci_urb_free_priv(xhci, urb_priv); 2500 xhci_urb_free_priv(urb_priv);
2501 2501
2502 usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); 2502 usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb);
2503 if ((urb->actual_length != urb->transfer_buffer_length && 2503 if ((urb->actual_length != urb->transfer_buffer_length &&
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index c50d8d202618..ec8ac1674854 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -60,8 +60,7 @@ MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default");
60 * handshake done). There are two failure modes: "usec" have passed (major 60 * handshake done). There are two failure modes: "usec" have passed (major
61 * hardware flakeout), or the register reads as all-ones (hardware removed). 61 * hardware flakeout), or the register reads as all-ones (hardware removed).
62 */ 62 */
63int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, 63int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
64 u32 mask, u32 done, int usec)
65{ 64{
66 u32 result; 65 u32 result;
67 66
@@ -111,7 +110,7 @@ int xhci_halt(struct xhci_hcd *xhci)
111 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC"); 110 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Halt the HC");
112 xhci_quiesce(xhci); 111 xhci_quiesce(xhci);
113 112
114 ret = xhci_handshake(xhci, &xhci->op_regs->status, 113 ret = xhci_handshake(&xhci->op_regs->status,
115 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); 114 STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC);
116 if (!ret) { 115 if (!ret) {
117 xhci->xhc_state |= XHCI_STATE_HALTED; 116 xhci->xhc_state |= XHCI_STATE_HALTED;
@@ -140,7 +139,7 @@ static int xhci_start(struct xhci_hcd *xhci)
140 * Wait for the HCHalted Status bit to be 0 to indicate the host is 139 * Wait for the HCHalted Status bit to be 0 to indicate the host is
141 * running. 140 * running.
142 */ 141 */
143 ret = xhci_handshake(xhci, &xhci->op_regs->status, 142 ret = xhci_handshake(&xhci->op_regs->status,
144 STS_HALT, 0, XHCI_MAX_HALT_USEC); 143 STS_HALT, 0, XHCI_MAX_HALT_USEC);
145 if (ret == -ETIMEDOUT) 144 if (ret == -ETIMEDOUT)
146 xhci_err(xhci, "Host took too long to start, " 145 xhci_err(xhci, "Host took too long to start, "
@@ -175,7 +174,7 @@ int xhci_reset(struct xhci_hcd *xhci)
175 command |= CMD_RESET; 174 command |= CMD_RESET;
176 writel(command, &xhci->op_regs->command); 175 writel(command, &xhci->op_regs->command);
177 176
178 ret = xhci_handshake(xhci, &xhci->op_regs->command, 177 ret = xhci_handshake(&xhci->op_regs->command,
179 CMD_RESET, 0, 10 * 1000 * 1000); 178 CMD_RESET, 0, 10 * 1000 * 1000);
180 if (ret) 179 if (ret)
181 return ret; 180 return ret;
@@ -186,7 +185,7 @@ int xhci_reset(struct xhci_hcd *xhci)
186 * xHCI cannot write to any doorbells or operational registers other 185 * xHCI cannot write to any doorbells or operational registers other
187 * than status until the "Controller Not Ready" flag is cleared. 186 * than status until the "Controller Not Ready" flag is cleared.
188 */ 187 */
189 ret = xhci_handshake(xhci, &xhci->op_regs->status, 188 ret = xhci_handshake(&xhci->op_regs->status,
190 STS_CNR, 0, 10 * 1000 * 1000); 189 STS_CNR, 0, 10 * 1000 * 1000);
191 190
192 for (i = 0; i < 2; ++i) { 191 for (i = 0; i < 2; ++i) {
@@ -473,10 +472,8 @@ static void compliance_mode_recovery(unsigned long arg)
473static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci) 472static void compliance_mode_recovery_timer_init(struct xhci_hcd *xhci)
474{ 473{
475 xhci->port_status_u0 = 0; 474 xhci->port_status_u0 = 0;
476 init_timer(&xhci->comp_mode_recovery_timer); 475 setup_timer(&xhci->comp_mode_recovery_timer,
477 476 compliance_mode_recovery, (unsigned long)xhci);
478 xhci->comp_mode_recovery_timer.data = (unsigned long) xhci;
479 xhci->comp_mode_recovery_timer.function = compliance_mode_recovery;
480 xhci->comp_mode_recovery_timer.expires = jiffies + 477 xhci->comp_mode_recovery_timer.expires = jiffies +
481 msecs_to_jiffies(COMP_MODE_RCVRY_MSECS); 478 msecs_to_jiffies(COMP_MODE_RCVRY_MSECS);
482 479
@@ -929,7 +926,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
929 /* Some chips from Fresco Logic need an extraordinary delay */ 926 /* Some chips from Fresco Logic need an extraordinary delay */
930 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; 927 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1;
931 928
932 if (xhci_handshake(xhci, &xhci->op_regs->status, 929 if (xhci_handshake(&xhci->op_regs->status,
933 STS_HALT, STS_HALT, delay)) { 930 STS_HALT, STS_HALT, delay)) {
934 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); 931 xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
935 spin_unlock_irq(&xhci->lock); 932 spin_unlock_irq(&xhci->lock);
@@ -944,7 +941,7 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
944 command = readl(&xhci->op_regs->command); 941 command = readl(&xhci->op_regs->command);
945 command |= CMD_CSS; 942 command |= CMD_CSS;
946 writel(command, &xhci->op_regs->command); 943 writel(command, &xhci->op_regs->command);
947 if (xhci_handshake(xhci, &xhci->op_regs->status, 944 if (xhci_handshake(&xhci->op_regs->status,
948 STS_SAVE, 0, 10 * 1000)) { 945 STS_SAVE, 0, 10 * 1000)) {
949 xhci_warn(xhci, "WARN: xHC save state timeout\n"); 946 xhci_warn(xhci, "WARN: xHC save state timeout\n");
950 spin_unlock_irq(&xhci->lock); 947 spin_unlock_irq(&xhci->lock);
@@ -1011,7 +1008,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1011 command = readl(&xhci->op_regs->command); 1008 command = readl(&xhci->op_regs->command);
1012 command |= CMD_CRS; 1009 command |= CMD_CRS;
1013 writel(command, &xhci->op_regs->command); 1010 writel(command, &xhci->op_regs->command);
1014 if (xhci_handshake(xhci, &xhci->op_regs->status, 1011 if (xhci_handshake(&xhci->op_regs->status,
1015 STS_RESTORE, 0, 10 * 1000)) { 1012 STS_RESTORE, 0, 10 * 1000)) {
1016 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 1013 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
1017 spin_unlock_irq(&xhci->lock); 1014 spin_unlock_irq(&xhci->lock);
@@ -1082,7 +1079,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1082 command = readl(&xhci->op_regs->command); 1079 command = readl(&xhci->op_regs->command);
1083 command |= CMD_RUN; 1080 command |= CMD_RUN;
1084 writel(command, &xhci->op_regs->command); 1081 writel(command, &xhci->op_regs->command);
1085 xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT, 1082 xhci_handshake(&xhci->op_regs->status, STS_HALT,
1086 0, 250 * 1000); 1083 0, 250 * 1000);
1087 1084
1088 /* step 5: walk topology and initialize portsc, 1085 /* step 5: walk topology and initialize portsc,
@@ -1276,7 +1273,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
1276 return -ENOMEM; 1273 return -ENOMEM;
1277 1274
1278 command->in_ctx = xhci->devs[slot_id]->in_ctx; 1275 command->in_ctx = xhci->devs[slot_id]->in_ctx;
1279 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 1276 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
1280 if (!ctrl_ctx) { 1277 if (!ctrl_ctx) {
1281 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1278 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1282 __func__); 1279 __func__);
@@ -1374,7 +1371,7 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
1374 ret = xhci_check_maxpacket(xhci, slot_id, 1371 ret = xhci_check_maxpacket(xhci, slot_id,
1375 ep_index, urb); 1372 ep_index, urb);
1376 if (ret < 0) { 1373 if (ret < 0) {
1377 xhci_urb_free_priv(xhci, urb_priv); 1374 xhci_urb_free_priv(urb_priv);
1378 urb->hcpriv = NULL; 1375 urb->hcpriv = NULL;
1379 return ret; 1376 return ret;
1380 } 1377 }
@@ -1440,7 +1437,7 @@ dying:
1440 urb->ep->desc.bEndpointAddress, urb); 1437 urb->ep->desc.bEndpointAddress, urb);
1441 ret = -ESHUTDOWN; 1438 ret = -ESHUTDOWN;
1442free_priv: 1439free_priv:
1443 xhci_urb_free_priv(xhci, urb_priv); 1440 xhci_urb_free_priv(urb_priv);
1444 urb->hcpriv = NULL; 1441 urb->hcpriv = NULL;
1445 spin_unlock_irqrestore(&xhci->lock, flags); 1442 spin_unlock_irqrestore(&xhci->lock, flags);
1446 return ret; 1443 return ret;
@@ -1553,7 +1550,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1553 usb_hcd_unlink_urb_from_ep(hcd, urb); 1550 usb_hcd_unlink_urb_from_ep(hcd, urb);
1554 spin_unlock_irqrestore(&xhci->lock, flags); 1551 spin_unlock_irqrestore(&xhci->lock, flags);
1555 usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN); 1552 usb_hcd_giveback_urb(hcd, urb, -ESHUTDOWN);
1556 xhci_urb_free_priv(xhci, urb_priv); 1553 xhci_urb_free_priv(urb_priv);
1557 return ret; 1554 return ret;
1558 } 1555 }
1559 if ((xhci->xhc_state & XHCI_STATE_DYING) || 1556 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
@@ -1660,7 +1657,7 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1660 1657
1661 in_ctx = xhci->devs[udev->slot_id]->in_ctx; 1658 in_ctx = xhci->devs[udev->slot_id]->in_ctx;
1662 out_ctx = xhci->devs[udev->slot_id]->out_ctx; 1659 out_ctx = xhci->devs[udev->slot_id]->out_ctx;
1663 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 1660 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
1664 if (!ctrl_ctx) { 1661 if (!ctrl_ctx) {
1665 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1662 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1666 __func__); 1663 __func__);
@@ -1676,8 +1673,10 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1676 cpu_to_le32(EP_STATE_DISABLED)) || 1673 cpu_to_le32(EP_STATE_DISABLED)) ||
1677 le32_to_cpu(ctrl_ctx->drop_flags) & 1674 le32_to_cpu(ctrl_ctx->drop_flags) &
1678 xhci_get_endpoint_flag(&ep->desc)) { 1675 xhci_get_endpoint_flag(&ep->desc)) {
1679 xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", 1676 /* Do not warn when called after a usb_device_reset */
1680 __func__, ep); 1677 if (xhci->devs[udev->slot_id]->eps[ep_index].ring != NULL)
1678 xhci_warn(xhci, "xHCI %s called with disabled ep %p\n",
1679 __func__, ep);
1681 return 0; 1680 return 0;
1682 } 1681 }
1683 1682
@@ -1714,7 +1713,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1714 struct usb_host_endpoint *ep) 1713 struct usb_host_endpoint *ep)
1715{ 1714{
1716 struct xhci_hcd *xhci; 1715 struct xhci_hcd *xhci;
1717 struct xhci_container_ctx *in_ctx, *out_ctx; 1716 struct xhci_container_ctx *in_ctx;
1718 unsigned int ep_index; 1717 unsigned int ep_index;
1719 struct xhci_input_control_ctx *ctrl_ctx; 1718 struct xhci_input_control_ctx *ctrl_ctx;
1720 u32 added_ctxs; 1719 u32 added_ctxs;
@@ -1745,8 +1744,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1745 1744
1746 virt_dev = xhci->devs[udev->slot_id]; 1745 virt_dev = xhci->devs[udev->slot_id];
1747 in_ctx = virt_dev->in_ctx; 1746 in_ctx = virt_dev->in_ctx;
1748 out_ctx = virt_dev->out_ctx; 1747 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
1749 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
1750 if (!ctrl_ctx) { 1748 if (!ctrl_ctx) {
1751 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1749 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1752 __func__); 1750 __func__);
@@ -1758,8 +1756,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1758 * to add it again without dropping it, reject the addition. 1756 * to add it again without dropping it, reject the addition.
1759 */ 1757 */
1760 if (virt_dev->eps[ep_index].ring && 1758 if (virt_dev->eps[ep_index].ring &&
1761 !(le32_to_cpu(ctrl_ctx->drop_flags) & 1759 !(le32_to_cpu(ctrl_ctx->drop_flags) & added_ctxs)) {
1762 xhci_get_endpoint_flag(&ep->desc))) {
1763 xhci_warn(xhci, "Trying to add endpoint 0x%x " 1760 xhci_warn(xhci, "Trying to add endpoint 0x%x "
1764 "without dropping it.\n", 1761 "without dropping it.\n",
1765 (unsigned int) ep->desc.bEndpointAddress); 1762 (unsigned int) ep->desc.bEndpointAddress);
@@ -1769,8 +1766,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1769 /* If the HCD has already noted the endpoint is enabled, 1766 /* If the HCD has already noted the endpoint is enabled,
1770 * ignore this request. 1767 * ignore this request.
1771 */ 1768 */
1772 if (le32_to_cpu(ctrl_ctx->add_flags) & 1769 if (le32_to_cpu(ctrl_ctx->add_flags) & added_ctxs) {
1773 xhci_get_endpoint_flag(&ep->desc)) {
1774 xhci_warn(xhci, "xHCI %s called with enabled ep %p\n", 1770 xhci_warn(xhci, "xHCI %s called with enabled ep %p\n",
1775 __func__, ep); 1771 __func__, ep);
1776 return 0; 1772 return 0;
@@ -1816,7 +1812,7 @@ static void xhci_zero_in_ctx(struct xhci_hcd *xhci, struct xhci_virt_device *vir
1816 struct xhci_slot_ctx *slot_ctx; 1812 struct xhci_slot_ctx *slot_ctx;
1817 int i; 1813 int i;
1818 1814
1819 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 1815 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
1820 if (!ctrl_ctx) { 1816 if (!ctrl_ctx) {
1821 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 1817 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
1822 __func__); 1818 __func__);
@@ -2542,7 +2538,7 @@ static int xhci_reserve_bandwidth(struct xhci_hcd *xhci,
2542 if (virt_dev->tt_info) 2538 if (virt_dev->tt_info)
2543 old_active_eps = virt_dev->tt_info->active_eps; 2539 old_active_eps = virt_dev->tt_info->active_eps;
2544 2540
2545 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 2541 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
2546 if (!ctrl_ctx) { 2542 if (!ctrl_ctx) {
2547 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2543 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
2548 __func__); 2544 __func__);
@@ -2639,7 +2635,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
2639 spin_lock_irqsave(&xhci->lock, flags); 2635 spin_lock_irqsave(&xhci->lock, flags);
2640 virt_dev = xhci->devs[udev->slot_id]; 2636 virt_dev = xhci->devs[udev->slot_id];
2641 2637
2642 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 2638 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
2643 if (!ctrl_ctx) { 2639 if (!ctrl_ctx) {
2644 spin_unlock_irqrestore(&xhci->lock, flags); 2640 spin_unlock_irqrestore(&xhci->lock, flags);
2645 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2641 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
@@ -2758,7 +2754,7 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2758 command->in_ctx = virt_dev->in_ctx; 2754 command->in_ctx = virt_dev->in_ctx;
2759 2755
2760 /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */ 2756 /* See section 4.6.6 - A0 = 1; A1 = D0 = D1 = 0 */
2761 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 2757 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
2762 if (!ctrl_ctx) { 2758 if (!ctrl_ctx) {
2763 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2759 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
2764 __func__); 2760 __func__);
@@ -2883,7 +2879,7 @@ static void xhci_setup_input_ctx_for_quirk(struct xhci_hcd *xhci,
2883 dma_addr_t addr; 2879 dma_addr_t addr;
2884 2880
2885 in_ctx = xhci->devs[slot_id]->in_ctx; 2881 in_ctx = xhci->devs[slot_id]->in_ctx;
2886 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 2882 ctrl_ctx = xhci_get_input_control_ctx(in_ctx);
2887 if (!ctrl_ctx) { 2883 if (!ctrl_ctx) {
2888 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 2884 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
2889 __func__); 2885 __func__);
@@ -3173,7 +3169,7 @@ int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
3173 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 3169 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
3174 return -ENOMEM; 3170 return -ENOMEM;
3175 } 3171 }
3176 ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx); 3172 ctrl_ctx = xhci_get_input_control_ctx(config_cmd->in_ctx);
3177 if (!ctrl_ctx) { 3173 if (!ctrl_ctx) {
3178 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 3174 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
3179 __func__); 3175 __func__);
@@ -3328,7 +3324,7 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3328 */ 3324 */
3329 ep_index = xhci_get_endpoint_index(&eps[0]->desc); 3325 ep_index = xhci_get_endpoint_index(&eps[0]->desc);
3330 command = vdev->eps[ep_index].stream_info->free_streams_command; 3326 command = vdev->eps[ep_index].stream_info->free_streams_command;
3331 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 3327 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
3332 if (!ctrl_ctx) { 3328 if (!ctrl_ctx) {
3333 spin_unlock_irqrestore(&xhci->lock, flags); 3329 spin_unlock_irqrestore(&xhci->lock, flags);
3334 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 3330 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
@@ -3346,7 +3342,7 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
3346 3342
3347 xhci_endpoint_copy(xhci, command->in_ctx, 3343 xhci_endpoint_copy(xhci, command->in_ctx,
3348 vdev->out_ctx, ep_index); 3344 vdev->out_ctx, ep_index);
3349 xhci_setup_no_streams_ep_input_ctx(xhci, ep_ctx, 3345 xhci_setup_no_streams_ep_input_ctx(ep_ctx,
3350 &vdev->eps[ep_index]); 3346 &vdev->eps[ep_index]);
3351 } 3347 }
3352 xhci_setup_input_ctx_for_config_ep(xhci, command->in_ctx, 3348 xhci_setup_input_ctx_for_config_ep(xhci, command->in_ctx,
@@ -3820,7 +3816,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3820 command->completion = &xhci->addr_dev; 3816 command->completion = &xhci->addr_dev;
3821 3817
3822 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx); 3818 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
3823 ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx); 3819 ctrl_ctx = xhci_get_input_control_ctx(virt_dev->in_ctx);
3824 if (!ctrl_ctx) { 3820 if (!ctrl_ctx) {
3825 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 3821 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
3826 __func__); 3822 __func__);
@@ -4003,7 +3999,7 @@ static int __maybe_unused xhci_change_max_exit_latency(struct xhci_hcd *xhci,
4003 3999
4004 /* Attempt to issue an Evaluate Context command to change the MEL. */ 4000 /* Attempt to issue an Evaluate Context command to change the MEL. */
4005 command = xhci->lpm_command; 4001 command = xhci->lpm_command;
4006 ctrl_ctx = xhci_get_input_control_ctx(xhci, command->in_ctx); 4002 ctrl_ctx = xhci_get_input_control_ctx(command->in_ctx);
4007 if (!ctrl_ctx) { 4003 if (!ctrl_ctx) {
4008 spin_unlock_irqrestore(&xhci->lock, flags); 4004 spin_unlock_irqrestore(&xhci->lock, flags);
4009 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 4005 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
@@ -4741,7 +4737,7 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
4741 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 4737 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
4742 return -ENOMEM; 4738 return -ENOMEM;
4743 } 4739 }
4744 ctrl_ctx = xhci_get_input_control_ctx(xhci, config_cmd->in_ctx); 4740 ctrl_ctx = xhci_get_input_control_ctx(config_cmd->in_ctx);
4745 if (!ctrl_ctx) { 4741 if (!ctrl_ctx) {
4746 xhci_warn(xhci, "%s: Could not get input context, bad type.\n", 4742 xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
4747 __func__); 4743 __func__);
@@ -4910,6 +4906,10 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4910 if (retval) 4906 if (retval)
4911 goto error; 4907 goto error;
4912 xhci_dbg(xhci, "Called HCD init\n"); 4908 xhci_dbg(xhci, "Called HCD init\n");
4909
4910 xhci_info(xhci, "hcc params 0x%08x hci version 0x%x quirks 0x%08x\n",
4911 xhci->hcc_params, xhci->hci_version, xhci->quirks);
4912
4913 return 0; 4913 return 0;
4914error: 4914error:
4915 kfree(xhci); 4915 kfree(xhci);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index cc7c5bb7cbcf..974514762a14 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1605,6 +1605,8 @@ static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci)
1605 dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args) 1605 dev_warn(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1606#define xhci_warn_ratelimited(xhci, fmt, args...) \ 1606#define xhci_warn_ratelimited(xhci, fmt, args...) \
1607 dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args) 1607 dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1608#define xhci_info(xhci, fmt, args...) \
1609 dev_info(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1608 1610
1609/* 1611/*
1610 * Registers should always be accessed with double word or quad word accesses. 1612 * Registers should always be accessed with double word or quad word accesses.
@@ -1712,8 +1714,7 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
1712void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci, 1714void xhci_setup_streams_ep_input_ctx(struct xhci_hcd *xhci,
1713 struct xhci_ep_ctx *ep_ctx, 1715 struct xhci_ep_ctx *ep_ctx,
1714 struct xhci_stream_info *stream_info); 1716 struct xhci_stream_info *stream_info);
1715void xhci_setup_no_streams_ep_input_ctx(struct xhci_hcd *xhci, 1717void xhci_setup_no_streams_ep_input_ctx(struct xhci_ep_ctx *ep_ctx,
1716 struct xhci_ep_ctx *ep_ctx,
1717 struct xhci_virt_ep *ep); 1718 struct xhci_virt_ep *ep);
1718void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci, 1719void xhci_free_device_endpoint_resources(struct xhci_hcd *xhci,
1719 struct xhci_virt_device *virt_dev, bool drop_control_ep); 1720 struct xhci_virt_device *virt_dev, bool drop_control_ep);
@@ -1727,14 +1728,13 @@ struct xhci_ring *xhci_stream_id_to_ring(
1727struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1728struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1728 bool allocate_in_ctx, bool allocate_completion, 1729 bool allocate_in_ctx, bool allocate_completion,
1729 gfp_t mem_flags); 1730 gfp_t mem_flags);
1730void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv); 1731void xhci_urb_free_priv(struct urb_priv *urb_priv);
1731void xhci_free_command(struct xhci_hcd *xhci, 1732void xhci_free_command(struct xhci_hcd *xhci,
1732 struct xhci_command *command); 1733 struct xhci_command *command);
1733 1734
1734/* xHCI host controller glue */ 1735/* xHCI host controller glue */
1735typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); 1736typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
1736int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, 1737int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
1737 u32 mask, u32 done, int usec);
1738void xhci_quiesce(struct xhci_hcd *xhci); 1738void xhci_quiesce(struct xhci_hcd *xhci);
1739int xhci_halt(struct xhci_hcd *xhci); 1739int xhci_halt(struct xhci_hcd *xhci);
1740int xhci_reset(struct xhci_hcd *xhci); 1740int xhci_reset(struct xhci_hcd *xhci);
@@ -1864,7 +1864,7 @@ int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
1864void xhci_ring_device(struct xhci_hcd *xhci, int slot_id); 1864void xhci_ring_device(struct xhci_hcd *xhci, int slot_id);
1865 1865
1866/* xHCI contexts */ 1866/* xHCI contexts */
1867struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); 1867struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_container_ctx *ctx);
1868struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); 1868struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx);
1869struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index); 1869struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index);
1870 1870
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 37b44b04a701..6431d08c8d9d 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -299,9 +299,7 @@ static inline void mts_show_command(struct scsi_cmnd *srb)
299 MTS_DEBUG( "Command %s (%d bytes)\n", what, srb->cmd_len); 299 MTS_DEBUG( "Command %s (%d bytes)\n", what, srb->cmd_len);
300 300
301 out: 301 out:
302 MTS_DEBUG( " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 302 MTS_DEBUG( " %10ph\n", srb->cmnd);
303 srb->cmnd[0], srb->cmnd[1], srb->cmnd[2], srb->cmnd[3], srb->cmnd[4], srb->cmnd[5],
304 srb->cmnd[6], srb->cmnd[7], srb->cmnd[8], srb->cmnd[9]);
305} 303}
306 304
307#else 305#else
diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index 996b2c157d12..eba9b82e2d70 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -1335,9 +1335,7 @@ static int isp1760_run(struct usb_hcd *hcd)
1335 if (retval) 1335 if (retval)
1336 return retval; 1336 return retval;
1337 1337
1338 init_timer(&errata2_timer); 1338 setup_timer(&errata2_timer, errata2_function, (unsigned long)hcd);
1339 errata2_timer.function = errata2_function;
1340 errata2_timer.data = (unsigned long) hcd;
1341 errata2_timer.expires = jiffies + SLOT_CHECK_PERIOD * HZ / 1000; 1339 errata2_timer.expires = jiffies + SLOT_CHECK_PERIOD * HZ / 1000;
1342 add_timer(&errata2_timer); 1340 add_timer(&errata2_timer);
1343 1341
@@ -1774,13 +1772,13 @@ static void isp1760_hub_descriptor(struct isp1760_hcd *priv,
1774 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp); 1772 memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
1775 1773
1776 /* per-port overcurrent reporting */ 1774 /* per-port overcurrent reporting */
1777 temp = 0x0008; 1775 temp = HUB_CHAR_INDV_PORT_OCPM;
1778 if (HCS_PPC(priv->hcs_params)) 1776 if (HCS_PPC(priv->hcs_params))
1779 /* per-port power control */ 1777 /* per-port power control */
1780 temp |= 0x0001; 1778 temp |= HUB_CHAR_INDV_PORT_LPSM;
1781 else 1779 else
1782 /* no power switching */ 1780 /* no power switching */
1783 temp |= 0x0002; 1781 temp |= HUB_CHAR_NO_LPSM;
1784 desc->wHubCharacteristics = cpu_to_le16(temp); 1782 desc->wHubCharacteristics = cpu_to_le16(temp);
1785} 1783}
1786 1784
@@ -2211,6 +2209,9 @@ int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs,
2211 hcd->rsrc_start = mem->start; 2209 hcd->rsrc_start = mem->start;
2212 hcd->rsrc_len = resource_size(mem); 2210 hcd->rsrc_len = resource_size(mem);
2213 2211
2212 /* This driver doesn't support wakeup requests */
2213 hcd->cant_recv_wakeups = 1;
2214
2214 ret = usb_add_hcd(hcd, irq, irqflags); 2215 ret = usb_add_hcd(hcd, irq, irqflags);
2215 if (ret) 2216 if (ret)
2216 goto error; 2217 goto error;
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 40ef40affe83..588d62a73e1a 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -124,12 +124,8 @@ static void async_complete(struct urb *urb)
124 } else if (rq->dr->bRequest == 3) { 124 } else if (rq->dr->bRequest == 3) {
125 memcpy(priv->reg, rq->reg, sizeof(priv->reg)); 125 memcpy(priv->reg, rq->reg, sizeof(priv->reg));
126#if 0 126#if 0
127 dev_dbg(&priv->usbdev->dev, 127 dev_dbg(&priv->usbdev->dev, "async_complete regs %7ph\n",
128 "async_complete regs %02x %02x %02x %02x %02x %02x %02x\n", 128 priv->reg);
129 (unsigned int)priv->reg[0], (unsigned int)priv->reg[1],
130 (unsigned int)priv->reg[2], (unsigned int)priv->reg[3],
131 (unsigned int)priv->reg[4], (unsigned int)priv->reg[5],
132 (unsigned int)priv->reg[6]);
133#endif 129#endif
134 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */ 130 /* if nAck interrupts are enabled and we have an interrupt, call the interrupt procedure */
135 if (rq->reg[2] & rq->reg[1] & 0x10 && pp) 131 if (rq->reg[2] & rq->reg[1] & 0x10 && pp)
@@ -742,9 +738,7 @@ static int uss720_probe(struct usb_interface *intf,
742 set_1284_register(pp, 2, 0x0c, GFP_KERNEL); 738 set_1284_register(pp, 2, 0x0c, GFP_KERNEL);
743 /* debugging */ 739 /* debugging */
744 get_1284_register(pp, 0, &reg, GFP_KERNEL); 740 get_1284_register(pp, 0, &reg, GFP_KERNEL);
745 dev_dbg(&intf->dev, "reg: %02x %02x %02x %02x %02x %02x %02x\n", 741 dev_dbg(&intf->dev, "reg: %7ph\n", priv->reg);
746 priv->reg[0], priv->reg[1], priv->reg[2], priv->reg[3],
747 priv->reg[4], priv->reg[5], priv->reg[6]);
748 742
749 endpoint = &interface->endpoint[2]; 743 endpoint = &interface->endpoint[2];
750 dev_dbg(&intf->dev, "epaddr %d interval %d\n", 744 dev_dbg(&intf->dev, "epaddr %d interval %d\n",
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index ccfdfb24b240..2f9735b35338 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -34,7 +34,7 @@ static struct usb_phy *__usb_find_phy(struct list_head *list,
34 return phy; 34 return phy;
35 } 35 }
36 36
37 return ERR_PTR(-EPROBE_DEFER); 37 return ERR_PTR(-ENODEV);
38} 38}
39 39
40static struct usb_phy *__usb_find_phy_dev(struct device *dev, 40static struct usb_phy *__usb_find_phy_dev(struct device *dev,
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index f4c56fc1a9f6..f40c856ff758 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -56,6 +56,7 @@ static const struct usb_device_id id_table[] = {
56 { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */ 56 { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */
57 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ 57 { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
58 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */ 58 { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
59 { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */
59 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */ 60 { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
60 { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */ 61 { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
61 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */ 62 { USB_DEVICE(0x0FCF, 0x1003) }, /* Dynastream ANT development board */
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 220b4be89641..e4473a9109cf 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1309,35 +1309,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1309 const unsigned char *current_position = data; 1309 const unsigned char *current_position = data;
1310 unsigned char *data1; 1310 unsigned char *data1;
1311 1311
1312#ifdef NOTMOS7840
1313 Data = 0x00;
1314 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
1315 mos7840_port->shadowLCR = Data;
1316 dev_dbg(&port->dev, "%s: LINE_CONTROL_REGISTER is %x\n", __func__, Data);
1317 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1318
1319 /* Data = 0x03; */
1320 /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
1321 /* mos7840_port->shadowLCR=Data;//Need to add later */
1322
1323 Data |= SERIAL_LCR_DLAB; /* data latch enable in LCR 0x80 */
1324 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1325
1326 /* Data = 0x0c; */
1327 /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
1328 Data = 0x00;
1329 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
1330 dev_dbg(&port->dev, "%s: DLL value is %x\n", __func__, Data);
1331
1332 Data = 0x0;
1333 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
1334 dev_dbg(&port->dev, "%s: DLM value is %x\n", __func__, Data);
1335
1336 Data = Data & ~SERIAL_LCR_DLAB;
1337 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1338 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1339#endif
1340
1341 if (mos7840_port_paranoia_check(port, __func__)) 1312 if (mos7840_port_paranoia_check(port, __func__))
1342 return -1; 1313 return -1;
1343 1314
@@ -1614,37 +1585,6 @@ static int mos7840_calc_baud_rate_divisor(struct usb_serial_port *port,
1614 *clk_sel_val = 0x70; 1585 *clk_sel_val = 0x70;
1615 } 1586 }
1616 return 0; 1587 return 0;
1617
1618#ifdef NOTMCS7840
1619
1620 for (i = 0; i < ARRAY_SIZE(mos7840_divisor_table); i++) {
1621 if (mos7840_divisor_table[i].BaudRate == baudrate) {
1622 *divisor = mos7840_divisor_table[i].Divisor;
1623 return 0;
1624 }
1625 }
1626
1627 /* After trying for all the standard baud rates *
1628 * Try calculating the divisor for this baud rate */
1629
1630 if (baudrate > 75 && baudrate < 230400) {
1631 /* get the divisor */
1632 custom = (__u16) (230400L / baudrate);
1633
1634 /* Check for round off */
1635 round1 = (__u16) (2304000L / baudrate);
1636 round = (__u16) (round1 - (custom * 10));
1637 if (round > 4)
1638 custom++;
1639 *divisor = custom;
1640
1641 dev_dbg(&port->dev, " Baud %d = %d\n", baudrate, custom);
1642 return 0;
1643 }
1644
1645 dev_dbg(&port->dev, "%s", " Baud calculation Failed...\n");
1646 return -1;
1647#endif
1648} 1588}
1649 1589
1650/***************************************************************************** 1590/*****************************************************************************
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index efdcee15b520..f0c0c53359ad 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -507,18 +507,10 @@ static void option_instat_callback(struct urb *urb);
507#define VIATELECOM_VENDOR_ID 0x15eb 507#define VIATELECOM_VENDOR_ID 0x15eb
508#define VIATELECOM_PRODUCT_CDS7 0x0001 508#define VIATELECOM_PRODUCT_CDS7 0x0001
509 509
510/* some devices interfaces need special handling due to a number of reasons */
511enum option_blacklist_reason {
512 OPTION_BLACKLIST_NONE = 0,
513 OPTION_BLACKLIST_SENDSETUP = 1,
514 OPTION_BLACKLIST_RESERVED_IF = 2
515};
516
517#define MAX_BL_NUM 11
518struct option_blacklist_info { 510struct option_blacklist_info {
519 /* bitfield of interface numbers for OPTION_BLACKLIST_SENDSETUP */ 511 /* bitmask of interface numbers blacklisted for send_setup */
520 const unsigned long sendsetup; 512 const unsigned long sendsetup;
521 /* bitfield of interface numbers for OPTION_BLACKLIST_RESERVED_IF */ 513 /* bitmask of interface numbers that are reserved */
522 const unsigned long reserved; 514 const unsigned long reserved;
523}; 515};
524 516
@@ -1822,36 +1814,13 @@ struct option_private {
1822 1814
1823module_usb_serial_driver(serial_drivers, option_ids); 1815module_usb_serial_driver(serial_drivers, option_ids);
1824 1816
1825static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason,
1826 const struct option_blacklist_info *blacklist)
1827{
1828 unsigned long num;
1829 const unsigned long *intf_list;
1830
1831 if (blacklist) {
1832 if (reason == OPTION_BLACKLIST_SENDSETUP)
1833 intf_list = &blacklist->sendsetup;
1834 else if (reason == OPTION_BLACKLIST_RESERVED_IF)
1835 intf_list = &blacklist->reserved;
1836 else {
1837 BUG_ON(reason);
1838 return false;
1839 }
1840
1841 for_each_set_bit(num, intf_list, MAX_BL_NUM + 1) {
1842 if (num == ifnum)
1843 return true;
1844 }
1845 }
1846 return false;
1847}
1848
1849static int option_probe(struct usb_serial *serial, 1817static int option_probe(struct usb_serial *serial,
1850 const struct usb_device_id *id) 1818 const struct usb_device_id *id)
1851{ 1819{
1852 struct usb_interface_descriptor *iface_desc = 1820 struct usb_interface_descriptor *iface_desc =
1853 &serial->interface->cur_altsetting->desc; 1821 &serial->interface->cur_altsetting->desc;
1854 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; 1822 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
1823 const struct option_blacklist_info *blacklist;
1855 1824
1856 /* Never bind to the CD-Rom emulation interface */ 1825 /* Never bind to the CD-Rom emulation interface */
1857 if (iface_desc->bInterfaceClass == 0x08) 1826 if (iface_desc->bInterfaceClass == 0x08)
@@ -1862,10 +1831,9 @@ static int option_probe(struct usb_serial *serial,
1862 * the same class/subclass/protocol as the serial interfaces. Look at 1831 * the same class/subclass/protocol as the serial interfaces. Look at
1863 * the Windows driver .INF files for reserved interface numbers. 1832 * the Windows driver .INF files for reserved interface numbers.
1864 */ 1833 */
1865 if (is_blacklisted( 1834 blacklist = (void *)id->driver_info;
1866 iface_desc->bInterfaceNumber, 1835 if (blacklist && test_bit(iface_desc->bInterfaceNumber,
1867 OPTION_BLACKLIST_RESERVED_IF, 1836 &blacklist->reserved))
1868 (const struct option_blacklist_info *) id->driver_info))
1869 return -ENODEV; 1837 return -ENODEV;
1870 /* 1838 /*
1871 * Don't bind network interface on Samsung GT-B3730, it is handled by 1839 * Don't bind network interface on Samsung GT-B3730, it is handled by
@@ -1876,8 +1844,8 @@ static int option_probe(struct usb_serial *serial,
1876 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) 1844 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
1877 return -ENODEV; 1845 return -ENODEV;
1878 1846
1879 /* Store device id so we can use it during attach. */ 1847 /* Store the blacklist info so we can use it during attach. */
1880 usb_set_serial_data(serial, (void *)id); 1848 usb_set_serial_data(serial, (void *)blacklist);
1881 1849
1882 return 0; 1850 return 0;
1883} 1851}
@@ -1885,7 +1853,7 @@ static int option_probe(struct usb_serial *serial,
1885static int option_attach(struct usb_serial *serial) 1853static int option_attach(struct usb_serial *serial)
1886{ 1854{
1887 struct usb_interface_descriptor *iface_desc; 1855 struct usb_interface_descriptor *iface_desc;
1888 const struct usb_device_id *id; 1856 const struct option_blacklist_info *blacklist;
1889 struct usb_wwan_intf_private *data; 1857 struct usb_wwan_intf_private *data;
1890 struct option_private *priv; 1858 struct option_private *priv;
1891 1859
@@ -1899,16 +1867,16 @@ static int option_attach(struct usb_serial *serial)
1899 return -ENOMEM; 1867 return -ENOMEM;
1900 } 1868 }
1901 1869
1902 /* Retrieve device id stored at probe. */ 1870 /* Retrieve blacklist info stored at probe. */
1903 id = usb_get_serial_data(serial); 1871 blacklist = usb_get_serial_data(serial);
1872
1904 iface_desc = &serial->interface->cur_altsetting->desc; 1873 iface_desc = &serial->interface->cur_altsetting->desc;
1905 1874
1906 priv->bInterfaceNumber = iface_desc->bInterfaceNumber; 1875 priv->bInterfaceNumber = iface_desc->bInterfaceNumber;
1907 data->private = priv; 1876 data->private = priv;
1908 1877
1909 if (!is_blacklisted(iface_desc->bInterfaceNumber, 1878 if (!blacklist || !test_bit(iface_desc->bInterfaceNumber,
1910 OPTION_BLACKLIST_SENDSETUP, 1879 &blacklist->sendsetup)) {
1911 (struct option_blacklist_info *)id->driver_info)) {
1912 data->send_setup = option_send_setup; 1880 data->send_setup = option_send_setup;
1913 } 1881 }
1914 spin_lock_init(&data->susp_lock); 1882 spin_lock_init(&data->susp_lock);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 11c7a9676441..d684b4b8108f 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -507,7 +507,7 @@ UNUSUAL_DEV( 0x04e6, 0x000c, 0x0100, 0x0100,
507UNUSUAL_DEV( 0x04e6, 0x000f, 0x0000, 0x9999, 507UNUSUAL_DEV( 0x04e6, 0x000f, 0x0000, 0x9999,
508 "SCM Microsystems", 508 "SCM Microsystems",
509 "eUSB SCSI Adapter (Bus Powered)", 509 "eUSB SCSI Adapter (Bus Powered)",
510 USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init, 510 USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
511 US_FL_SCM_MULT_TARG ), 511 US_FL_SCM_MULT_TARG ),
512 512
513UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200, 513UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
@@ -1995,6 +1995,13 @@ UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
1995 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 1995 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1996 US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ), 1996 US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
1997 1997
1998/* Reported by Dmitry Nezhevenko <dion@dion.org.ua> */
1999UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114,
2000 "JMicron",
2001 "USB to ATA/ATAPI Bridge",
2002 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2003 US_FL_BROKEN_FUA ),
2004
1998/* Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI) 2005/* Entrega Technologies U1-SC25 (later Xircom PortGear PGSCSI)
1999 * and Mac USB Dock USB-SCSI */ 2006 * and Mac USB Dock USB-SCSI */
2000UNUSUAL_DEV( 0x1645, 0x0007, 0x0100, 0x0133, 2007UNUSUAL_DEV( 0x1645, 0x0007, 0x0100, 0x0133,
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index 6df4357d9ee3..dbc00e56c7f5 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -140,3 +140,10 @@ UNUSUAL_DEV(0x4971, 0x1012, 0x0000, 0x9999,
140 "External HDD", 140 "External HDD",
141 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 141 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
142 US_FL_IGNORE_UAS), 142 US_FL_IGNORE_UAS),
143
144/* Reported-by: Richard Henderson <rth@redhat.com> */
145UNUSUAL_DEV(0x4971, 0x8017, 0x0000, 0x9999,
146 "SimpleTech",
147 "External HDD",
148 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
149 US_FL_NO_REPORT_OPCODES),
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 1ae9d40f96bf..11f6f61c2381 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -218,7 +218,8 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
218 memset(desc, 0, sizeof(*desc)); 218 memset(desc, 0, sizeof(*desc));
219 desc->bDescriptorType = 0x29; 219 desc->bDescriptorType = 0x29;
220 desc->bDescLength = 9; 220 desc->bDescLength = 9;
221 desc->wHubCharacteristics = (__constant_cpu_to_le16(0x0001)); 221 desc->wHubCharacteristics = __constant_cpu_to_le16(
222 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
222 desc->bNbrPorts = VHCI_NPORTS; 223 desc->bNbrPorts = VHCI_NPORTS;
223 desc->u.hs.DeviceRemovable[0] = 0xff; 224 desc->u.hs.DeviceRemovable[0] = 0xff;
224 desc->u.hs.DeviceRemovable[1] = 0xff; 225 desc->u.hs.DeviceRemovable[1] = 0xff;
diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c
index fe8bc777ab88..aa5af817f31c 100644
--- a/drivers/usb/wusbcore/rh.c
+++ b/drivers/usb/wusbcore/rh.c
@@ -185,9 +185,9 @@ static int wusbhc_rh_get_hub_descr(struct wusbhc *wusbhc, u16 wValue,
185 descr->bDescriptorType = 0x29; /* HUB type */ 185 descr->bDescriptorType = 0x29; /* HUB type */
186 descr->bNbrPorts = wusbhc->ports_max; 186 descr->bNbrPorts = wusbhc->ports_max;
187 descr->wHubCharacteristics = cpu_to_le16( 187 descr->wHubCharacteristics = cpu_to_le16(
188 0x00 /* All ports power at once */ 188 HUB_CHAR_COMMON_LPSM /* All ports power at once */
189 | 0x00 /* not part of compound device */ 189 | 0x00 /* not part of compound device */
190 | 0x10 /* No overcurrent protection */ 190 | HUB_CHAR_NO_OCPM /* No overcurrent protection */
191 | 0x00 /* 8 FS think time FIXME ?? */ 191 | 0x00 /* 8 FS think time FIXME ?? */
192 | 0x00); /* No port indicators */ 192 | 0x00); /* No port indicators */
193 descr->bPwrOn2PwrGood = 0; 193 descr->bPwrOn2PwrGood = 0;