aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-16 11:46:03 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-16 11:46:03 -0500
commitd59abb9325ae5eb8fd28440d80f820b945887541 (patch)
tree6ba86796569a8b478a959c2c76c8bfb2bde34522 /drivers/usb
parent319e2e3f63c348a9b66db4667efa73178e18b17d (diff)
parent3d724fa513cd1bd06d3457ccda36941f3606d048 (diff)
Merge branch 3.13-rc4 into usb-next
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/atm/usbatm.c8
-rw-r--r--drivers/usb/c67x00/c67x00-hcd.c2
-rw-r--r--drivers/usb/chipidea/Makefile2
-rw-r--r--drivers/usb/chipidea/ci_hdrc_pci.c2
-rw-r--r--drivers/usb/chipidea/core.c3
-rw-r--r--drivers/usb/chipidea/host.c3
-rw-r--r--drivers/usb/chipidea/usbmisc_imx.c46
-rw-r--r--drivers/usb/class/cdc-acm.c116
-rw-r--r--drivers/usb/class/cdc-acm.h3
-rw-r--r--drivers/usb/core/config.c7
-rw-r--r--drivers/usb/core/driver.c4
-rw-r--r--drivers/usb/core/hcd-pci.c1
-rw-r--r--drivers/usb/core/hcd.c38
-rw-r--r--drivers/usb/core/hub.c85
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/core/urb.c4
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/gadget/amd5536udc.c2
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c2
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c2
-rw-r--r--drivers/usb/gadget/pch_udc.c2
-rw-r--r--drivers/usb/host/Makefile2
-rw-r--r--drivers/usb/host/ehci-atmel.c1
-rw-r--r--drivers/usb/host/ehci-dbg.c10
-rw-r--r--drivers/usb/host/ehci-exynos.c1
-rw-r--r--drivers/usb/host/ehci-fsl.c3
-rw-r--r--drivers/usb/host/ehci-grlib.c1
-rw-r--r--drivers/usb/host/ehci-hcd.c14
-rw-r--r--drivers/usb/host/ehci-hub.c6
-rw-r--r--drivers/usb/host/ehci-mv.c3
-rw-r--r--drivers/usb/host/ehci-mxc.c1
-rw-r--r--drivers/usb/host/ehci-octeon.c1
-rw-r--r--drivers/usb/host/ehci-omap.c1
-rw-r--r--drivers/usb/host/ehci-orion.c1
-rw-r--r--drivers/usb/host/ehci-platform.c1
-rw-r--r--drivers/usb/host/ehci-pmcmsp.c4
-rw-r--r--drivers/usb/host/ehci-ppc-of.c1
-rw-r--r--drivers/usb/host/ehci-ps3.c1
-rw-r--r--drivers/usb/host/ehci-q.c4
-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-spear.c1
-rw-r--r--drivers/usb/host/ehci-tegra.c1
-rw-r--r--drivers/usb/host/ehci-tilegx.c1
-rw-r--r--drivers/usb/host/ehci-w90x900.c1
-rw-r--r--drivers/usb/host/ehci-xilinx-of.c4
-rw-r--r--drivers/usb/host/ehci.h8
-rw-r--r--drivers/usb/host/fhci-hcd.c2
-rw-r--r--drivers/usb/host/fotg210-hcd.c96
-rw-r--r--drivers/usb/host/fotg210.h8
-rw-r--r--drivers/usb/host/fusbh200-hcd.c98
-rw-r--r--drivers/usb/host/fusbh200.h12
-rw-r--r--drivers/usb/host/hwa-hc.c23
-rw-r--r--drivers/usb/host/imx21-dbg.c4
-rw-r--r--drivers/usb/host/imx21-hcd.c7
-rw-r--r--drivers/usb/host/imx21-hcd.h4
-rw-r--r--drivers/usb/host/isp116x-hcd.c4
-rw-r--r--drivers/usb/host/isp1362-hcd.c4
-rw-r--r--drivers/usb/host/isp1760-hcd.c1
-rw-r--r--drivers/usb/host/ohci-at91.c15
-rw-r--r--drivers/usb/host/ohci-da8xx.c18
-rw-r--r--drivers/usb/host/ohci-dbg.c69
-rw-r--r--drivers/usb/host/ohci-exynos.c23
-rw-r--r--drivers/usb/host/ohci-hcd.c29
-rw-r--r--drivers/usb/host/ohci-hub.c6
-rw-r--r--drivers/usb/host/ohci-jz4740.c1
-rw-r--r--drivers/usb/host/ohci-nxp.c4
-rw-r--r--drivers/usb/host/ohci-octeon.c2
-rw-r--r--drivers/usb/host/ohci-omap.c1
-rw-r--r--drivers/usb/host/ohci-omap3.c1
-rw-r--r--drivers/usb/host/ohci-platform.c2
-rw-r--r--drivers/usb/host/ohci-ppc-of.c4
-rw-r--r--drivers/usb/host/ohci-ps3.c1
-rw-r--r--drivers/usb/host/ohci-pxa27x.c4
-rw-r--r--drivers/usb/host/ohci-q.c12
-rw-r--r--drivers/usb/host/ohci-s3c2410.c22
-rw-r--r--drivers/usb/host/ohci-sa1111.c4
-rw-r--r--drivers/usb/host/ohci-sm501.c1
-rw-r--r--drivers/usb/host/ohci-spear.c16
-rw-r--r--drivers/usb/host/ohci-tilegx.c1
-rw-r--r--drivers/usb/host/ohci-tmio.c1
-rw-r--r--drivers/usb/host/ohci.h13
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c5
-rw-r--r--drivers/usb/host/r8a66597-hcd.c3
-rw-r--r--drivers/usb/host/sl811-hcd.c2
-rw-r--r--drivers/usb/host/u132-hcd.c3
-rw-r--r--drivers/usb/host/uhci-debug.c4
-rw-r--r--drivers/usb/host/uhci-grlib.c1
-rw-r--r--drivers/usb/host/uhci-hcd.c44
-rw-r--r--drivers/usb/host/uhci-pci.c2
-rw-r--r--drivers/usb/host/uhci-platform.c1
-rw-r--r--drivers/usb/host/whci/hcd.c1
-rw-r--r--drivers/usb/host/xhci-dbg.c42
-rw-r--r--drivers/usb/host/xhci-hub.c106
-rw-r--r--drivers/usb/host/xhci-mem.c68
-rw-r--r--drivers/usb/host/xhci-pci.c1
-rw-r--r--drivers/usb/host/xhci-plat.c2
-rw-r--r--drivers/usb/host/xhci-ring.c42
-rw-r--r--drivers/usb/host/xhci-trace.h6
-rw-r--r--drivers/usb/host/xhci.c214
-rw-r--r--drivers/usb/host/xhci.h65
-rw-r--r--drivers/usb/misc/usbtest.c17
-rw-r--r--drivers/usb/musb/musb_host.c1
-rw-r--r--drivers/usb/phy/phy-msm-usb.c1
-rw-r--r--drivers/usb/phy/phy-mv-usb.c6
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c1
-rw-r--r--drivers/usb/storage/protocol.c81
-rw-r--r--drivers/usb/wusbcore/cbaf.c8
-rw-r--r--drivers/usb/wusbcore/security.c22
-rw-r--r--drivers/usb/wusbcore/wa-hc.h7
-rw-r--r--drivers/usb/wusbcore/wa-rpipe.c10
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c209
112 files changed, 955 insertions, 944 deletions
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 25a7bfcf666c..dada0146cd7f 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -170,9 +170,9 @@ struct usbatm_control {
170static void usbatm_atm_dev_close(struct atm_dev *atm_dev); 170static void usbatm_atm_dev_close(struct atm_dev *atm_dev);
171static int usbatm_atm_open(struct atm_vcc *vcc); 171static int usbatm_atm_open(struct atm_vcc *vcc);
172static void usbatm_atm_close(struct atm_vcc *vcc); 172static void usbatm_atm_close(struct atm_vcc *vcc);
173static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user * arg); 173static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user *arg);
174static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb); 174static int usbatm_atm_send(struct atm_vcc *vcc, struct sk_buff *skb);
175static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page); 175static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page);
176 176
177static struct atmdev_ops usbatm_atm_devops = { 177static struct atmdev_ops usbatm_atm_devops = {
178 .dev_close = usbatm_atm_dev_close, 178 .dev_close = usbatm_atm_dev_close,
@@ -739,7 +739,7 @@ static void usbatm_atm_dev_close(struct atm_dev *atm_dev)
739 usbatm_put_instance(instance); /* taken in usbatm_atm_init */ 739 usbatm_put_instance(instance); /* taken in usbatm_atm_init */
740} 740}
741 741
742static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *page) 742static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t *pos, char *page)
743{ 743{
744 struct usbatm_data *instance = atm_dev->dev_data; 744 struct usbatm_data *instance = atm_dev->dev_data;
745 int left = *pos; 745 int left = *pos;
@@ -895,7 +895,7 @@ static void usbatm_atm_close(struct atm_vcc *vcc)
895} 895}
896 896
897static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd, 897static int usbatm_atm_ioctl(struct atm_dev *atm_dev, unsigned int cmd,
898 void __user * arg) 898 void __user *arg)
899{ 899{
900 struct usbatm_data *instance = atm_dev->dev_data; 900 struct usbatm_data *instance = atm_dev->dev_data;
901 901
diff --git a/drivers/usb/c67x00/c67x00-hcd.c b/drivers/usb/c67x00/c67x00-hcd.c
index 75e47b860a53..20ec4eee1ac8 100644
--- a/drivers/usb/c67x00/c67x00-hcd.c
+++ b/drivers/usb/c67x00/c67x00-hcd.c
@@ -384,6 +384,8 @@ int c67x00_hcd_probe(struct c67x00_sie *sie)
384 goto err2; 384 goto err2;
385 } 385 }
386 386
387 device_wakeup_enable(hcd->self.controller);
388
387 spin_lock_irqsave(&sie->lock, flags); 389 spin_lock_irqsave(&sie->lock, flags);
388 sie->private_data = c67x00; 390 sie->private_data = c67x00;
389 sie->irq = c67x00_hcd_irq; 391 sie->irq = c67x00_hcd_irq;
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index a99d980454a6..7345d2115af2 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),)
17endif 17endif
18 18
19ifneq ($(CONFIG_OF),) 19ifneq ($(CONFIG_OF),)
20 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_imx.o usbmisc_imx.o 20 obj-$(CONFIG_USB_CHIPIDEA) += usbmisc_imx.o ci_hdrc_imx.o
21endif 21endif
diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c
index d514332ac081..241ae3444fde 100644
--- a/drivers/usb/chipidea/ci_hdrc_pci.c
+++ b/drivers/usb/chipidea/ci_hdrc_pci.c
@@ -112,7 +112,7 @@ static void ci_hdrc_pci_remove(struct pci_dev *pdev)
112 * 112 *
113 * Check "pci.h" for details 113 * Check "pci.h" for details
114 */ 114 */
115static DEFINE_PCI_DEVICE_TABLE(ci_hdrc_pci_id_table) = { 115static const struct pci_device_id ci_hdrc_pci_id_table[] = {
116 { 116 {
117 PCI_DEVICE(0x153F, 0x1004), 117 PCI_DEVICE(0x153F, 0x1004),
118 .driver_data = (kernel_ulong_t)&pci_platdata, 118 .driver_data = (kernel_ulong_t)&pci_platdata,
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5d8981c5235e..50754073fae0 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
208 reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >> 208 reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >>
209 __ffs(HCCPARAMS_LEN); 209 __ffs(HCCPARAMS_LEN);
210 ci->hw_bank.lpm = reg; 210 ci->hw_bank.lpm = reg;
211 hw_alloc_regmap(ci, !!reg); 211 if (reg)
212 hw_alloc_regmap(ci, !!reg);
212 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs; 213 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs;
213 ci->hw_bank.size += OP_LAST; 214 ci->hw_bank.size += OP_LAST;
214 ci->hw_bank.size /= sizeof(u32); 215 ci->hw_bank.size /= sizeof(u32);
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 59e6020ea753..526cd77563d8 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -88,7 +88,8 @@ static int host_start(struct ci_hdrc *ci)
88 return ret; 88 return ret;
89 89
90disable_reg: 90disable_reg:
91 regulator_disable(ci->platdata->reg_vbus); 91 if (ci->platdata->reg_vbus)
92 regulator_disable(ci->platdata->reg_vbus);
92 93
93put_hcd: 94put_hcd:
94 usb_put_hcd(hcd); 95 usb_put_hcd(hcd);
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 8a1094b1182f..cd061abe3507 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -21,6 +21,10 @@
21#define MX25_USB_PHY_CTRL_OFFSET 0x08 21#define MX25_USB_PHY_CTRL_OFFSET 0x08
22#define MX25_BM_EXTERNAL_VBUS_DIVIDER BIT(23) 22#define MX25_BM_EXTERNAL_VBUS_DIVIDER BIT(23)
23 23
24#define MX27_H1_PM_BIT BIT(8)
25#define MX27_H2_PM_BIT BIT(16)
26#define MX27_OTG_PM_BIT BIT(24)
27
24#define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08 28#define MX53_USB_OTG_PHY_CTRL_0_OFFSET 0x08
25#define MX53_USB_UH2_CTRL_OFFSET 0x14 29#define MX53_USB_UH2_CTRL_OFFSET 0x14
26#define MX53_USB_UH3_CTRL_OFFSET 0x18 30#define MX53_USB_UH3_CTRL_OFFSET 0x18
@@ -68,6 +72,36 @@ static int usbmisc_imx25_post(struct imx_usbmisc_data *data)
68 return 0; 72 return 0;
69} 73}
70 74
75static int usbmisc_imx27_init(struct imx_usbmisc_data *data)
76{
77 unsigned long flags;
78 u32 val;
79
80 switch (data->index) {
81 case 0:
82 val = MX27_OTG_PM_BIT;
83 break;
84 case 1:
85 val = MX27_H1_PM_BIT;
86 break;
87 case 2:
88 val = MX27_H2_PM_BIT;
89 break;
90 default:
91 return -EINVAL;
92 };
93
94 spin_lock_irqsave(&usbmisc->lock, flags);
95 if (data->disable_oc)
96 val = readl(usbmisc->base) | val;
97 else
98 val = readl(usbmisc->base) & ~val;
99 writel(val, usbmisc->base);
100 spin_unlock_irqrestore(&usbmisc->lock, flags);
101
102 return 0;
103}
104
71static int usbmisc_imx53_init(struct imx_usbmisc_data *data) 105static int usbmisc_imx53_init(struct imx_usbmisc_data *data)
72{ 106{
73 void __iomem *reg = NULL; 107 void __iomem *reg = NULL;
@@ -128,6 +162,10 @@ static const struct usbmisc_ops imx25_usbmisc_ops = {
128 .post = usbmisc_imx25_post, 162 .post = usbmisc_imx25_post,
129}; 163};
130 164
165static const struct usbmisc_ops imx27_usbmisc_ops = {
166 .init = usbmisc_imx27_init,
167};
168
131static const struct usbmisc_ops imx53_usbmisc_ops = { 169static const struct usbmisc_ops imx53_usbmisc_ops = {
132 .init = usbmisc_imx53_init, 170 .init = usbmisc_imx53_init,
133}; 171};
@@ -162,6 +200,14 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
162 .data = &imx25_usbmisc_ops, 200 .data = &imx25_usbmisc_ops,
163 }, 201 },
164 { 202 {
203 .compatible = "fsl,imx27-usbmisc",
204 .data = &imx27_usbmisc_ops,
205 },
206 {
207 .compatible = "fsl,imx51-usbmisc",
208 .data = &imx53_usbmisc_ops,
209 },
210 {
165 .compatible = "fsl,imx53-usbmisc", 211 .compatible = "fsl,imx53-usbmisc",
166 .data = &imx53_usbmisc_ops, 212 .data = &imx53_usbmisc_ops,
167 }, 213 },
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e8404319ca68..900f7ff805ee 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -262,6 +262,7 @@ static void acm_ctrl_irq(struct urb *urb)
262 struct usb_cdc_notification *dr = urb->transfer_buffer; 262 struct usb_cdc_notification *dr = urb->transfer_buffer;
263 unsigned char *data; 263 unsigned char *data;
264 int newctrl; 264 int newctrl;
265 int difference;
265 int retval; 266 int retval;
266 int status = urb->status; 267 int status = urb->status;
267 268
@@ -302,20 +303,31 @@ static void acm_ctrl_irq(struct urb *urb)
302 tty_port_tty_hangup(&acm->port, false); 303 tty_port_tty_hangup(&acm->port, false);
303 } 304 }
304 305
306 difference = acm->ctrlin ^ newctrl;
307 spin_lock(&acm->read_lock);
305 acm->ctrlin = newctrl; 308 acm->ctrlin = newctrl;
309 acm->oldcount = acm->iocount;
310
311 if (difference & ACM_CTRL_DSR)
312 acm->iocount.dsr++;
313 if (difference & ACM_CTRL_BRK)
314 acm->iocount.brk++;
315 if (difference & ACM_CTRL_RI)
316 acm->iocount.rng++;
317 if (difference & ACM_CTRL_DCD)
318 acm->iocount.dcd++;
319 if (difference & ACM_CTRL_FRAMING)
320 acm->iocount.frame++;
321 if (difference & ACM_CTRL_PARITY)
322 acm->iocount.parity++;
323 if (difference & ACM_CTRL_OVERRUN)
324 acm->iocount.overrun++;
325 spin_unlock(&acm->read_lock);
326
327 if (difference)
328 wake_up_all(&acm->wioctl);
306 329
307 dev_dbg(&acm->control->dev, 330 break;
308 "%s - input control lines: dcd%c dsr%c break%c "
309 "ring%c framing%c parity%c overrun%c\n",
310 __func__,
311 acm->ctrlin & ACM_CTRL_DCD ? '+' : '-',
312 acm->ctrlin & ACM_CTRL_DSR ? '+' : '-',
313 acm->ctrlin & ACM_CTRL_BRK ? '+' : '-',
314 acm->ctrlin & ACM_CTRL_RI ? '+' : '-',
315 acm->ctrlin & ACM_CTRL_FRAMING ? '+' : '-',
316 acm->ctrlin & ACM_CTRL_PARITY ? '+' : '-',
317 acm->ctrlin & ACM_CTRL_OVERRUN ? '+' : '-');
318 break;
319 331
320 default: 332 default:
321 dev_dbg(&acm->control->dev, 333 dev_dbg(&acm->control->dev,
@@ -796,6 +808,72 @@ static int set_serial_info(struct acm *acm,
796 return retval; 808 return retval;
797} 809}
798 810
811static int wait_serial_change(struct acm *acm, unsigned long arg)
812{
813 int rv = 0;
814 DECLARE_WAITQUEUE(wait, current);
815 struct async_icount old, new;
816
817 if (arg & (TIOCM_DSR | TIOCM_RI | TIOCM_CD ))
818 return -EINVAL;
819 do {
820 spin_lock_irq(&acm->read_lock);
821 old = acm->oldcount;
822 new = acm->iocount;
823 acm->oldcount = new;
824 spin_unlock_irq(&acm->read_lock);
825
826 if ((arg & TIOCM_DSR) &&
827 old.dsr != new.dsr)
828 break;
829 if ((arg & TIOCM_CD) &&
830 old.dcd != new.dcd)
831 break;
832 if ((arg & TIOCM_RI) &&
833 old.rng != new.rng)
834 break;
835
836 add_wait_queue(&acm->wioctl, &wait);
837 set_current_state(TASK_INTERRUPTIBLE);
838 schedule();
839 remove_wait_queue(&acm->wioctl, &wait);
840 if (acm->disconnected) {
841 if (arg & TIOCM_CD)
842 break;
843 else
844 rv = -ENODEV;
845 } else {
846 if (signal_pending(current))
847 rv = -ERESTARTSYS;
848 }
849 } while (!rv);
850
851
852
853 return rv;
854}
855
856static int get_serial_usage(struct acm *acm,
857 struct serial_icounter_struct __user *count)
858{
859 struct serial_icounter_struct icount;
860 int rv = 0;
861
862 memset(&icount, 0, sizeof(icount));
863 icount.dsr = acm->iocount.dsr;
864 icount.rng = acm->iocount.rng;
865 icount.dcd = acm->iocount.dcd;
866 icount.frame = acm->iocount.frame;
867 icount.overrun = acm->iocount.overrun;
868 icount.parity = acm->iocount.parity;
869 icount.brk = acm->iocount.brk;
870
871 if (copy_to_user(count, &icount, sizeof(icount)) > 0)
872 rv = -EFAULT;
873
874 return rv;
875}
876
799static int acm_tty_ioctl(struct tty_struct *tty, 877static int acm_tty_ioctl(struct tty_struct *tty,
800 unsigned int cmd, unsigned long arg) 878 unsigned int cmd, unsigned long arg)
801{ 879{
@@ -809,6 +887,18 @@ static int acm_tty_ioctl(struct tty_struct *tty,
809 case TIOCSSERIAL: 887 case TIOCSSERIAL:
810 rv = set_serial_info(acm, (struct serial_struct __user *) arg); 888 rv = set_serial_info(acm, (struct serial_struct __user *) arg);
811 break; 889 break;
890 case TIOCMIWAIT:
891 rv = usb_autopm_get_interface(acm->control);
892 if (rv < 0) {
893 rv = -EIO;
894 break;
895 }
896 rv = wait_serial_change(acm, arg);
897 usb_autopm_put_interface(acm->control);
898 break;
899 case TIOCGICOUNT:
900 rv = get_serial_usage(acm, (struct serial_icounter_struct __user *) arg);
901 break;
812 } 902 }
813 903
814 return rv; 904 return rv;
@@ -1167,6 +1257,7 @@ made_compressed_probe:
1167 acm->readsize = readsize; 1257 acm->readsize = readsize;
1168 acm->rx_buflimit = num_rx_buf; 1258 acm->rx_buflimit = num_rx_buf;
1169 INIT_WORK(&acm->work, acm_softint); 1259 INIT_WORK(&acm->work, acm_softint);
1260 init_waitqueue_head(&acm->wioctl);
1170 spin_lock_init(&acm->write_lock); 1261 spin_lock_init(&acm->write_lock);
1171 spin_lock_init(&acm->read_lock); 1262 spin_lock_init(&acm->read_lock);
1172 mutex_init(&acm->mutex); 1263 mutex_init(&acm->mutex);
@@ -1383,6 +1474,7 @@ static void acm_disconnect(struct usb_interface *intf)
1383 device_remove_file(&acm->control->dev, 1474 device_remove_file(&acm->control->dev,
1384 &dev_attr_iCountryCodeRelDate); 1475 &dev_attr_iCountryCodeRelDate);
1385 } 1476 }
1477 wake_up_all(&acm->wioctl);
1386 device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); 1478 device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
1387 usb_set_intfdata(acm->control, NULL); 1479 usb_set_intfdata(acm->control, NULL);
1388 usb_set_intfdata(acm->data, NULL); 1480 usb_set_intfdata(acm->data, NULL);
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 0f76e4af600e..e38dc785808f 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -106,6 +106,9 @@ struct acm {
106 struct work_struct work; /* work queue entry for line discipline waking up */ 106 struct work_struct work; /* work queue entry for line discipline waking up */
107 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ 107 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
108 unsigned int ctrlout; /* output control lines (DTR, RTS) */ 108 unsigned int ctrlout; /* output control lines (DTR, RTS) */
109 struct async_icount iocount; /* counters for control line changes */
110 struct async_icount oldcount; /* for comparison of counter */
111 wait_queue_head_t wioctl; /* for ioctl */
109 unsigned int writesize; /* max packet size for the output bulk endpoint */ 112 unsigned int writesize; /* max packet size for the output bulk endpoint */
110 unsigned int readsize,ctrlsize; /* buffer sizes for freeing */ 113 unsigned int readsize,ctrlsize; /* buffer sizes for freeing */
111 unsigned int minor; /* acm minor number */ 114 unsigned int minor; /* acm minor number */
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index a6b2cabe7930..548d1996590f 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -651,10 +651,6 @@ void usb_destroy_configuration(struct usb_device *dev)
651 * 651 *
652 * hub-only!! ... and only in reset path, or usb_new_device() 652 * hub-only!! ... and only in reset path, or usb_new_device()
653 * (used by real hubs and virtual root hubs) 653 * (used by real hubs and virtual root hubs)
654 *
655 * NOTE: if this is a WUSB device and is not authorized, we skip the
656 * whole thing. A non-authorized USB device has no
657 * configurations.
658 */ 654 */
659int usb_get_configuration(struct usb_device *dev) 655int usb_get_configuration(struct usb_device *dev)
660{ 656{
@@ -666,8 +662,6 @@ int usb_get_configuration(struct usb_device *dev)
666 struct usb_config_descriptor *desc; 662 struct usb_config_descriptor *desc;
667 663
668 cfgno = 0; 664 cfgno = 0;
669 if (dev->authorized == 0) /* Not really an error */
670 goto out_not_authorized;
671 result = -ENOMEM; 665 result = -ENOMEM;
672 if (ncfg > USB_MAXCONFIG) { 666 if (ncfg > USB_MAXCONFIG) {
673 dev_warn(ddev, "too many configurations: %d, " 667 dev_warn(ddev, "too many configurations: %d, "
@@ -751,7 +745,6 @@ int usb_get_configuration(struct usb_device *dev)
751 745
752err: 746err:
753 kfree(desc); 747 kfree(desc);
754out_not_authorized:
755 dev->descriptor.bNumConfigurations = cfgno; 748 dev->descriptor.bNumConfigurations = cfgno;
756err2: 749err2:
757 if (result == -ENOMEM) 750 if (result == -ENOMEM)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 47aade2a5e74..8d989b1d3dc5 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -839,7 +839,7 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver,
839 return -ENODEV; 839 return -ENODEV;
840 840
841 new_udriver->drvwrap.for_devices = 1; 841 new_udriver->drvwrap.for_devices = 1;
842 new_udriver->drvwrap.driver.name = (char *) new_udriver->name; 842 new_udriver->drvwrap.driver.name = new_udriver->name;
843 new_udriver->drvwrap.driver.bus = &usb_bus_type; 843 new_udriver->drvwrap.driver.bus = &usb_bus_type;
844 new_udriver->drvwrap.driver.probe = usb_probe_device; 844 new_udriver->drvwrap.driver.probe = usb_probe_device;
845 new_udriver->drvwrap.driver.remove = usb_unbind_device; 845 new_udriver->drvwrap.driver.remove = usb_unbind_device;
@@ -900,7 +900,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
900 return -ENODEV; 900 return -ENODEV;
901 901
902 new_driver->drvwrap.for_devices = 0; 902 new_driver->drvwrap.for_devices = 0;
903 new_driver->drvwrap.driver.name = (char *) new_driver->name; 903 new_driver->drvwrap.driver.name = new_driver->name;
904 new_driver->drvwrap.driver.bus = &usb_bus_type; 904 new_driver->drvwrap.driver.bus = &usb_bus_type;
905 new_driver->drvwrap.driver.probe = usb_probe_interface; 905 new_driver->drvwrap.driver.probe = usb_probe_interface;
906 new_driver->drvwrap.driver.remove = usb_unbind_interface; 906 new_driver->drvwrap.driver.remove = usb_unbind_interface;
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index dfe9d0f22978..d59d99347d54 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -282,6 +282,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
282 282
283 if (retval != 0) 283 if (retval != 0)
284 goto unmap_registers; 284 goto unmap_registers;
285 device_wakeup_enable(hcd->self.controller);
285 286
286 if (pci_dev_run_wake(dev)) 287 if (pci_dev_run_wake(dev))
287 pm_runtime_put_noidle(&dev->dev); 288 pm_runtime_put_noidle(&dev->dev);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 6bffb8c87bc9..6297c9e50de2 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -44,6 +44,7 @@
44 44
45#include <linux/usb.h> 45#include <linux/usb.h>
46#include <linux/usb/hcd.h> 46#include <linux/usb/hcd.h>
47#include <linux/usb/phy.h>
47 48
48#include "usb.h" 49#include "usb.h"
49 50
@@ -2588,6 +2589,24 @@ int usb_add_hcd(struct usb_hcd *hcd,
2588 int retval; 2589 int retval;
2589 struct usb_device *rhdev; 2590 struct usb_device *rhdev;
2590 2591
2592 if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->phy) {
2593 struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0);
2594
2595 if (IS_ERR(phy)) {
2596 retval = PTR_ERR(phy);
2597 if (retval == -EPROBE_DEFER)
2598 return retval;
2599 } else {
2600 retval = usb_phy_init(phy);
2601 if (retval) {
2602 usb_put_phy(phy);
2603 return retval;
2604 }
2605 hcd->phy = phy;
2606 hcd->remove_phy = 1;
2607 }
2608 }
2609
2591 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); 2610 dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
2592 2611
2593 /* Keep old behaviour if authorized_default is not in [0, 1]. */ 2612 /* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2603,7 +2622,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
2603 */ 2622 */
2604 if ((retval = hcd_buffer_create(hcd)) != 0) { 2623 if ((retval = hcd_buffer_create(hcd)) != 0) {
2605 dev_dbg(hcd->self.controller, "pool alloc failed\n"); 2624 dev_dbg(hcd->self.controller, "pool alloc failed\n");
2606 return retval; 2625 goto err_remove_phy;
2607 } 2626 }
2608 2627
2609 if ((retval = usb_register_bus(&hcd->self)) < 0) 2628 if ((retval = usb_register_bus(&hcd->self)) < 0)
@@ -2693,12 +2712,6 @@ int usb_add_hcd(struct usb_hcd *hcd,
2693 if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) 2712 if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
2694 usb_hcd_poll_rh_status(hcd); 2713 usb_hcd_poll_rh_status(hcd);
2695 2714
2696 /*
2697 * Host controllers don't generate their own wakeup requests;
2698 * they only forward requests from the root hub. Therefore
2699 * controllers should always be enabled for remote wakeup.
2700 */
2701 device_wakeup_enable(hcd->self.controller);
2702 return retval; 2715 return retval;
2703 2716
2704error_create_attr_group: 2717error_create_attr_group:
@@ -2734,6 +2747,12 @@ err_allocate_root_hub:
2734 usb_deregister_bus(&hcd->self); 2747 usb_deregister_bus(&hcd->self);
2735err_register_bus: 2748err_register_bus:
2736 hcd_buffer_destroy(hcd); 2749 hcd_buffer_destroy(hcd);
2750err_remove_phy:
2751 if (hcd->remove_phy && hcd->phy) {
2752 usb_phy_shutdown(hcd->phy);
2753 usb_put_phy(hcd->phy);
2754 hcd->phy = NULL;
2755 }
2737 return retval; 2756 return retval;
2738} 2757}
2739EXPORT_SYMBOL_GPL(usb_add_hcd); 2758EXPORT_SYMBOL_GPL(usb_add_hcd);
@@ -2806,6 +2825,11 @@ void usb_remove_hcd(struct usb_hcd *hcd)
2806 usb_put_dev(hcd->self.root_hub); 2825 usb_put_dev(hcd->self.root_hub);
2807 usb_deregister_bus(&hcd->self); 2826 usb_deregister_bus(&hcd->self);
2808 hcd_buffer_destroy(hcd); 2827 hcd_buffer_destroy(hcd);
2828 if (hcd->remove_phy && hcd->phy) {
2829 usb_phy_shutdown(hcd->phy);
2830 usb_put_phy(hcd->phy);
2831 hcd->phy = NULL;
2832 }
2809} 2833}
2810EXPORT_SYMBOL_GPL(usb_remove_hcd); 2834EXPORT_SYMBOL_GPL(usb_remove_hcd);
2811 2835
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index bd9dc3504b51..162e94dbed53 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2235,17 +2235,13 @@ static int usb_enumerate_device(struct usb_device *udev)
2235 return err; 2235 return err;
2236 } 2236 }
2237 } 2237 }
2238 if (udev->wusb == 1 && udev->authorized == 0) { 2238
2239 udev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2239 /* read the standard strings and cache them if present */
2240 udev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2240 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
2241 udev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL); 2241 udev->manufacturer = usb_cache_string(udev,
2242 } else { 2242 udev->descriptor.iManufacturer);
2243 /* read the standard strings and cache them if present */ 2243 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2244 udev->product = usb_cache_string(udev, udev->descriptor.iProduct); 2244
2245 udev->manufacturer = usb_cache_string(udev,
2246 udev->descriptor.iManufacturer);
2247 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
2248 }
2249 err = usb_enumerate_device_otg(udev); 2245 err = usb_enumerate_device_otg(udev);
2250 if (err < 0) 2246 if (err < 0)
2251 return err; 2247 return err;
@@ -2427,16 +2423,6 @@ int usb_deauthorize_device(struct usb_device *usb_dev)
2427 usb_dev->authorized = 0; 2423 usb_dev->authorized = 0;
2428 usb_set_configuration(usb_dev, -1); 2424 usb_set_configuration(usb_dev, -1);
2429 2425
2430 kfree(usb_dev->product);
2431 usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2432 kfree(usb_dev->manufacturer);
2433 usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2434 kfree(usb_dev->serial);
2435 usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
2436
2437 usb_destroy_configuration(usb_dev);
2438 usb_dev->descriptor.bNumConfigurations = 0;
2439
2440out_unauthorized: 2426out_unauthorized:
2441 usb_unlock_device(usb_dev); 2427 usb_unlock_device(usb_dev);
2442 return 0; 2428 return 0;
@@ -2464,17 +2450,7 @@ int usb_authorize_device(struct usb_device *usb_dev)
2464 goto error_device_descriptor; 2450 goto error_device_descriptor;
2465 } 2451 }
2466 2452
2467 kfree(usb_dev->product);
2468 usb_dev->product = NULL;
2469 kfree(usb_dev->manufacturer);
2470 usb_dev->manufacturer = NULL;
2471 kfree(usb_dev->serial);
2472 usb_dev->serial = NULL;
2473
2474 usb_dev->authorized = 1; 2453 usb_dev->authorized = 1;
2475 result = usb_enumerate_device(usb_dev);
2476 if (result < 0)
2477 goto error_enumerate;
2478 /* Choose and set the configuration. This registers the interfaces 2454 /* Choose and set the configuration. This registers the interfaces
2479 * with the driver core and lets interface drivers bind to them. 2455 * with the driver core and lets interface drivers bind to them.
2480 */ 2456 */
@@ -2490,7 +2466,6 @@ int usb_authorize_device(struct usb_device *usb_dev)
2490 } 2466 }
2491 dev_info(&usb_dev->dev, "authorized to connect\n"); 2467 dev_info(&usb_dev->dev, "authorized to connect\n");
2492 2468
2493error_enumerate:
2494error_device_descriptor: 2469error_device_descriptor:
2495 usb_autosuspend_device(usb_dev); 2470 usb_autosuspend_device(usb_dev);
2496error_autoresume: 2471error_autoresume:
@@ -2523,6 +2498,21 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
2523#define HUB_LONG_RESET_TIME 200 2498#define HUB_LONG_RESET_TIME 200
2524#define HUB_RESET_TIMEOUT 800 2499#define HUB_RESET_TIMEOUT 800
2525 2500
2501/*
2502 * "New scheme" enumeration causes an extra state transition to be
2503 * exposed to an xhci host and causes USB3 devices to receive control
2504 * commands in the default state. This has been seen to cause
2505 * enumeration failures, so disable this enumeration scheme for USB3
2506 * devices.
2507 */
2508static bool use_new_scheme(struct usb_device *udev, int retry)
2509{
2510 if (udev->speed == USB_SPEED_SUPER)
2511 return false;
2512
2513 return USE_NEW_SCHEME(retry);
2514}
2515
2526static int hub_port_reset(struct usb_hub *hub, int port1, 2516static int hub_port_reset(struct usb_hub *hub, int port1,
2527 struct usb_device *udev, unsigned int delay, bool warm); 2517 struct usb_device *udev, unsigned int delay, bool warm);
2528 2518
@@ -3981,6 +3971,20 @@ static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
3981 } 3971 }
3982} 3972}
3983 3973
3974static int hub_enable_device(struct usb_device *udev)
3975{
3976 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
3977
3978 if (!hcd->driver->enable_device)
3979 return 0;
3980 if (udev->state == USB_STATE_ADDRESS)
3981 return 0;
3982 if (udev->state != USB_STATE_DEFAULT)
3983 return -EINVAL;
3984
3985 return hcd->driver->enable_device(hcd, udev);
3986}
3987
3984/* Reset device, (re)assign address, get device descriptor. 3988/* Reset device, (re)assign address, get device descriptor.
3985 * Device connection must be stable, no more debouncing needed. 3989 * Device connection must be stable, no more debouncing needed.
3986 * Returns device in USB_STATE_ADDRESS, except on error. 3990 * Returns device in USB_STATE_ADDRESS, except on error.
@@ -4093,7 +4097,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4093 * this area, and this is how Linux has done it for ages. 4097 * this area, and this is how Linux has done it for ages.
4094 * Change it cautiously. 4098 * Change it cautiously.
4095 * 4099 *
4096 * NOTE: If USE_NEW_SCHEME() is true we will start by issuing 4100 * NOTE: If use_new_scheme() is true we will start by issuing
4097 * a 64-byte GET_DESCRIPTOR request. This is what Windows does, 4101 * a 64-byte GET_DESCRIPTOR request. This is what Windows does,
4098 * so it may help with some non-standards-compliant devices. 4102 * so it may help with some non-standards-compliant devices.
4099 * Otherwise we start with SET_ADDRESS and then try to read the 4103 * Otherwise we start with SET_ADDRESS and then try to read the
@@ -4101,10 +4105,17 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4101 * value. 4105 * value.
4102 */ 4106 */
4103 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) { 4107 for (i = 0; i < GET_DESCRIPTOR_TRIES; (++i, msleep(100))) {
4104 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) { 4108 bool did_new_scheme = false;
4109
4110 if (use_new_scheme(udev, retry_counter)) {
4105 struct usb_device_descriptor *buf; 4111 struct usb_device_descriptor *buf;
4106 int r = 0; 4112 int r = 0;
4107 4113
4114 did_new_scheme = true;
4115 retval = hub_enable_device(udev);
4116 if (retval < 0)
4117 goto fail;
4118
4108#define GET_DESCRIPTOR_BUFSIZE 64 4119#define GET_DESCRIPTOR_BUFSIZE 64
4109 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO); 4120 buf = kmalloc(GET_DESCRIPTOR_BUFSIZE, GFP_NOIO);
4110 if (!buf) { 4121 if (!buf) {
@@ -4193,7 +4204,11 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4193 * - read ep0 maxpacket even for high and low speed, 4204 * - read ep0 maxpacket even for high and low speed,
4194 */ 4205 */
4195 msleep(10); 4206 msleep(10);
4196 if (USE_NEW_SCHEME(retry_counter) && !(hcd->driver->flags & HCD_USB3)) 4207 /* use_new_scheme() checks the speed which may have
4208 * changed since the initial look so we cache the result
4209 * in did_new_scheme
4210 */
4211 if (did_new_scheme)
4197 break; 4212 break;
4198 } 4213 }
4199 4214
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 12924dbfdc2c..8f37063c0a49 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -98,9 +98,6 @@ static const struct usb_device_id usb_quirk_list[] = {
98 /* Alcor Micro Corp. Hub */ 98 /* Alcor Micro Corp. Hub */
99 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, 99 { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME },
100 100
101 /* MicroTouch Systems touchscreen */
102 { USB_DEVICE(0x0596, 0x051e), .driver_info = USB_QUIRK_RESET_RESUME },
103
104 /* appletouch */ 101 /* appletouch */
105 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, 102 { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME },
106 103
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index e62208356c89..07c58af6b5c0 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -492,9 +492,9 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
492 /* too small? */ 492 /* too small? */
493 switch (dev->speed) { 493 switch (dev->speed) {
494 case USB_SPEED_WIRELESS: 494 case USB_SPEED_WIRELESS:
495 if (urb->interval < 6) 495 if ((urb->interval < 6)
496 && (xfertype == USB_ENDPOINT_XFER_INT))
496 return -EINVAL; 497 return -EINVAL;
497 break;
498 default: 498 default:
499 if (urb->interval <= 0) 499 if (urb->interval <= 0)
500 return -EINVAL; 500 return -EINVAL;
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 31443aeedcdb..665686e7c8cd 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -182,7 +182,7 @@ static void dwc3_pci_remove(struct pci_dev *pci)
182 pci_disable_device(pci); 182 pci_disable_device(pci);
183} 183}
184 184
185static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { 185static const struct pci_device_id dwc3_pci_id_table[] = {
186 { 186 {
187 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 187 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
188 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), 188 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 54a1e2954cea..f0ff4a675e9d 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3338,7 +3338,7 @@ static int udc_remote_wakeup(struct udc *dev)
3338} 3338}
3339 3339
3340/* PCI device parameters */ 3340/* PCI device parameters */
3341static DEFINE_PCI_DEVICE_TABLE(pci_id) = { 3341static const struct pci_device_id pci_id[] = {
3342 { 3342 {
3343 PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x2096), 3343 PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x2096),
3344 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, 3344 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index 807127d56fa3..6315ee698d4d 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -2717,7 +2717,7 @@ MODULE_DEVICE_TABLE(of, qe_udc_match);
2717 2717
2718static struct platform_driver udc_driver = { 2718static struct platform_driver udc_driver = {
2719 .driver = { 2719 .driver = {
2720 .name = (char *)driver_name, 2720 .name = driver_name,
2721 .owner = THIS_MODULE, 2721 .owner = THIS_MODULE,
2722 .of_match_table = qe_udc_match, 2722 .of_match_table = qe_udc_match,
2723 }, 2723 },
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 36ac7cfba91d..b7dea4eec32c 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2666,7 +2666,7 @@ static struct platform_driver udc_driver = {
2666 .suspend = fsl_udc_suspend, 2666 .suspend = fsl_udc_suspend,
2667 .resume = fsl_udc_resume, 2667 .resume = fsl_udc_resume,
2668 .driver = { 2668 .driver = {
2669 .name = (char *)driver_name, 2669 .name = driver_name,
2670 .owner = THIS_MODULE, 2670 .owner = THIS_MODULE,
2671 /* udc suspend/resume called from OTG driver */ 2671 /* udc suspend/resume called from OTG driver */
2672 .suspend = fsl_udc_otg_suspend, 2672 .suspend = fsl_udc_otg_suspend,
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index 32d5e923750b..78a3d9289816 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -3210,7 +3210,7 @@ finished:
3210 return retval; 3210 return retval;
3211} 3211}
3212 3212
3213static DEFINE_PCI_DEVICE_TABLE(pch_udc_pcidev_id) = { 3213static const struct pci_device_id pch_udc_pcidev_id[] = {
3214 { 3214 {
3215 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC), 3215 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC),
3216 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, 3216 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 01e879ef3654..7530468c9a4f 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -2,8 +2,6 @@
2# Makefile for USB Host Controller Drivers 2# Makefile for USB Host Controller Drivers
3# 3#
4 4
5ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
6
7# tell define_trace.h where to find the xhci trace header 5# tell define_trace.h where to find the xhci trace header
8CFLAGS_xhci-trace.o := -I$(src) 6CFLAGS_xhci-trace.o := -I$(src)
9 7
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 284f8417eae5..ec9f7b75d497 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -153,6 +153,7 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
153 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 153 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
154 if (retval) 154 if (retval)
155 goto fail_add_hcd; 155 goto fail_add_hcd;
156 device_wakeup_enable(hcd->self.controller);
156 157
157 return retval; 158 return retval;
158 159
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 4a9c2edbcb2b..524cbf26d992 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -18,7 +18,7 @@
18 18
19/* this file is part of ehci-hcd.c */ 19/* this file is part of ehci-hcd.c */
20 20
21#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 21#ifdef CONFIG_DYNAMIC_DEBUG
22 22
23/* check the values in the HCSPARAMS register 23/* check the values in the HCSPARAMS register
24 * (host controller _Structural_ parameters) 24 * (host controller _Structural_ parameters)
@@ -62,7 +62,7 @@ static inline void dbg_hcs_params (struct ehci_hcd *ehci, char *label) {}
62 62
63#endif 63#endif
64 64
65#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 65#ifdef CONFIG_DYNAMIC_DEBUG
66 66
67/* check the values in the HCCPARAMS register 67/* check the values in the HCCPARAMS register
68 * (host controller _Capability_ parameters) 68 * (host controller _Capability_ parameters)
@@ -101,7 +101,7 @@ static inline void dbg_hcc_params (struct ehci_hcd *ehci, char *label) {}
101 101
102#endif 102#endif
103 103
104#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 104#ifdef CONFIG_DYNAMIC_DEBUG
105 105
106static void __maybe_unused 106static void __maybe_unused
107dbg_qtd (const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd) 107dbg_qtd (const char *label, struct ehci_hcd *ehci, struct ehci_qtd *qtd)
@@ -301,7 +301,7 @@ static inline int __maybe_unused
301dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status) 301dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
302{ return 0; } 302{ return 0; }
303 303
304#endif /* DEBUG || CONFIG_DYNAMIC_DEBUG */ 304#endif /* CONFIG_DYNAMIC_DEBUG */
305 305
306/* functions have the "wrong" filename when they're output... */ 306/* functions have the "wrong" filename when they're output... */
307#define dbg_status(ehci, label, status) { \ 307#define dbg_status(ehci, label, status) { \
@@ -818,7 +818,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
818 818
819#ifdef CONFIG_PCI 819#ifdef CONFIG_PCI
820 /* EHCI 0.96 and later may have "extended capabilities" */ 820 /* EHCI 0.96 and later may have "extended capabilities" */
821 if (hcd->self.controller->bus == &pci_bus_type) { 821 if (dev_is_pci(hcd->self.controller)) {
822 struct pci_dev *pdev; 822 struct pci_dev *pdev;
823 u32 offset, cap, cap2; 823 u32 offset, cap, cap2;
824 unsigned count = 256/4; 824 unsigned count = 256/4;
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index e97c198e052f..d1d8c47777c5 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -166,6 +166,7 @@ skip_phy:
166 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 166 dev_err(&pdev->dev, "Failed to add USB HCD\n");
167 goto fail_add_hcd; 167 goto fail_add_hcd;
168 } 168 }
169 device_wakeup_enable(hcd->self.controller);
169 170
170 platform_set_drvdata(pdev, hcd); 171 platform_set_drvdata(pdev, hcd);
171 172
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index a06d5012201f..854a68fa59a6 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -138,6 +138,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
138 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 138 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
139 if (retval != 0) 139 if (retval != 0)
140 goto err4; 140 goto err4;
141 device_wakeup_enable(hcd->self.controller);
141 142
142#ifdef CONFIG_USB_OTG 143#ifdef CONFIG_USB_OTG
143 if (pdata->operating_mode == FSL_USB2_DR_OTG) { 144 if (pdata->operating_mode == FSL_USB2_DR_OTG) {
@@ -413,7 +414,7 @@ static int ehci_fsl_mpc512x_drv_suspend(struct device *dev)
413 struct fsl_usb2_platform_data *pdata = dev_get_platdata(dev); 414 struct fsl_usb2_platform_data *pdata = dev_get_platdata(dev);
414 u32 tmp; 415 u32 tmp;
415 416
416#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 417#ifdef CONFIG_DYNAMIC_DEBUG
417 u32 mode = ehci_readl(ehci, hcd->regs + FSL_SOC_USB_USBMODE); 418 u32 mode = ehci_readl(ehci, hcd->regs + FSL_SOC_USB_USBMODE);
418 mode &= USBMODE_CM_MASK; 419 mode &= USBMODE_CM_MASK;
419 tmp = ehci_readl(ehci, hcd->regs + 0x140); /* usbcmd */ 420 tmp = ehci_readl(ehci, hcd->regs + 0x140); /* usbcmd */
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c
index b52a66ce92e8..054792c56271 100644
--- a/drivers/usb/host/ehci-grlib.c
+++ b/drivers/usb/host/ehci-grlib.c
@@ -140,6 +140,7 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
140 if (rv) 140 if (rv)
141 goto err_ioremap; 141 goto err_ioremap;
142 142
143 device_wakeup_enable(hcd->self.controller);
143 return 0; 144 return 0;
144 145
145err_ioremap: 146err_ioremap:
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index e8ba4c44223a..471142725ffe 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -71,7 +71,6 @@
71static const char hcd_name [] = "ehci_hcd"; 71static const char hcd_name [] = "ehci_hcd";
72 72
73 73
74#undef VERBOSE_DEBUG
75#undef EHCI_URB_TRACE 74#undef EHCI_URB_TRACE
76 75
77/* magic numbers that can affect system performance */ 76/* magic numbers that can affect system performance */
@@ -714,13 +713,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
714 cmd = ehci_readl(ehci, &ehci->regs->command); 713 cmd = ehci_readl(ehci, &ehci->regs->command);
715 bh = 0; 714 bh = 0;
716 715
717#ifdef VERBOSE_DEBUG
718 /* unrequested/ignored: Frame List Rollover */
719 dbg_status (ehci, "irq", status);
720#endif
721
722 /* INT, ERR, and IAA interrupt rates can be throttled */
723
724 /* normal [4.15.1.2] or error [4.15.1.1] completion */ 716 /* normal [4.15.1.2] or error [4.15.1.1] completion */
725 if (likely ((status & (STS_INT|STS_ERR)) != 0)) { 717 if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
726 if (likely ((status & STS_ERR) == 0)) 718 if (likely ((status & STS_ERR) == 0))
@@ -1320,7 +1312,7 @@ static int __init ehci_hcd_init(void)
1320 sizeof(struct ehci_qh), sizeof(struct ehci_qtd), 1312 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
1321 sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); 1313 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
1322 1314
1323#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 1315#ifdef CONFIG_DYNAMIC_DEBUG
1324 ehci_debug_root = debugfs_create_dir("ehci", usb_debug_root); 1316 ehci_debug_root = debugfs_create_dir("ehci", usb_debug_root);
1325 if (!ehci_debug_root) { 1317 if (!ehci_debug_root) {
1326 retval = -ENOENT; 1318 retval = -ENOENT;
@@ -1369,7 +1361,7 @@ clean2:
1369 platform_driver_unregister(&PLATFORM_DRIVER); 1361 platform_driver_unregister(&PLATFORM_DRIVER);
1370clean0: 1362clean0:
1371#endif 1363#endif
1372#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 1364#ifdef CONFIG_DYNAMIC_DEBUG
1373 debugfs_remove(ehci_debug_root); 1365 debugfs_remove(ehci_debug_root);
1374 ehci_debug_root = NULL; 1366 ehci_debug_root = NULL;
1375err_debug: 1367err_debug:
@@ -1393,7 +1385,7 @@ static void __exit ehci_hcd_cleanup(void)
1393#ifdef PS3_SYSTEM_BUS_DRIVER 1385#ifdef PS3_SYSTEM_BUS_DRIVER
1394 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1386 ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1395#endif 1387#endif
1396#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 1388#ifdef CONFIG_DYNAMIC_DEBUG
1397 debugfs_remove(ehci_debug_root); 1389 debugfs_remove(ehci_debug_root);
1398#endif 1390#endif
1399 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 1391 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 835fc0844a66..47b858fc50b2 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1114,10 +1114,8 @@ static int ehci_hub_control (
1114 if (test_bit(wIndex, &ehci->port_c_suspend)) 1114 if (test_bit(wIndex, &ehci->port_c_suspend))
1115 status |= USB_PORT_STAT_C_SUSPEND << 16; 1115 status |= USB_PORT_STAT_C_SUSPEND << 16;
1116 1116
1117#ifndef VERBOSE_DEBUG 1117 if (status & ~0xffff) /* only if wPortChange is interesting */
1118 if (status & ~0xffff) /* only if wPortChange is interesting */ 1118 dbg_port(ehci, "GetStatus", wIndex + 1, temp);
1119#endif
1120 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
1121 put_unaligned_le32(status, buf); 1119 put_unaligned_le32(status, buf);
1122 break; 1120 break;
1123 case SetHubFeature: 1121 case SetHubFeature:
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 417c10da9450..bd61612a7251 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -178,7 +178,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
178 178
179 ehci_mv->phy_regs = devm_ioremap(&pdev->dev, r->start, 179 ehci_mv->phy_regs = devm_ioremap(&pdev->dev, r->start,
180 resource_size(r)); 180 resource_size(r));
181 if (ehci_mv->phy_regs == 0) { 181 if (!ehci_mv->phy_regs) {
182 dev_err(&pdev->dev, "failed to map phy I/O memory\n"); 182 dev_err(&pdev->dev, "failed to map phy I/O memory\n");
183 retval = -EFAULT; 183 retval = -EFAULT;
184 goto err_put_hcd; 184 goto err_put_hcd;
@@ -257,6 +257,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
257 "failed to add hcd with err %d\n", retval); 257 "failed to add hcd with err %d\n", retval);
258 goto err_set_vbus; 258 goto err_set_vbus;
259 } 259 }
260 device_wakeup_enable(hcd->self.controller);
260 } 261 }
261 262
262 if (pdata->private_init) 263 if (pdata->private_init)
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 0528dc4526c8..dbe5e4eea08d 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -155,6 +155,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
155 if (ret) 155 if (ret)
156 goto err_add; 156 goto err_add;
157 157
158 device_wakeup_enable(hcd->self.controller);
158 return 0; 159 return 0;
159 160
160err_add: 161err_add:
diff --git a/drivers/usb/host/ehci-octeon.c b/drivers/usb/host/ehci-octeon.c
index 4c528b2c033a..c4ad7ed6b3f8 100644
--- a/drivers/usb/host/ehci-octeon.c
+++ b/drivers/usb/host/ehci-octeon.c
@@ -158,6 +158,7 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev)
158 dev_dbg(&pdev->dev, "failed to add hcd with err %d\n", ret); 158 dev_dbg(&pdev->dev, "failed to add hcd with err %d\n", ret);
159 goto err3; 159 goto err3;
160 } 160 }
161 device_wakeup_enable(hcd->self.controller);
161 162
162 platform_set_drvdata(pdev, hcd); 163 platform_set_drvdata(pdev, hcd);
163 164
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 6fa82d6b7661..a24720beb39d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -215,6 +215,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
215 dev_err(dev, "failed to add hcd with err %d\n", ret); 215 dev_err(dev, "failed to add hcd with err %d\n", ret);
216 goto err_pm_runtime; 216 goto err_pm_runtime;
217 } 217 }
218 device_wakeup_enable(hcd->self.controller);
218 219
219 /* 220 /*
220 * Bring PHYs out of reset for non PHY modes. 221 * Bring PHYs out of reset for non PHY modes.
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 2ba76730e650..aa8b92bf5361 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -252,6 +252,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
252 if (err) 252 if (err)
253 goto err4; 253 goto err4;
254 254
255 device_wakeup_enable(hcd->self.controller);
255 return 0; 256 return 0;
256 257
257err4: 258err4:
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 7f30b7168d5a..01536cfd361d 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -132,6 +132,7 @@ static int ehci_platform_probe(struct platform_device *dev)
132 if (err) 132 if (err)
133 goto err_put_hcd; 133 goto err_put_hcd;
134 134
135 device_wakeup_enable(hcd->self.controller);
135 platform_set_drvdata(dev, hcd); 136 platform_set_drvdata(dev, hcd);
136 137
137 return err; 138 return err;
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c
index 893b707f0000..af3974a5e7c2 100644
--- a/drivers/usb/host/ehci-pmcmsp.c
+++ b/drivers/usb/host/ehci-pmcmsp.c
@@ -210,8 +210,10 @@ int usb_hcd_msp_probe(const struct hc_driver *driver,
210 210
211 211
212 retval = usb_add_hcd(hcd, res->start, IRQF_SHARED); 212 retval = usb_add_hcd(hcd, res->start, IRQF_SHARED);
213 if (retval == 0) 213 if (retval == 0) {
214 device_wakeup_enable(hcd->self.controller);
214 return 0; 215 return 0;
216 }
215 217
216 usb_remove_hcd(hcd); 218 usb_remove_hcd(hcd);
217err3: 219err3:
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index 875d2fcc9e0e..b0965eb6c0db 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -169,6 +169,7 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
169 if (rv) 169 if (rv)
170 goto err_ioremap; 170 goto err_ioremap;
171 171
172 device_wakeup_enable(hcd->self.controller);
172 return 0; 173 return 0;
173 174
174err_ioremap: 175err_ioremap:
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c
index 8188542ba17e..7934ff9b35e1 100644
--- a/drivers/usb/host/ehci-ps3.c
+++ b/drivers/usb/host/ehci-ps3.c
@@ -189,6 +189,7 @@ static int ps3_ehci_probe(struct ps3_system_bus_device *dev)
189 goto fail_add_hcd; 189 goto fail_add_hcd;
190 } 190 }
191 191
192 device_wakeup_enable(hcd->self.controller);
192 return result; 193 return result;
193 194
194fail_add_hcd: 195fail_add_hcd:
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index db05bd8ee9d5..54f5332f814d 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -168,13 +168,13 @@ static void ehci_clear_tt_buffer(struct ehci_hcd *ehci, struct ehci_qh *qh,
168 * Note: this routine is never called for Isochronous transfers. 168 * Note: this routine is never called for Isochronous transfers.
169 */ 169 */
170 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { 170 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
171#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 171#ifdef CONFIG_DYNAMIC_DEBUG
172 struct usb_device *tt = urb->dev->tt->hub; 172 struct usb_device *tt = urb->dev->tt->hub;
173 dev_dbg(&tt->dev, 173 dev_dbg(&tt->dev,
174 "clear tt buffer port %d, a%d ep%d t%08x\n", 174 "clear tt buffer port %d, a%d ep%d t%08x\n",
175 urb->dev->ttport, urb->dev->devnum, 175 urb->dev->ttport, urb->dev->devnum,
176 usb_pipeendpoint(urb->pipe), token); 176 usb_pipeendpoint(urb->pipe), token);
177#endif /* DEBUG || CONFIG_DYNAMIC_DEBUG */ 177#endif /* CONFIG_DYNAMIC_DEBUG */
178 if (!ehci_is_TDI(ehci) 178 if (!ehci_is_TDI(ehci)
179 || urb->dev->tt->hub != 179 || urb->dev->tt->hub !=
180 ehci_to_hcd(ehci)->self.root_hub) { 180 ehci_to_hcd(ehci)->self.root_hub) {
diff --git a/drivers/usb/host/ehci-sead3.c b/drivers/usb/host/ehci-sead3.c
index 8a734498079b..cf1267673868 100644
--- a/drivers/usb/host/ehci-sead3.c
+++ b/drivers/usb/host/ehci-sead3.c
@@ -126,6 +126,7 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev)
126 IRQF_SHARED); 126 IRQF_SHARED);
127 if (ret == 0) { 127 if (ret == 0) {
128 platform_set_drvdata(pdev, hcd); 128 platform_set_drvdata(pdev, hcd);
129 device_wakeup_enable(hcd->self.controller);
129 return ret; 130 return ret;
130 } 131 }
131 132
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c
index dc899eb2b861..9b9b9f5b016e 100644
--- a/drivers/usb/host/ehci-sh.c
+++ b/drivers/usb/host/ehci-sh.c
@@ -151,6 +151,7 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
151 dev_err(&pdev->dev, "Failed to add hcd"); 151 dev_err(&pdev->dev, "Failed to add hcd");
152 goto fail_add_hcd; 152 goto fail_add_hcd;
153 } 153 }
154 device_wakeup_enable(hcd->self.controller);
154 155
155 priv->hcd = hcd; 156 priv->hcd = hcd;
156 platform_set_drvdata(pdev, priv); 157 platform_set_drvdata(pdev, priv);
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index ee6f9ffaa0e7..8bd915b2ae8c 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -130,6 +130,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
130 if (retval) 130 if (retval)
131 goto err_stop_ehci; 131 goto err_stop_ehci;
132 132
133 device_wakeup_enable(hcd->self.controller);
133 return retval; 134 return retval;
134 135
135err_stop_ehci: 136err_stop_ehci:
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index b9fd0396011e..a8f4471dae7b 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -455,6 +455,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
455 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 455 dev_err(&pdev->dev, "Failed to add USB HCD\n");
456 goto cleanup_otg_set_host; 456 goto cleanup_otg_set_host;
457 } 457 }
458 device_wakeup_enable(hcd->self.controller);
458 459
459 return err; 460 return err;
460 461
diff --git a/drivers/usb/host/ehci-tilegx.c b/drivers/usb/host/ehci-tilegx.c
index 67026ffbf9a8..f3713d32c9a1 100644
--- a/drivers/usb/host/ehci-tilegx.c
+++ b/drivers/usb/host/ehci-tilegx.c
@@ -170,6 +170,7 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
170 ret = usb_add_hcd(hcd, pdata->irq, IRQF_SHARED); 170 ret = usb_add_hcd(hcd, pdata->irq, IRQF_SHARED);
171 if (ret == 0) { 171 if (ret == 0) {
172 platform_set_drvdata(pdev, hcd); 172 platform_set_drvdata(pdev, hcd);
173 device_wakeup_enable(hcd->self.controller);
173 return ret; 174 return ret;
174 } 175 }
175 176
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c
index cdad8438c02b..12c1a563c3f2 100644
--- a/drivers/usb/host/ehci-w90x900.c
+++ b/drivers/usb/host/ehci-w90x900.c
@@ -94,6 +94,7 @@ static int usb_w90x900_probe(const struct hc_driver *driver,
94 if (retval != 0) 94 if (retval != 0)
95 goto err4; 95 goto err4;
96 96
97 device_wakeup_enable(hcd->self.controller);
97 return retval; 98 return retval;
98err4: 99err4:
99 iounmap(hcd->regs); 100 iounmap(hcd->regs);
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c
index 95979f9f4381..3cd2efa4e678 100644
--- a/drivers/usb/host/ehci-xilinx-of.c
+++ b/drivers/usb/host/ehci-xilinx-of.c
@@ -191,8 +191,10 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
191 ehci->caps = hcd->regs + 0x100; 191 ehci->caps = hcd->regs + 0x100;
192 192
193 rv = usb_add_hcd(hcd, irq, 0); 193 rv = usb_add_hcd(hcd, irq, 0);
194 if (rv == 0) 194 if (rv == 0) {
195 device_wakeup_enable(hcd->self.controller);
195 return 0; 196 return 0;
197 }
196 198
197err_irq: 199err_irq:
198 usb_put_hcd(hcd); 200 usb_put_hcd(hcd);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index e8f41c5e771b..c35a6e2b94e5 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -38,7 +38,7 @@ typedef __u16 __bitwise __hc16;
38#endif 38#endif
39 39
40/* statistics can be kept for tuning/monitoring */ 40/* statistics can be kept for tuning/monitoring */
41#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 41#ifdef CONFIG_DYNAMIC_DEBUG
42#define EHCI_STATS 42#define EHCI_STATS
43#endif 43#endif
44 44
@@ -248,7 +248,7 @@ struct ehci_hcd { /* one per controller */
248#endif 248#endif
249 249
250 /* debug files */ 250 /* debug files */
251#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 251#ifdef CONFIG_DYNAMIC_DEBUG
252 struct dentry *debug_dir; 252 struct dentry *debug_dir;
253#endif 253#endif
254 254
@@ -832,9 +832,9 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x)
832 dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args) 832 dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args)
833 833
834 834
835#if !defined(DEBUG) && !defined(CONFIG_DYNAMIC_DEBUG) 835#ifndef CONFIG_DYNAMIC_DEBUG
836#define STUB_DEBUG_FILES 836#define STUB_DEBUG_FILES
837#endif /* !DEBUG && !CONFIG_DYNAMIC_DEBUG */ 837#endif
838 838
839/*-------------------------------------------------------------------------*/ 839/*-------------------------------------------------------------------------*/
840 840
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 0551c0af0fd1..1cf68eaf2ed8 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -754,6 +754,8 @@ static int of_fhci_probe(struct platform_device *ofdev)
754 if (ret < 0) 754 if (ret < 0)
755 goto err_add_hcd; 755 goto err_add_hcd;
756 756
757 device_wakeup_enable(hcd->self.controller);
758
757 fhci_dfs_create(fhci); 759 fhci_dfs_create(fhci);
758 760
759 return 0; 761 return 0;
diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index 55486bd23cf1..98a89d16cc3e 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -56,12 +56,9 @@
56 56
57static const char hcd_name[] = "fotg210_hcd"; 57static const char hcd_name[] = "fotg210_hcd";
58 58
59#undef VERBOSE_DEBUG
60#undef FOTG210_URB_TRACE 59#undef FOTG210_URB_TRACE
61 60
62#ifdef DEBUG
63#define FOTG210_STATS 61#define FOTG210_STATS
64#endif
65 62
66/* magic numbers that can affect system performance */ 63/* magic numbers that can affect system performance */
67#define FOTG210_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */ 64#define FOTG210_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
@@ -107,14 +104,6 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
107#define fotg210_warn(fotg210, fmt, args...) \ 104#define fotg210_warn(fotg210, fmt, args...) \
108 dev_warn(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) 105 dev_warn(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args)
109 106
110#ifdef VERBOSE_DEBUG
111# define fotg210_vdbg fotg210_dbg
112#else
113 static inline void fotg210_vdbg(struct fotg210_hcd *fotg210, ...) {}
114#endif
115
116#ifdef DEBUG
117
118/* check the values in the HCSPARAMS register 107/* check the values in the HCSPARAMS register
119 * (host controller _Structural_ parameters) 108 * (host controller _Structural_ parameters)
120 * see EHCI spec, Table 2-4 for each value 109 * see EHCI spec, Table 2-4 for each value
@@ -129,13 +118,6 @@ static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label)
129 HCS_N_PORTS(params) 118 HCS_N_PORTS(params)
130 ); 119 );
131} 120}
132#else
133
134static inline void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label) {}
135
136#endif
137
138#ifdef DEBUG
139 121
140/* check the values in the HCCPARAMS register 122/* check the values in the HCCPARAMS register
141 * (host controller _Capability_ parameters) 123 * (host controller _Capability_ parameters)
@@ -152,13 +134,6 @@ static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label)
152 HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024", 134 HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
153 HCC_CANPARK(params) ? " park" : ""); 135 HCC_CANPARK(params) ? " park" : "");
154} 136}
155#else
156
157static inline void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label) {}
158
159#endif
160
161#ifdef DEBUG
162 137
163static void __maybe_unused 138static void __maybe_unused
164dbg_qtd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd) 139dbg_qtd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd)
@@ -272,8 +247,8 @@ dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
272 ); 247 );
273} 248}
274 249
275static int 250static char
276dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status) 251*dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
277{ 252{
278 char *sig; 253 char *sig;
279 254
@@ -293,7 +268,7 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
293 break; 268 break;
294 } 269 }
295 270
296 return scnprintf(buf, len, 271 scnprintf(buf, len,
297 "%s%sport:%d status %06x %d " 272 "%s%sport:%d status %06x %d "
298 "sig=%s%s%s%s%s%s%s%s", 273 "sig=%s%s%s%s%s%s%s%s",
299 label, label[0] ? " " : "", port, status, 274 label, label[0] ? " " : "", port, status,
@@ -306,31 +281,9 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
306 (status & PORT_PE) ? " PE" : "", 281 (status & PORT_PE) ? " PE" : "",
307 (status & PORT_CSC) ? " CSC" : "", 282 (status & PORT_CSC) ? " CSC" : "",
308 (status & PORT_CONNECT) ? " CONNECT" : ""); 283 (status & PORT_CONNECT) ? " CONNECT" : "");
284 return buf;
309} 285}
310 286
311#else
312static inline void __maybe_unused
313dbg_qh(char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
314{}
315
316static inline int __maybe_unused
317dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
318{ return 0; }
319
320static inline int __maybe_unused
321dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
322{ return 0; }
323
324static inline int __maybe_unused
325dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
326{ return 0; }
327
328static inline int __maybe_unused
329dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
330{ return 0; }
331
332#endif /* DEBUG */
333
334/* functions have the "wrong" filename when they're output... */ 287/* functions have the "wrong" filename when they're output... */
335#define dbg_status(fotg210, label, status) { \ 288#define dbg_status(fotg210, label, status) { \
336 char _buf[80]; \ 289 char _buf[80]; \
@@ -346,19 +299,11 @@ dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
346 299
347#define dbg_port(fotg210, label, port, status) { \ 300#define dbg_port(fotg210, label, port, status) { \
348 char _buf[80]; \ 301 char _buf[80]; \
349 dbg_port_buf(_buf, sizeof(_buf), label, port, status); \ 302 fotg210_dbg(fotg210, "%s\n", dbg_port_buf(_buf, sizeof(_buf), label, port, status) ); \
350 fotg210_dbg(fotg210, "%s\n", _buf); \
351} 303}
352 304
353/*-------------------------------------------------------------------------*/ 305/*-------------------------------------------------------------------------*/
354 306
355#ifdef STUB_DEBUG_FILES
356
357static inline void create_debug_files(struct fotg210_hcd *bus) { }
358static inline void remove_debug_files(struct fotg210_hcd *bus) { }
359
360#else
361
362/* troubleshooting help: expose state in debugfs */ 307/* troubleshooting help: expose state in debugfs */
363 308
364static int debug_async_open(struct inode *, struct file *); 309static int debug_async_open(struct inode *, struct file *);
@@ -954,7 +899,6 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210)
954 debugfs_remove_recursive(fotg210->debug_dir); 899 debugfs_remove_recursive(fotg210->debug_dir);
955} 900}
956 901
957#endif /* STUB_DEBUG_FILES */
958/*-------------------------------------------------------------------------*/ 902/*-------------------------------------------------------------------------*/
959 903
960/* 904/*
@@ -1398,7 +1342,7 @@ static void fotg210_iaa_watchdog(struct fotg210_hcd *fotg210)
1398 &fotg210->regs->status); 1342 &fotg210->regs->status);
1399 } 1343 }
1400 1344
1401 fotg210_vdbg(fotg210, "IAA watchdog: status %x cmd %x\n", 1345 fotg210_dbg(fotg210, "IAA watchdog: status %x cmd %x\n",
1402 status, cmd); 1346 status, cmd);
1403 end_unlink_async(fotg210); 1347 end_unlink_async(fotg210);
1404 } 1348 }
@@ -1810,10 +1754,8 @@ static int fotg210_hub_control(
1810 if (test_bit(wIndex, &fotg210->port_c_suspend)) 1754 if (test_bit(wIndex, &fotg210->port_c_suspend))
1811 status |= USB_PORT_STAT_C_SUSPEND << 16; 1755 status |= USB_PORT_STAT_C_SUSPEND << 16;
1812 1756
1813#ifndef VERBOSE_DEBUG 1757 if (status & ~0xffff) /* only if wPortChange is interesting */
1814 if (status & ~0xffff) /* only if wPortChange is interesting */ 1758 dbg_port(fotg210, "GetStatus", wIndex + 1, temp);
1815#endif
1816 dbg_port(fotg210, "GetStatus", wIndex + 1, temp);
1817 put_unaligned_le32(status, buf); 1759 put_unaligned_le32(status, buf);
1818 break; 1760 break;
1819 case SetHubFeature: 1761 case SetHubFeature:
@@ -1856,7 +1798,7 @@ static int fotg210_hub_control(
1856 * which can be fine if this root hub has a 1798 * which can be fine if this root hub has a
1857 * transaction translator built in. 1799 * transaction translator built in.
1858 */ 1800 */
1859 fotg210_vdbg(fotg210, "port %d reset\n", wIndex + 1); 1801 fotg210_dbg(fotg210, "port %d reset\n", wIndex + 1);
1860 temp |= PORT_RESET; 1802 temp |= PORT_RESET;
1861 temp &= ~PORT_PE; 1803 temp &= ~PORT_PE;
1862 1804
@@ -2274,13 +2216,12 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
2274 * Note: this routine is never called for Isochronous transfers. 2216 * Note: this routine is never called for Isochronous transfers.
2275 */ 2217 */
2276 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { 2218 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
2277#ifdef DEBUG
2278 struct usb_device *tt = urb->dev->tt->hub; 2219 struct usb_device *tt = urb->dev->tt->hub;
2279 dev_dbg(&tt->dev, 2220 dev_dbg(&tt->dev,
2280 "clear tt buffer port %d, a%d ep%d t%08x\n", 2221 "clear tt buffer port %d, a%d ep%d t%08x\n",
2281 urb->dev->ttport, urb->dev->devnum, 2222 urb->dev->ttport, urb->dev->devnum,
2282 usb_pipeendpoint(urb->pipe), token); 2223 usb_pipeendpoint(urb->pipe), token);
2283#endif /* DEBUG */ 2224
2284 if (urb->dev->tt->hub != 2225 if (urb->dev->tt->hub !=
2285 fotg210_to_hcd(fotg210)->self.root_hub) { 2226 fotg210_to_hcd(fotg210)->self.root_hub) {
2286 if (usb_hub_clear_tt_buffer(urb) == 0) 2227 if (usb_hub_clear_tt_buffer(urb) == 0)
@@ -2341,7 +2282,7 @@ static int qtd_copy_status(
2341 status = -EPROTO; 2282 status = -EPROTO;
2342 } 2283 }
2343 2284
2344 fotg210_vdbg(fotg210, 2285 fotg210_dbg(fotg210,
2345 "dev%d ep%d%s qtd token %08x --> status %d\n", 2286 "dev%d ep%d%s qtd token %08x --> status %d\n",
2346 usb_pipedevice(urb->pipe), 2287 usb_pipedevice(urb->pipe),
2347 usb_pipeendpoint(urb->pipe), 2288 usb_pipeendpoint(urb->pipe),
@@ -3583,11 +3524,9 @@ periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe)
3583 break; 3524 break;
3584 } 3525 }
3585 } 3526 }
3586#ifdef DEBUG
3587 if (usecs > fotg210->uframe_periodic_max) 3527 if (usecs > fotg210->uframe_periodic_max)
3588 fotg210_err(fotg210, "uframe %d sched overrun: %d usecs\n", 3528 fotg210_err(fotg210, "uframe %d sched overrun: %d usecs\n",
3589 frame * 8 + uframe, usecs); 3529 frame * 8 + uframe, usecs);
3590#endif
3591 return usecs; 3530 return usecs;
3592} 3531}
3593 3532
@@ -4646,7 +4585,7 @@ static void itd_link_urb(
4646 if (unlikely(list_empty(&stream->td_list))) { 4585 if (unlikely(list_empty(&stream->td_list))) {
4647 fotg210_to_hcd(fotg210)->self.bandwidth_allocated 4586 fotg210_to_hcd(fotg210)->self.bandwidth_allocated
4648 += stream->bandwidth; 4587 += stream->bandwidth;
4649 fotg210_vdbg(fotg210, 4588 fotg210_dbg(fotg210,
4650 "schedule devp %s ep%d%s-iso period %d start %d.%d\n", 4589 "schedule devp %s ep%d%s-iso period %d start %d.%d\n",
4651 urb->dev->devpath, stream->bEndpointAddress & 0x0f, 4590 urb->dev->devpath, stream->bEndpointAddress & 0x0f,
4652 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", 4591 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out",
@@ -4779,7 +4718,7 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
4779 if (unlikely(list_is_singular(&stream->td_list))) { 4718 if (unlikely(list_is_singular(&stream->td_list))) {
4780 fotg210_to_hcd(fotg210)->self.bandwidth_allocated 4719 fotg210_to_hcd(fotg210)->self.bandwidth_allocated
4781 -= stream->bandwidth; 4720 -= stream->bandwidth;
4782 fotg210_vdbg(fotg210, 4721 fotg210_dbg(fotg210,
4783 "deschedule devp %s ep%d%s-iso\n", 4722 "deschedule devp %s ep%d%s-iso\n",
4784 dev->devpath, stream->bEndpointAddress & 0x0f, 4723 dev->devpath, stream->bEndpointAddress & 0x0f,
4785 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); 4724 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");
@@ -5444,10 +5383,8 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
5444 cmd = fotg210_readl(fotg210, &fotg210->regs->command); 5383 cmd = fotg210_readl(fotg210, &fotg210->regs->command);
5445 bh = 0; 5384 bh = 0;
5446 5385
5447#ifdef VERBOSE_DEBUG
5448 /* unrequested/ignored: Frame List Rollover */ 5386 /* unrequested/ignored: Frame List Rollover */
5449 dbg_status(fotg210, "irq", status); 5387 dbg_status(fotg210, "irq", status);
5450#endif
5451 5388
5452 /* INT, ERR, and IAA interrupt rates can be throttled */ 5389 /* INT, ERR, and IAA interrupt rates can be throttled */
5453 5390
@@ -5952,6 +5889,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
5952 dev_err(dev, "failed to add hcd with err %d\n", retval); 5889 dev_err(dev, "failed to add hcd with err %d\n", retval);
5953 goto fail_add_hcd; 5890 goto fail_add_hcd;
5954 } 5891 }
5892 device_wakeup_enable(hcd->self.controller);
5955 5893
5956 return retval; 5894 return retval;
5957 5895
@@ -6013,13 +5951,11 @@ static int __init fotg210_hcd_init(void)
6013 sizeof(struct fotg210_qh), sizeof(struct fotg210_qtd), 5951 sizeof(struct fotg210_qh), sizeof(struct fotg210_qtd),
6014 sizeof(struct fotg210_itd)); 5952 sizeof(struct fotg210_itd));
6015 5953
6016#ifdef DEBUG
6017 fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root); 5954 fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root);
6018 if (!fotg210_debug_root) { 5955 if (!fotg210_debug_root) {
6019 retval = -ENOENT; 5956 retval = -ENOENT;
6020 goto err_debug; 5957 goto err_debug;
6021 } 5958 }
6022#endif
6023 5959
6024 retval = platform_driver_register(&fotg210_hcd_driver); 5960 retval = platform_driver_register(&fotg210_hcd_driver);
6025 if (retval < 0) 5961 if (retval < 0)
@@ -6028,11 +5964,9 @@ static int __init fotg210_hcd_init(void)
6028 5964
6029 platform_driver_unregister(&fotg210_hcd_driver); 5965 platform_driver_unregister(&fotg210_hcd_driver);
6030clean: 5966clean:
6031#ifdef DEBUG
6032 debugfs_remove(fotg210_debug_root); 5967 debugfs_remove(fotg210_debug_root);
6033 fotg210_debug_root = NULL; 5968 fotg210_debug_root = NULL;
6034err_debug: 5969err_debug:
6035#endif
6036 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 5970 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
6037 return retval; 5971 return retval;
6038} 5972}
@@ -6041,9 +5975,7 @@ module_init(fotg210_hcd_init);
6041static void __exit fotg210_hcd_cleanup(void) 5975static void __exit fotg210_hcd_cleanup(void)
6042{ 5976{
6043 platform_driver_unregister(&fotg210_hcd_driver); 5977 platform_driver_unregister(&fotg210_hcd_driver);
6044#ifdef DEBUG
6045 debugfs_remove(fotg210_debug_root); 5978 debugfs_remove(fotg210_debug_root);
6046#endif
6047 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 5979 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
6048} 5980}
6049module_exit(fotg210_hcd_cleanup); 5981module_exit(fotg210_hcd_cleanup);
diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
index 8920f9d32564..ac6cd1bfd208 100644
--- a/drivers/usb/host/fotg210.h
+++ b/drivers/usb/host/fotg210.h
@@ -174,9 +174,7 @@ struct fotg210_hcd { /* one per controller */
174#endif 174#endif
175 175
176 /* debug files */ 176 /* debug files */
177#ifdef DEBUG
178 struct dentry *debug_dir; 177 struct dentry *debug_dir;
179#endif
180}; 178};
181 179
182/* convert between an HCD pointer and the corresponding FOTG210_HCD */ 180/* convert between an HCD pointer and the corresponding FOTG210_HCD */
@@ -741,10 +739,4 @@ static inline unsigned fotg210_read_frame_index(struct fotg210_hcd *fotg210)
741}) 739})
742/*-------------------------------------------------------------------------*/ 740/*-------------------------------------------------------------------------*/
743 741
744#ifndef DEBUG
745#define STUB_DEBUG_FILES
746#endif /* DEBUG */
747
748/*-------------------------------------------------------------------------*/
749
750#endif /* __LINUX_FOTG210_H */ 742#endif /* __LINUX_FOTG210_H */
diff --git a/drivers/usb/host/fusbh200-hcd.c b/drivers/usb/host/fusbh200-hcd.c
index e1c6d850a7e1..ba9499060f63 100644
--- a/drivers/usb/host/fusbh200-hcd.c
+++ b/drivers/usb/host/fusbh200-hcd.c
@@ -57,13 +57,8 @@
57 57
58static const char hcd_name [] = "fusbh200_hcd"; 58static const char hcd_name [] = "fusbh200_hcd";
59 59
60#undef VERBOSE_DEBUG
61#undef FUSBH200_URB_TRACE 60#undef FUSBH200_URB_TRACE
62 61
63#ifdef DEBUG
64#define FUSBH200_STATS
65#endif
66
67/* magic numbers that can affect system performance */ 62/* magic numbers that can affect system performance */
68#define FUSBH200_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */ 63#define FUSBH200_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
69#define FUSBH200_TUNE_RL_HS 4 /* nak throttle; see 4.9 */ 64#define FUSBH200_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
@@ -108,14 +103,6 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
108#define fusbh200_warn(fusbh200, fmt, args...) \ 103#define fusbh200_warn(fusbh200, fmt, args...) \
109 dev_warn (fusbh200_to_hcd(fusbh200)->self.controller , fmt , ## args ) 104 dev_warn (fusbh200_to_hcd(fusbh200)->self.controller , fmt , ## args )
110 105
111#ifdef VERBOSE_DEBUG
112# define fusbh200_vdbg fusbh200_dbg
113#else
114 static inline void fusbh200_vdbg(struct fusbh200_hcd *fusbh200, ...) {}
115#endif
116
117#ifdef DEBUG
118
119/* check the values in the HCSPARAMS register 106/* check the values in the HCSPARAMS register
120 * (host controller _Structural_ parameters) 107 * (host controller _Structural_ parameters)
121 * see EHCI spec, Table 2-4 for each value 108 * see EHCI spec, Table 2-4 for each value
@@ -130,13 +117,6 @@ static void dbg_hcs_params (struct fusbh200_hcd *fusbh200, char *label)
130 HCS_N_PORTS (params) 117 HCS_N_PORTS (params)
131 ); 118 );
132} 119}
133#else
134
135static inline void dbg_hcs_params (struct fusbh200_hcd *fusbh200, char *label) {}
136
137#endif
138
139#ifdef DEBUG
140 120
141/* check the values in the HCCPARAMS register 121/* check the values in the HCCPARAMS register
142 * (host controller _Capability_ parameters) 122 * (host controller _Capability_ parameters)
@@ -153,13 +133,6 @@ static void dbg_hcc_params (struct fusbh200_hcd *fusbh200, char *label)
153 HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024", 133 HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
154 HCC_CANPARK(params) ? " park" : ""); 134 HCC_CANPARK(params) ? " park" : "");
155} 135}
156#else
157
158static inline void dbg_hcc_params (struct fusbh200_hcd *fusbh200, char *label) {}
159
160#endif
161
162#ifdef DEBUG
163 136
164static void __maybe_unused 137static void __maybe_unused
165dbg_qtd (const char *label, struct fusbh200_hcd *fusbh200, struct fusbh200_qtd *qtd) 138dbg_qtd (const char *label, struct fusbh200_hcd *fusbh200, struct fusbh200_qtd *qtd)
@@ -302,29 +275,6 @@ dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
302 (status & PORT_CONNECT) ? " CONNECT" : ""); 275 (status & PORT_CONNECT) ? " CONNECT" : "");
303} 276}
304 277
305#else
306static inline void __maybe_unused
307dbg_qh (char *label, struct fusbh200_hcd *fusbh200, struct fusbh200_qh *qh)
308{}
309
310static inline int __maybe_unused
311dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
312{ return 0; }
313
314static inline int __maybe_unused
315dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
316{ return 0; }
317
318static inline int __maybe_unused
319dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
320{ return 0; }
321
322static inline int __maybe_unused
323dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
324{ return 0; }
325
326#endif /* DEBUG */
327
328/* functions have the "wrong" filename when they're output... */ 278/* functions have the "wrong" filename when they're output... */
329#define dbg_status(fusbh200, label, status) { \ 279#define dbg_status(fusbh200, label, status) { \
330 char _buf [80]; \ 280 char _buf [80]; \
@@ -346,13 +296,6 @@ dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
346 296
347/*-------------------------------------------------------------------------*/ 297/*-------------------------------------------------------------------------*/
348 298
349#ifdef STUB_DEBUG_FILES
350
351static inline void create_debug_files (struct fusbh200_hcd *bus) { }
352static inline void remove_debug_files (struct fusbh200_hcd *bus) { }
353
354#else
355
356/* troubleshooting help: expose state in debugfs */ 299/* troubleshooting help: expose state in debugfs */
357 300
358static int debug_async_open(struct inode *, struct file *); 301static int debug_async_open(struct inode *, struct file *);
@@ -775,7 +718,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
775 next += temp; 718 next += temp;
776 } 719 }
777 720
778#ifdef FUSBH200_STATS
779 temp = scnprintf (next, size, 721 temp = scnprintf (next, size,
780 "irq normal %ld err %ld iaa %ld (lost %ld)\n", 722 "irq normal %ld err %ld iaa %ld (lost %ld)\n",
781 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa, 723 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa,
@@ -787,7 +729,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
787 fusbh200->stats.complete, fusbh200->stats.unlink); 729 fusbh200->stats.complete, fusbh200->stats.unlink);
788 size -= temp; 730 size -= temp;
789 next += temp; 731 next += temp;
790#endif
791 732
792done: 733done:
793 spin_unlock_irqrestore (&fusbh200->lock, flags); 734 spin_unlock_irqrestore (&fusbh200->lock, flags);
@@ -928,7 +869,6 @@ static inline void remove_debug_files (struct fusbh200_hcd *fusbh200)
928 debugfs_remove_recursive(fusbh200->debug_dir); 869 debugfs_remove_recursive(fusbh200->debug_dir);
929} 870}
930 871
931#endif /* STUB_DEBUG_FILES */
932/*-------------------------------------------------------------------------*/ 872/*-------------------------------------------------------------------------*/
933 873
934/* 874/*
@@ -1362,7 +1302,7 @@ static void fusbh200_iaa_watchdog(struct fusbh200_hcd *fusbh200)
1362 fusbh200_writel(fusbh200, STS_IAA, &fusbh200->regs->status); 1302 fusbh200_writel(fusbh200, STS_IAA, &fusbh200->regs->status);
1363 } 1303 }
1364 1304
1365 fusbh200_vdbg(fusbh200, "IAA watchdog: status %x cmd %x\n", 1305 fusbh200_dbg(fusbh200, "IAA watchdog: status %x cmd %x\n",
1366 status, cmd); 1306 status, cmd);
1367 end_unlink_async(fusbh200); 1307 end_unlink_async(fusbh200);
1368 } 1308 }
@@ -1769,10 +1709,8 @@ static int fusbh200_hub_control (
1769 if (test_bit(wIndex, &fusbh200->port_c_suspend)) 1709 if (test_bit(wIndex, &fusbh200->port_c_suspend))
1770 status |= USB_PORT_STAT_C_SUSPEND << 16; 1710 status |= USB_PORT_STAT_C_SUSPEND << 16;
1771 1711
1772#ifndef VERBOSE_DEBUG 1712 if (status & ~0xffff) /* only if wPortChange is interesting */
1773 if (status & ~0xffff) /* only if wPortChange is interesting */ 1713 dbg_port(fusbh200, "GetStatus", wIndex + 1, temp);
1774#endif
1775 dbg_port (fusbh200, "GetStatus", wIndex + 1, temp);
1776 put_unaligned_le32(status, buf); 1714 put_unaligned_le32(status, buf);
1777 break; 1715 break;
1778 case SetHubFeature: 1716 case SetHubFeature:
@@ -1814,7 +1752,7 @@ static int fusbh200_hub_control (
1814 * which can be fine if this root hub has a 1752 * which can be fine if this root hub has a
1815 * transaction translator built in. 1753 * transaction translator built in.
1816 */ 1754 */
1817 fusbh200_vdbg (fusbh200, "port %d reset\n", wIndex + 1); 1755 fusbh200_dbg(fusbh200, "port %d reset\n", wIndex + 1);
1818 temp |= PORT_RESET; 1756 temp |= PORT_RESET;
1819 temp &= ~PORT_PE; 1757 temp &= ~PORT_PE;
1820 1758
@@ -2230,13 +2168,13 @@ static void fusbh200_clear_tt_buffer(struct fusbh200_hcd *fusbh200, struct fusbh
2230 * Note: this routine is never called for Isochronous transfers. 2168 * Note: this routine is never called for Isochronous transfers.
2231 */ 2169 */
2232 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { 2170 if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
2233#ifdef DEBUG
2234 struct usb_device *tt = urb->dev->tt->hub; 2171 struct usb_device *tt = urb->dev->tt->hub;
2172
2235 dev_dbg(&tt->dev, 2173 dev_dbg(&tt->dev,
2236 "clear tt buffer port %d, a%d ep%d t%08x\n", 2174 "clear tt buffer port %d, a%d ep%d t%08x\n",
2237 urb->dev->ttport, urb->dev->devnum, 2175 urb->dev->ttport, urb->dev->devnum,
2238 usb_pipeendpoint(urb->pipe), token); 2176 usb_pipeendpoint(urb->pipe), token);
2239#endif /* DEBUG */ 2177
2240 if (urb->dev->tt->hub != 2178 if (urb->dev->tt->hub !=
2241 fusbh200_to_hcd(fusbh200)->self.root_hub) { 2179 fusbh200_to_hcd(fusbh200)->self.root_hub) {
2242 if (usb_hub_clear_tt_buffer(urb) == 0) 2180 if (usb_hub_clear_tt_buffer(urb) == 0)
@@ -2297,7 +2235,7 @@ static int qtd_copy_status (
2297 status = -EPROTO; 2235 status = -EPROTO;
2298 } 2236 }
2299 2237
2300 fusbh200_vdbg (fusbh200, 2238 fusbh200_dbg(fusbh200,
2301 "dev%d ep%d%s qtd token %08x --> status %d\n", 2239 "dev%d ep%d%s qtd token %08x --> status %d\n",
2302 usb_pipedevice (urb->pipe), 2240 usb_pipedevice (urb->pipe),
2303 usb_pipeendpoint (urb->pipe), 2241 usb_pipeendpoint (urb->pipe),
@@ -3529,11 +3467,9 @@ periodic_usecs (struct fusbh200_hcd *fusbh200, unsigned frame, unsigned uframe)
3529 break; 3467 break;
3530 } 3468 }
3531 } 3469 }
3532#ifdef DEBUG
3533 if (usecs > fusbh200->uframe_periodic_max) 3470 if (usecs > fusbh200->uframe_periodic_max)
3534 fusbh200_err (fusbh200, "uframe %d sched overrun: %d usecs\n", 3471 fusbh200_err (fusbh200, "uframe %d sched overrun: %d usecs\n",
3535 frame * 8 + uframe, usecs); 3472 frame * 8 + uframe, usecs);
3536#endif
3537 return usecs; 3473 return usecs;
3538} 3474}
3539 3475
@@ -4586,7 +4522,7 @@ static void itd_link_urb(
4586 if (unlikely (list_empty(&stream->td_list))) { 4522 if (unlikely (list_empty(&stream->td_list))) {
4587 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated 4523 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated
4588 += stream->bandwidth; 4524 += stream->bandwidth;
4589 fusbh200_vdbg (fusbh200, 4525 fusbh200_dbg(fusbh200,
4590 "schedule devp %s ep%d%s-iso period %d start %d.%d\n", 4526 "schedule devp %s ep%d%s-iso period %d start %d.%d\n",
4591 urb->dev->devpath, stream->bEndpointAddress & 0x0f, 4527 urb->dev->devpath, stream->bEndpointAddress & 0x0f,
4592 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out", 4528 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out",
@@ -4717,7 +4653,7 @@ static bool itd_complete(struct fusbh200_hcd *fusbh200, struct fusbh200_itd *itd
4717 if (unlikely(list_is_singular(&stream->td_list))) { 4653 if (unlikely(list_is_singular(&stream->td_list))) {
4718 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated 4654 fusbh200_to_hcd(fusbh200)->self.bandwidth_allocated
4719 -= stream->bandwidth; 4655 -= stream->bandwidth;
4720 fusbh200_vdbg (fusbh200, 4656 fusbh200_dbg(fusbh200,
4721 "deschedule devp %s ep%d%s-iso\n", 4657 "deschedule devp %s ep%d%s-iso\n",
4722 dev->devpath, stream->bEndpointAddress & 0x0f, 4658 dev->devpath, stream->bEndpointAddress & 0x0f,
4723 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); 4659 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");
@@ -5115,13 +5051,11 @@ static void fusbh200_stop (struct usb_hcd *hcd)
5115 spin_unlock_irq (&fusbh200->lock); 5051 spin_unlock_irq (&fusbh200->lock);
5116 fusbh200_mem_cleanup (fusbh200); 5052 fusbh200_mem_cleanup (fusbh200);
5117 5053
5118#ifdef FUSBH200_STATS
5119 fusbh200_dbg(fusbh200, "irq normal %ld err %ld iaa %ld (lost %ld)\n", 5054 fusbh200_dbg(fusbh200, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
5120 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa, 5055 fusbh200->stats.normal, fusbh200->stats.error, fusbh200->stats.iaa,
5121 fusbh200->stats.lost_iaa); 5056 fusbh200->stats.lost_iaa);
5122 fusbh200_dbg (fusbh200, "complete %ld unlink %ld\n", 5057 fusbh200_dbg (fusbh200, "complete %ld unlink %ld\n",
5123 fusbh200->stats.complete, fusbh200->stats.unlink); 5058 fusbh200->stats.complete, fusbh200->stats.unlink);
5124#endif
5125 5059
5126 dbg_status (fusbh200, "fusbh200_stop completed", 5060 dbg_status (fusbh200, "fusbh200_stop completed",
5127 fusbh200_readl(fusbh200, &fusbh200->regs->status)); 5061 fusbh200_readl(fusbh200, &fusbh200->regs->status));
@@ -5365,13 +5299,6 @@ static irqreturn_t fusbh200_irq (struct usb_hcd *hcd)
5365 cmd = fusbh200_readl(fusbh200, &fusbh200->regs->command); 5299 cmd = fusbh200_readl(fusbh200, &fusbh200->regs->command);
5366 bh = 0; 5300 bh = 0;
5367 5301
5368#ifdef VERBOSE_DEBUG
5369 /* unrequested/ignored: Frame List Rollover */
5370 dbg_status (fusbh200, "irq", status);
5371#endif
5372
5373 /* INT, ERR, and IAA interrupt rates can be throttled */
5374
5375 /* normal [4.15.1.2] or error [4.15.1.1] completion */ 5302 /* normal [4.15.1.2] or error [4.15.1.1] completion */
5376 if (likely ((status & (STS_INT|STS_ERR)) != 0)) { 5303 if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
5377 if (likely ((status & STS_ERR) == 0)) 5304 if (likely ((status & STS_ERR) == 0))
@@ -5871,6 +5798,7 @@ static int fusbh200_hcd_probe(struct platform_device *pdev)
5871 dev_err(dev, "failed to add hcd with err %d\n", retval); 5798 dev_err(dev, "failed to add hcd with err %d\n", retval);
5872 goto fail_add_hcd; 5799 goto fail_add_hcd;
5873 } 5800 }
5801 device_wakeup_enable(hcd->self.controller);
5874 5802
5875 return retval; 5803 return retval;
5876 5804
@@ -5936,13 +5864,11 @@ static int __init fusbh200_hcd_init(void)
5936 sizeof(struct fusbh200_qh), sizeof(struct fusbh200_qtd), 5864 sizeof(struct fusbh200_qh), sizeof(struct fusbh200_qtd),
5937 sizeof(struct fusbh200_itd)); 5865 sizeof(struct fusbh200_itd));
5938 5866
5939#ifdef DEBUG
5940 fusbh200_debug_root = debugfs_create_dir("fusbh200", usb_debug_root); 5867 fusbh200_debug_root = debugfs_create_dir("fusbh200", usb_debug_root);
5941 if (!fusbh200_debug_root) { 5868 if (!fusbh200_debug_root) {
5942 retval = -ENOENT; 5869 retval = -ENOENT;
5943 goto err_debug; 5870 goto err_debug;
5944 } 5871 }
5945#endif
5946 5872
5947 retval = platform_driver_register(&fusbh200_hcd_fusbh200_driver); 5873 retval = platform_driver_register(&fusbh200_hcd_fusbh200_driver);
5948 if (retval < 0) 5874 if (retval < 0)
@@ -5951,11 +5877,9 @@ static int __init fusbh200_hcd_init(void)
5951 5877
5952 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver); 5878 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver);
5953clean: 5879clean:
5954#ifdef DEBUG
5955 debugfs_remove(fusbh200_debug_root); 5880 debugfs_remove(fusbh200_debug_root);
5956 fusbh200_debug_root = NULL; 5881 fusbh200_debug_root = NULL;
5957err_debug: 5882err_debug:
5958#endif
5959 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 5883 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
5960 return retval; 5884 return retval;
5961} 5885}
@@ -5964,9 +5888,7 @@ module_init(fusbh200_hcd_init);
5964static void __exit fusbh200_hcd_cleanup(void) 5888static void __exit fusbh200_hcd_cleanup(void)
5965{ 5889{
5966 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver); 5890 platform_driver_unregister(&fusbh200_hcd_fusbh200_driver);
5967#ifdef DEBUG
5968 debugfs_remove(fusbh200_debug_root); 5891 debugfs_remove(fusbh200_debug_root);
5969#endif
5970 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); 5892 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
5971} 5893}
5972module_exit(fusbh200_hcd_cleanup); 5894module_exit(fusbh200_hcd_cleanup);
diff --git a/drivers/usb/host/fusbh200.h b/drivers/usb/host/fusbh200.h
index 797c9e855270..6b719e066c3f 100644
--- a/drivers/usb/host/fusbh200.h
+++ b/drivers/usb/host/fusbh200.h
@@ -165,17 +165,11 @@ struct fusbh200_hcd { /* one per controller */
165 u8 sbrn; /* packed release number */ 165 u8 sbrn; /* packed release number */
166 166
167 /* irq statistics */ 167 /* irq statistics */
168#ifdef FUSBH200_STATS
169 struct fusbh200_stats stats; 168 struct fusbh200_stats stats;
170# define COUNT(x) do { (x)++; } while (0) 169# define COUNT(x) do { (x)++; } while (0)
171#else
172# define COUNT(x) do {} while (0)
173#endif
174 170
175 /* debug files */ 171 /* debug files */
176#ifdef DEBUG
177 struct dentry *debug_dir; 172 struct dentry *debug_dir;
178#endif
179}; 173};
180 174
181/* convert between an HCD pointer and the corresponding FUSBH200_HCD */ 175/* convert between an HCD pointer and the corresponding FUSBH200_HCD */
@@ -734,10 +728,4 @@ static inline unsigned fusbh200_read_frame_index(struct fusbh200_hcd *fusbh200)
734}) 728})
735/*-------------------------------------------------------------------------*/ 729/*-------------------------------------------------------------------------*/
736 730
737#ifndef DEBUG
738#define STUB_DEBUG_FILES
739#endif /* DEBUG */
740
741/*-------------------------------------------------------------------------*/
742
743#endif /* __LINUX_FUSBH200_H */ 731#endif /* __LINUX_FUSBH200_H */
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index ada0a52797b1..f0b97bb08791 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -86,7 +86,7 @@ static int __hwahc_set_cluster_id(struct hwahc *hwahc, u8 cluster_id)
86 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 86 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
87 cluster_id, 87 cluster_id,
88 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber, 88 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
89 NULL, 0, 1000 /* FIXME: arbitrary */); 89 NULL, 0, USB_CTRL_SET_TIMEOUT);
90 if (result < 0) 90 if (result < 0)
91 dev_err(dev, "Cannot set WUSB Cluster ID to 0x%02x: %d\n", 91 dev_err(dev, "Cannot set WUSB Cluster ID to 0x%02x: %d\n",
92 cluster_id, result); 92 cluster_id, result);
@@ -106,7 +106,7 @@ static int __hwahc_op_set_num_dnts(struct wusbhc *wusbhc, u8 interval, u8 slots)
106 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 106 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
107 interval << 8 | slots, 107 interval << 8 | slots,
108 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber, 108 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
109 NULL, 0, 1000 /* FIXME: arbitrary */); 109 NULL, 0, USB_CTRL_SET_TIMEOUT);
110} 110}
111 111
112/* 112/*
@@ -224,7 +224,7 @@ static int hwahc_op_urb_dequeue(struct usb_hcd *usb_hcd, struct urb *urb,
224 struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd); 224 struct wusbhc *wusbhc = usb_hcd_to_wusbhc(usb_hcd);
225 struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc); 225 struct hwahc *hwahc = container_of(wusbhc, struct hwahc, wusbhc);
226 226
227 return wa_urb_dequeue(&hwahc->wa, urb); 227 return wa_urb_dequeue(&hwahc->wa, urb, status);
228} 228}
229 229
230/* 230/*
@@ -281,7 +281,7 @@ static void __hwahc_op_wusbhc_stop(struct wusbhc *wusbhc, int delay)
281 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 281 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
282 delay * 1000, 282 delay * 1000,
283 iface_no, 283 iface_no,
284 NULL, 0, 1000 /* FIXME: arbitrary */); 284 NULL, 0, USB_CTRL_SET_TIMEOUT);
285 if (ret == 0) 285 if (ret == 0)
286 msleep(delay); 286 msleep(delay);
287 287
@@ -310,7 +310,7 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
310 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 310 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
311 stream_index, 311 stream_index,
312 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber, 312 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
313 NULL, 0, 1000 /* FIXME: arbitrary */); 313 NULL, 0, USB_CTRL_SET_TIMEOUT);
314 if (result < 0) { 314 if (result < 0) {
315 dev_err(dev, "Cannot set WUSB stream index: %d\n", result); 315 dev_err(dev, "Cannot set WUSB stream index: %d\n", result);
316 goto out; 316 goto out;
@@ -321,7 +321,7 @@ static int __hwahc_op_bwa_set(struct wusbhc *wusbhc, s8 stream_index,
321 WUSB_REQ_SET_WUSB_MAS, 321 WUSB_REQ_SET_WUSB_MAS,
322 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 322 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
323 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber, 323 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
324 mas_le, 32, 1000 /* FIXME: arbitrary */); 324 mas_le, 32, USB_CTRL_SET_TIMEOUT);
325 if (result < 0) 325 if (result < 0)
326 dev_err(dev, "Cannot set WUSB MAS allocation: %d\n", result); 326 dev_err(dev, "Cannot set WUSB MAS allocation: %d\n", result);
327out: 327out:
@@ -355,7 +355,7 @@ static int __hwahc_op_mmcie_add(struct wusbhc *wusbhc, u8 interval,
355 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 355 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
356 interval << 8 | repeat_cnt, 356 interval << 8 | repeat_cnt,
357 handle << 8 | iface_no, 357 handle << 8 | iface_no,
358 wuie, wuie->bLength, 1000 /* FIXME: arbitrary */); 358 wuie, wuie->bLength, USB_CTRL_SET_TIMEOUT);
359} 359}
360 360
361/* 361/*
@@ -372,7 +372,7 @@ static int __hwahc_op_mmcie_rm(struct wusbhc *wusbhc, u8 handle)
372 WUSB_REQ_REMOVE_MMC_IE, 372 WUSB_REQ_REMOVE_MMC_IE,
373 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 373 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
374 0, handle << 8 | iface_no, 374 0, handle << 8 | iface_no,
375 NULL, 0, 1000 /* FIXME: arbitrary */); 375 NULL, 0, USB_CTRL_SET_TIMEOUT);
376} 376}
377 377
378/* 378/*
@@ -415,7 +415,7 @@ static int __hwahc_op_dev_info_set(struct wusbhc *wusbhc,
415 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 415 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
416 0, wusb_dev->port_idx << 8 | iface_no, 416 0, wusb_dev->port_idx << 8 | iface_no,
417 dev_info, sizeof(struct hwa_dev_info), 417 dev_info, sizeof(struct hwa_dev_info),
418 1000 /* FIXME: arbitrary */); 418 USB_CTRL_SET_TIMEOUT);
419 kfree(dev_info); 419 kfree(dev_info);
420 return ret; 420 return ret;
421} 421}
@@ -455,7 +455,7 @@ static int __hwahc_dev_set_key(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
455 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 455 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
456 USB_DT_KEY << 8 | key_idx, 456 USB_DT_KEY << 8 | key_idx,
457 port_idx << 8 | iface_no, 457 port_idx << 8 | iface_no,
458 keyd, keyd_len, 1000 /* FIXME: arbitrary */); 458 keyd, keyd_len, USB_CTRL_SET_TIMEOUT);
459 459
460 kzfree(keyd); /* clear keys etc. */ 460 kzfree(keyd); /* clear keys etc. */
461 return result; 461 return result;
@@ -497,7 +497,7 @@ static int __hwahc_op_set_ptk(struct wusbhc *wusbhc, u8 port_idx, u32 tkid,
497 USB_REQ_SET_ENCRYPTION, 497 USB_REQ_SET_ENCRYPTION,
498 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 498 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
499 encryption_value, port_idx << 8 | iface_no, 499 encryption_value, port_idx << 8 | iface_no,
500 NULL, 0, 1000 /* FIXME: arbitrary */); 500 NULL, 0, USB_CTRL_SET_TIMEOUT);
501 if (result < 0) 501 if (result < 0)
502 dev_err(wusbhc->dev, "Can't set host's WUSB encryption for " 502 dev_err(wusbhc->dev, "Can't set host's WUSB encryption for "
503 "port index %u to %s (value %d): %d\n", port_idx, 503 "port index %u to %s (value %d): %d\n", port_idx,
@@ -791,6 +791,7 @@ static int hwahc_probe(struct usb_interface *usb_iface,
791 dev_err(dev, "Cannot add HCD: %d\n", result); 791 dev_err(dev, "Cannot add HCD: %d\n", result);
792 goto error_add_hcd; 792 goto error_add_hcd;
793 } 793 }
794 device_wakeup_enable(usb_hcd->self.controller);
794 result = wusbhc_b_create(&hwahc->wusbhc); 795 result = wusbhc_b_create(&hwahc->wusbhc);
795 if (result < 0) { 796 if (result < 0) {
796 dev_err(dev, "Cannot setup phase B of WUSBHC: %d\n", result); 797 dev_err(dev, "Cannot setup phase B of WUSBHC: %d\n", result);
diff --git a/drivers/usb/host/imx21-dbg.c b/drivers/usb/host/imx21-dbg.c
index ec98ecee3517..4f320d050da7 100644
--- a/drivers/usb/host/imx21-dbg.c
+++ b/drivers/usb/host/imx21-dbg.c
@@ -18,6 +18,10 @@
18 18
19/* this file is part of imx21-hcd.c */ 19/* this file is part of imx21-hcd.c */
20 20
21#ifdef CONFIG_DYNAMIC_DEBUG
22#define DEBUG
23#endif
24
21#ifndef DEBUG 25#ifndef DEBUG
22 26
23static inline void create_debug_files(struct imx21 *imx21) { } 27static inline void create_debug_files(struct imx21 *imx21) { }
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index adb01d950a16..207bad99301f 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -62,6 +62,10 @@
62 62
63#include "imx21-hcd.h" 63#include "imx21-hcd.h"
64 64
65#ifdef CONFIG_DYNAMIC_DEBUG
66#define DEBUG
67#endif
68
65#ifdef DEBUG 69#ifdef DEBUG
66#define DEBUG_LOG_FRAME(imx21, etd, event) \ 70#define DEBUG_LOG_FRAME(imx21, etd, event) \
67 (etd)->event##_frame = readl((imx21)->regs + USBH_FRMNUB) 71 (etd)->event##_frame = readl((imx21)->regs + USBH_FRMNUB)
@@ -1906,6 +1910,7 @@ static int imx21_probe(struct platform_device *pdev)
1906 dev_err(imx21->dev, "usb_add_hcd() returned %d\n", ret); 1910 dev_err(imx21->dev, "usb_add_hcd() returned %d\n", ret);
1907 goto failed_add_hcd; 1911 goto failed_add_hcd;
1908 } 1912 }
1913 device_wakeup_enable(hcd->self.controller);
1909 1914
1910 return 0; 1915 return 0;
1911 1916
@@ -1926,7 +1931,7 @@ failed_request_mem:
1926 1931
1927static struct platform_driver imx21_hcd_driver = { 1932static struct platform_driver imx21_hcd_driver = {
1928 .driver = { 1933 .driver = {
1929 .name = (char *)hcd_name, 1934 .name = hcd_name,
1930 }, 1935 },
1931 .probe = imx21_probe, 1936 .probe = imx21_probe,
1932 .remove = imx21_remove, 1937 .remove = imx21_remove,
diff --git a/drivers/usb/host/imx21-hcd.h b/drivers/usb/host/imx21-hcd.h
index c005770a73e9..05122f8a6983 100644
--- a/drivers/usb/host/imx21-hcd.h
+++ b/drivers/usb/host/imx21-hcd.h
@@ -24,6 +24,10 @@
24#ifndef __LINUX_IMX21_HCD_H__ 24#ifndef __LINUX_IMX21_HCD_H__
25#define __LINUX_IMX21_HCD_H__ 25#define __LINUX_IMX21_HCD_H__
26 26
27#ifdef CONFIG_DYNAMIC_DEBUG
28#define DEBUG
29#endif
30
27#include <linux/platform_data/usb-mx2.h> 31#include <linux/platform_data/usb-mx2.h>
28 32
29#define NUM_ISO_ETDS 2 33#define NUM_ISO_ETDS 2
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index c7d0f8f231be..2740f65936bd 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1645,6 +1645,8 @@ static int isp116x_probe(struct platform_device *pdev)
1645 if (ret) 1645 if (ret)
1646 goto err6; 1646 goto err6;
1647 1647
1648 device_wakeup_enable(hcd->self.controller);
1649
1648 ret = create_debug_file(isp116x); 1650 ret = create_debug_file(isp116x);
1649 if (ret) { 1651 if (ret) {
1650 ERR("Couldn't create debugfs entry\n"); 1652 ERR("Couldn't create debugfs entry\n");
@@ -1705,7 +1707,7 @@ static struct platform_driver isp116x_driver = {
1705 .suspend = isp116x_suspend, 1707 .suspend = isp116x_suspend,
1706 .resume = isp116x_resume, 1708 .resume = isp116x_resume,
1707 .driver = { 1709 .driver = {
1708 .name = (char *)hcd_name, 1710 .name = hcd_name,
1709 .owner = THIS_MODULE, 1711 .owner = THIS_MODULE,
1710 }, 1712 },
1711}; 1713};
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c
index 935a2dd367a8..34645ae9313d 100644
--- a/drivers/usb/host/isp1362-hcd.c
+++ b/drivers/usb/host/isp1362-hcd.c
@@ -2746,6 +2746,8 @@ static int isp1362_probe(struct platform_device *pdev)
2746 retval = usb_add_hcd(hcd, irq, irq_flags | IRQF_SHARED); 2746 retval = usb_add_hcd(hcd, irq, irq_flags | IRQF_SHARED);
2747 if (retval != 0) 2747 if (retval != 0)
2748 goto err6; 2748 goto err6;
2749 device_wakeup_enable(hcd->self.controller);
2750
2749 pr_info("%s, irq %d\n", hcd->product_desc, irq); 2751 pr_info("%s, irq %d\n", hcd->product_desc, irq);
2750 2752
2751 create_debug_file(isp1362_hcd); 2753 create_debug_file(isp1362_hcd);
@@ -2829,7 +2831,7 @@ static struct platform_driver isp1362_driver = {
2829 .suspend = isp1362_suspend, 2831 .suspend = isp1362_suspend,
2830 .resume = isp1362_resume, 2832 .resume = isp1362_resume,
2831 .driver = { 2833 .driver = {
2832 .name = (char *)hcd_name, 2834 .name = hcd_name,
2833 .owner = THIS_MODULE, 2835 .owner = THIS_MODULE,
2834 }, 2836 },
2835}; 2837};
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 2facee53eab1..51a0ae9cdd1d 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -2250,6 +2250,7 @@ struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
2250 ret = usb_add_hcd(hcd, irq, irqflags); 2250 ret = usb_add_hcd(hcd, irq, irqflags);
2251 if (ret) 2251 if (ret)
2252 goto err_unmap; 2252 goto err_unmap;
2253 device_wakeup_enable(hcd->self.controller);
2253 2254
2254 return hcd; 2255 return hcd;
2255 2256
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 418444ebb1b8..29d2093e3cee 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -200,8 +200,10 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
200 at91_start_hc(pdev); 200 at91_start_hc(pdev);
201 201
202 retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED); 202 retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
203 if (retval == 0) 203 if (retval == 0) {
204 device_wakeup_enable(hcd->self.controller);
204 return retval; 205 return retval;
206 }
205 207
206 /* Error handling */ 208 /* Error handling */
207 at91_stop_hc(pdev); 209 at91_stop_hc(pdev);
@@ -635,10 +637,17 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
635{ 637{
636 struct usb_hcd *hcd = platform_get_drvdata(pdev); 638 struct usb_hcd *hcd = platform_get_drvdata(pdev);
637 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 639 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
640 bool do_wakeup = device_may_wakeup(&pdev->dev);
641 int ret;
638 642
639 if (device_may_wakeup(&pdev->dev)) 643 if (do_wakeup)
640 enable_irq_wake(hcd->irq); 644 enable_irq_wake(hcd->irq);
641 645
646 ret = ohci_suspend(hcd, do_wakeup);
647 if (ret) {
648 disable_irq_wake(hcd->irq);
649 return ret;
650 }
642 /* 651 /*
643 * The integrated transceivers seem unable to notice disconnect, 652 * The integrated transceivers seem unable to notice disconnect,
644 * reconnect, or wakeup without the 48 MHz clock active. so for 653 * reconnect, or wakeup without the 48 MHz clock active. so for
@@ -657,7 +666,7 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
657 at91_stop_clock(); 666 at91_stop_clock();
658 } 667 }
659 668
660 return 0; 669 return ret;
661} 670}
662 671
663static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) 672static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 9be59f11e051..f0fe0d26314d 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -348,6 +348,8 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
348 if (error) 348 if (error)
349 goto err4; 349 goto err4;
350 350
351 device_wakeup_enable(hcd->self.controller);
352
351 if (hub->ocic_notify) { 353 if (hub->ocic_notify) {
352 error = hub->ocic_notify(ohci_da8xx_ocic_handler); 354 error = hub->ocic_notify(ohci_da8xx_ocic_handler);
353 if (!error) 355 if (!error)
@@ -406,19 +408,27 @@ static int ohci_hcd_da8xx_drv_remove(struct platform_device *dev)
406} 408}
407 409
408#ifdef CONFIG_PM 410#ifdef CONFIG_PM
409static int ohci_da8xx_suspend(struct platform_device *dev, pm_message_t message) 411static int ohci_da8xx_suspend(struct platform_device *pdev,
412 pm_message_t message)
410{ 413{
411 struct usb_hcd *hcd = platform_get_drvdata(dev); 414 struct usb_hcd *hcd = platform_get_drvdata(pdev);
412 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 415 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
416 bool do_wakeup = device_may_wakeup(&pdev->dev);
417 int ret;
418
413 419
414 if (time_before(jiffies, ohci->next_statechange)) 420 if (time_before(jiffies, ohci->next_statechange))
415 msleep(5); 421 msleep(5);
416 ohci->next_statechange = jiffies; 422 ohci->next_statechange = jiffies;
417 423
424 ret = ohci_suspend(hcd, do_wakeup);
425 if (ret)
426 return ret;
427
418 ohci_da8xx_clock(0); 428 ohci_da8xx_clock(0);
419 hcd->state = HC_STATE_SUSPENDED; 429 hcd->state = HC_STATE_SUSPENDED;
420 dev->dev.power.power_state = PMSG_SUSPEND; 430
421 return 0; 431 return ret;
422} 432}
423 433
424static int ohci_da8xx_resume(struct platform_device *dev) 434static int ohci_da8xx_resume(struct platform_device *dev)
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 3fca52ec02ac..45032e933e18 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -9,8 +9,6 @@
9 9
10/*-------------------------------------------------------------------------*/ 10/*-------------------------------------------------------------------------*/
11 11
12#ifdef DEBUG
13
14#define edstring(ed_type) ({ char *temp; \ 12#define edstring(ed_type) ({ char *temp; \
15 switch (ed_type) { \ 13 switch (ed_type) { \
16 case PIPE_CONTROL: temp = "ctrl"; break; \ 14 case PIPE_CONTROL: temp = "ctrl"; break; \
@@ -20,57 +18,6 @@
20 } temp;}) 18 } temp;})
21#define pipestring(pipe) edstring(usb_pipetype(pipe)) 19#define pipestring(pipe) edstring(usb_pipetype(pipe))
22 20
23/* debug| print the main components of an URB
24 * small: 0) header + data packets 1) just header
25 */
26static void __maybe_unused
27urb_print(struct urb * urb, char * str, int small, int status)
28{
29 unsigned int pipe= urb->pipe;
30
31 if (!urb->dev || !urb->dev->bus) {
32 printk(KERN_DEBUG "%s URB: no dev\n", str);
33 return;
34 }
35
36#ifndef OHCI_VERBOSE_DEBUG
37 if (status != 0)
38#endif
39 printk(KERN_DEBUG "%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d stat=%d\n",
40 str,
41 urb,
42 usb_pipedevice (pipe),
43 usb_pipeendpoint (pipe),
44 usb_pipeout (pipe)? "out" : "in",
45 pipestring (pipe),
46 urb->transfer_flags,
47 urb->actual_length,
48 urb->transfer_buffer_length,
49 status);
50
51#ifdef OHCI_VERBOSE_DEBUG
52 if (!small) {
53 int i, len;
54
55 if (usb_pipecontrol (pipe)) {
56 printk (KERN_DEBUG "%s: setup(8):", __FILE__);
57 for (i = 0; i < 8 ; i++)
58 printk (" %02x", ((__u8 *) urb->setup_packet) [i]);
59 printk ("\n");
60 }
61 if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
62 printk (KERN_DEBUG "%s: data(%d/%d):", __FILE__,
63 urb->actual_length,
64 urb->transfer_buffer_length);
65 len = usb_pipeout (pipe)?
66 urb->transfer_buffer_length: urb->actual_length;
67 for (i = 0; i < 16 && i < len; i++)
68 printk (" %02x", ((__u8 *) urb->transfer_buffer) [i]);
69 printk ("%s stat:%d\n", i < len? "...": "", status);
70 }
71 }
72#endif
73}
74 21
75#define ohci_dbg_sw(ohci, next, size, format, arg...) \ 22#define ohci_dbg_sw(ohci, next, size, format, arg...) \
76 do { \ 23 do { \
@@ -407,22 +354,8 @@ ohci_dump_ed (const struct ohci_hcd *ohci, const char *label,
407 } 354 }
408} 355}
409 356
410#else
411static inline void ohci_dump (struct ohci_hcd *controller, int verbose) {}
412
413#undef OHCI_VERBOSE_DEBUG
414
415#endif /* DEBUG */
416
417/*-------------------------------------------------------------------------*/ 357/*-------------------------------------------------------------------------*/
418 358
419#ifdef STUB_DEBUG_FILES
420
421static inline void create_debug_files (struct ohci_hcd *bus) { }
422static inline void remove_debug_files (struct ohci_hcd *bus) { }
423
424#else
425
426static int debug_async_open(struct inode *, struct file *); 359static int debug_async_open(struct inode *, struct file *);
427static int debug_periodic_open(struct inode *, struct file *); 360static int debug_periodic_open(struct inode *, struct file *);
428static int debug_registers_open(struct inode *, struct file *); 361static int debug_registers_open(struct inode *, struct file *);
@@ -871,7 +804,5 @@ static inline void remove_debug_files (struct ohci_hcd *ohci)
871 debugfs_remove(ohci->debug_dir); 804 debugfs_remove(ohci->debug_dir);
872} 805}
873 806
874#endif
875
876/*-------------------------------------------------------------------------*/ 807/*-------------------------------------------------------------------------*/
877 808
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 91ec9b2cd378..68588d8a09bb 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -146,6 +146,7 @@ skip_phy:
146 dev_err(&pdev->dev, "Failed to add USB HCD\n"); 146 dev_err(&pdev->dev, "Failed to add USB HCD\n");
147 goto fail_add_hcd; 147 goto fail_add_hcd;
148 } 148 }
149 device_wakeup_enable(hcd->self.controller);
149 return 0; 150 return 0;
150 151
151fail_add_hcd: 152fail_add_hcd:
@@ -191,23 +192,14 @@ static int exynos_ohci_suspend(struct device *dev)
191 struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); 192 struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
192 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 193 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
193 struct platform_device *pdev = to_platform_device(dev); 194 struct platform_device *pdev = to_platform_device(dev);
195 bool do_wakeup = device_may_wakeup(dev);
194 unsigned long flags; 196 unsigned long flags;
195 int rc = 0; 197 int rc = ohci_suspend(hcd, do_wakeup);
196 198
197 /* 199 if (rc)
198 * Root hub was already suspended. Disable irq emission and 200 return rc;
199 * mark HW unaccessible, bail out if RH has been resumed. Use
200 * the spinlock to properly synchronize with possible pending
201 * RH suspend or resume activity.
202 */
203 spin_lock_irqsave(&ohci->lock, flags);
204 if (ohci->rh_state != OHCI_RH_SUSPENDED &&
205 ohci->rh_state != OHCI_RH_HALTED) {
206 rc = -EINVAL;
207 goto fail;
208 }
209 201
210 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 202 spin_lock_irqsave(&ohci->lock, flags);
211 203
212 if (exynos_ohci->otg) 204 if (exynos_ohci->otg)
213 exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); 205 exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
@@ -216,10 +208,9 @@ static int exynos_ohci_suspend(struct device *dev)
216 208
217 clk_disable_unprepare(exynos_ohci->clk); 209 clk_disable_unprepare(exynos_ohci->clk);
218 210
219fail:
220 spin_unlock_irqrestore(&ohci->lock, flags); 211 spin_unlock_irqrestore(&ohci->lock, flags);
221 212
222 return rc; 213 return 0;
223} 214}
224 215
225static int exynos_ohci_resume(struct device *dev) 216static int exynos_ohci_resume(struct device *dev)
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 8ada13f8dde2..3586460fb2a1 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -51,8 +51,6 @@
51 51
52/*-------------------------------------------------------------------------*/ 52/*-------------------------------------------------------------------------*/
53 53
54#undef OHCI_VERBOSE_DEBUG /* not always helpful */
55
56/* For initializing controller (mask in an HCFS mode too) */ 54/* For initializing controller (mask in an HCFS mode too) */
57#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 55#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
58#define OHCI_INTR_INIT \ 56#define OHCI_INTR_INIT \
@@ -127,10 +125,6 @@ static int ohci_urb_enqueue (
127 unsigned long flags; 125 unsigned long flags;
128 int retval = 0; 126 int retval = 0;
129 127
130#ifdef OHCI_VERBOSE_DEBUG
131 urb_print(urb, "SUB", usb_pipein(pipe), -EINPROGRESS);
132#endif
133
134 /* every endpoint has a ed, locate and maybe (re)initialize it */ 128 /* every endpoint has a ed, locate and maybe (re)initialize it */
135 if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval))) 129 if (! (ed = ed_get (ohci, urb->ep, urb->dev, pipe, urb->interval)))
136 return -ENOMEM; 130 return -ENOMEM;
@@ -284,10 +278,6 @@ static int ohci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
284 unsigned long flags; 278 unsigned long flags;
285 int rc; 279 int rc;
286 280
287#ifdef OHCI_VERBOSE_DEBUG
288 urb_print(urb, "UNLINK", 1, status);
289#endif
290
291 spin_lock_irqsave (&ohci->lock, flags); 281 spin_lock_irqsave (&ohci->lock, flags);
292 rc = usb_hcd_check_unlink_urb(hcd, urb, status); 282 rc = usb_hcd_check_unlink_urb(hcd, urb, status);
293 if (rc) { 283 if (rc) {
@@ -840,7 +830,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
840 } 830 }
841 831
842 if (ints & OHCI_INTR_RHSC) { 832 if (ints & OHCI_INTR_RHSC) {
843 ohci_vdbg(ohci, "rhsc\n"); 833 ohci_dbg(ohci, "rhsc\n");
844 ohci->next_statechange = jiffies + STATECHANGE_DELAY; 834 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
845 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, 835 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
846 &regs->intrstatus); 836 &regs->intrstatus);
@@ -862,7 +852,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
862 * this might not happen. 852 * this might not happen.
863 */ 853 */
864 else if (ints & OHCI_INTR_RD) { 854 else if (ints & OHCI_INTR_RD) {
865 ohci_vdbg(ohci, "resume detect\n"); 855 ohci_dbg(ohci, "resume detect\n");
866 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus); 856 ohci_writel(ohci, OHCI_INTR_RD, &regs->intrstatus);
867 set_bit(HCD_FLAG_POLL_RH, &hcd->flags); 857 set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
868 if (ohci->autostop) { 858 if (ohci->autostop) {
@@ -1036,6 +1026,7 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1036{ 1026{
1037 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 1027 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
1038 unsigned long flags; 1028 unsigned long flags;
1029 int rc = 0;
1039 1030
1040 /* Disable irq emission and mark HW unaccessible. Use 1031 /* Disable irq emission and mark HW unaccessible. Use
1041 * the spinlock to properly synchronize with possible pending 1032 * the spinlock to properly synchronize with possible pending
@@ -1048,7 +1039,13 @@ int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup)
1048 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 1039 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1049 spin_unlock_irqrestore (&ohci->lock, flags); 1040 spin_unlock_irqrestore (&ohci->lock, flags);
1050 1041
1051 return 0; 1042 synchronize_irq(hcd->irq);
1043
1044 if (do_wakeup && HCD_WAKEUP_PENDING(hcd)) {
1045 ohci_resume(hcd, false);
1046 rc = -EBUSY;
1047 }
1048 return rc;
1052} 1049}
1053EXPORT_SYMBOL_GPL(ohci_suspend); 1050EXPORT_SYMBOL_GPL(ohci_suspend);
1054 1051
@@ -1233,13 +1230,11 @@ static int __init ohci_hcd_mod_init(void)
1233 sizeof (struct ed), sizeof (struct td)); 1230 sizeof (struct ed), sizeof (struct td));
1234 set_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1231 set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
1235 1232
1236#ifdef DEBUG
1237 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root); 1233 ohci_debug_root = debugfs_create_dir("ohci", usb_debug_root);
1238 if (!ohci_debug_root) { 1234 if (!ohci_debug_root) {
1239 retval = -ENOENT; 1235 retval = -ENOENT;
1240 goto error_debug; 1236 goto error_debug;
1241 } 1237 }
1242#endif
1243 1238
1244#ifdef PS3_SYSTEM_BUS_DRIVER 1239#ifdef PS3_SYSTEM_BUS_DRIVER
1245 retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER); 1240 retval = ps3_ohci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
@@ -1314,11 +1309,9 @@ static int __init ohci_hcd_mod_init(void)
1314 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1309 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1315 error_ps3: 1310 error_ps3:
1316#endif 1311#endif
1317#ifdef DEBUG
1318 debugfs_remove(ohci_debug_root); 1312 debugfs_remove(ohci_debug_root);
1319 ohci_debug_root = NULL; 1313 ohci_debug_root = NULL;
1320 error_debug: 1314 error_debug:
1321#endif
1322 1315
1323 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1316 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
1324 return retval; 1317 return retval;
@@ -1348,9 +1341,7 @@ static void __exit ohci_hcd_mod_exit(void)
1348#ifdef PS3_SYSTEM_BUS_DRIVER 1341#ifdef PS3_SYSTEM_BUS_DRIVER
1349 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); 1342 ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
1350#endif 1343#endif
1351#ifdef DEBUG
1352 debugfs_remove(ohci_debug_root); 1344 debugfs_remove(ohci_debug_root);
1353#endif
1354 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded); 1345 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
1355} 1346}
1356module_exit(ohci_hcd_mod_exit); 1347module_exit(ohci_hcd_mod_exit);
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 61705a760e7d..c81c8721cc5a 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -725,10 +725,8 @@ static int ohci_hub_control (
725 temp = roothub_portstatus (ohci, wIndex); 725 temp = roothub_portstatus (ohci, wIndex);
726 put_unaligned_le32(temp, buf); 726 put_unaligned_le32(temp, buf);
727 727
728#ifndef OHCI_VERBOSE_DEBUG 728 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */
729 if (*(u16*)(buf+2)) /* only if wPortChange is interesting */ 729 dbg_port(ohci, "GetStatus", wIndex, temp);
730#endif
731 dbg_port (ohci, "GetStatus", wIndex, temp);
732 break; 730 break;
733 case SetHubFeature: 731 case SetHubFeature:
734 switch (wValue) { 732 switch (wValue) {
diff --git a/drivers/usb/host/ohci-jz4740.c b/drivers/usb/host/ohci-jz4740.c
index d4ef53990d73..efe31f3ab4ea 100644
--- a/drivers/usb/host/ohci-jz4740.c
+++ b/drivers/usb/host/ohci-jz4740.c
@@ -217,6 +217,7 @@ static int jz4740_ohci_probe(struct platform_device *pdev)
217 dev_err(&pdev->dev, "Failed to add hcd: %d\n", ret); 217 dev_err(&pdev->dev, "Failed to add hcd: %d\n", ret);
218 goto err_disable; 218 goto err_disable;
219 } 219 }
220 device_wakeup_enable(hcd->self.controller);
220 221
221 return 0; 222 return 0;
222 223
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index e99db8a6d55f..719f28e5e3ac 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -274,8 +274,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
274 274
275 dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq); 275 dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq);
276 ret = usb_add_hcd(hcd, irq, 0); 276 ret = usb_add_hcd(hcd, irq, 0);
277 if (ret == 0) 277 if (ret == 0) {
278 device_wakeup_enable(hcd->self.controller);
278 return ret; 279 return ret;
280 }
279 281
280 ohci_nxp_stop_hc(); 282 ohci_nxp_stop_hc();
281fail_resource: 283fail_resource:
diff --git a/drivers/usb/host/ohci-octeon.c b/drivers/usb/host/ohci-octeon.c
index 6c16dcef15c6..49b220dc2f9b 100644
--- a/drivers/usb/host/ohci-octeon.c
+++ b/drivers/usb/host/ohci-octeon.c
@@ -171,6 +171,8 @@ static int ohci_octeon_drv_probe(struct platform_device *pdev)
171 goto err3; 171 goto err3;
172 } 172 }
173 173
174 device_wakeup_enable(hcd->self.controller);
175
174 platform_set_drvdata(pdev, hcd); 176 platform_set_drvdata(pdev, hcd);
175 177
176 return 0; 178 return 0;
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index f253214741ba..a44a4fede1c4 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -367,6 +367,7 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
367 if (retval) 367 if (retval)
368 goto err3; 368 goto err3;
369 369
370 device_wakeup_enable(hcd->self.controller);
370 return 0; 371 return 0;
371err3: 372err3:
372 iounmap(hcd->regs); 373 iounmap(hcd->regs);
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c
index 21457417a856..ec15aebe8786 100644
--- a/drivers/usb/host/ohci-omap3.c
+++ b/drivers/usb/host/ohci-omap3.c
@@ -130,6 +130,7 @@ static int ohci_hcd_omap3_probe(struct platform_device *pdev)
130 dev_dbg(dev, "failed to add hcd with err %d\n", ret); 130 dev_dbg(dev, "failed to add hcd with err %d\n", ret);
131 goto err_add_hcd; 131 goto err_add_hcd;
132 } 132 }
133 device_wakeup_enable(hcd->self.controller);
133 134
134 return 0; 135 return 0;
135 136
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index f351ff5b171f..68f674cd095f 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -108,6 +108,8 @@ static int ohci_platform_probe(struct platform_device *dev)
108 if (err) 108 if (err)
109 goto err_put_hcd; 109 goto err_put_hcd;
110 110
111 device_wakeup_enable(hcd->self.controller);
112
111 platform_set_drvdata(dev, hcd); 113 platform_set_drvdata(dev, hcd);
112 114
113 return err; 115 return err;
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 81f3eba215c1..83e33d464082 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -147,8 +147,10 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
147 ohci_hcd_init(ohci); 147 ohci_hcd_init(ohci);
148 148
149 rv = usb_add_hcd(hcd, irq, 0); 149 rv = usb_add_hcd(hcd, irq, 0);
150 if (rv == 0) 150 if (rv == 0) {
151 device_wakeup_enable(hcd->self.controller);
151 return 0; 152 return 0;
153 }
152 154
153 /* by now, 440epx is known to show usb_23 erratum */ 155 /* by now, 440epx is known to show usb_23 erratum */
154 np = of_find_compatible_node(NULL, NULL, "ibm,usb-ehci-440epx"); 156 np = of_find_compatible_node(NULL, NULL, "ibm,usb-ehci-440epx");
diff --git a/drivers/usb/host/ohci-ps3.c b/drivers/usb/host/ohci-ps3.c
index 7d35cd9e2862..71d8bc4c27f6 100644
--- a/drivers/usb/host/ohci-ps3.c
+++ b/drivers/usb/host/ohci-ps3.c
@@ -173,6 +173,7 @@ static int ps3_ohci_probe(struct ps3_system_bus_device *dev)
173 goto fail_add_hcd; 173 goto fail_add_hcd;
174 } 174 }
175 175
176 device_wakeup_enable(hcd->self.controller);
176 return result; 177 return result;
177 178
178fail_add_hcd: 179fail_add_hcd:
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 9b7435f0dcd6..9352a4d42563 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -443,8 +443,10 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
443 ohci->num_ports = 3; 443 ohci->num_ports = 3;
444 444
445 retval = usb_add_hcd(hcd, irq, 0); 445 retval = usb_add_hcd(hcd, irq, 0);
446 if (retval == 0) 446 if (retval == 0) {
447 device_wakeup_enable(hcd->self.controller);
447 return retval; 448 return retval;
449 }
448 450
449 pxa27x_stop_hc(pxa_ohci, &pdev->dev); 451 pxa27x_stop_hc(pxa_ohci, &pdev->dev);
450 err3: 452 err3:
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index e7f577e63624..d4253e319428 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -68,10 +68,6 @@ __acquires(ohci->lock)
68 break; 68 break;
69 } 69 }
70 70
71#ifdef OHCI_VERBOSE_DEBUG
72 urb_print(urb, "RET", usb_pipeout (urb->pipe), status);
73#endif
74
75 /* urb->complete() can reenter this HCD */ 71 /* urb->complete() can reenter this HCD */
76 usb_hcd_unlink_urb_from_ep(ohci_to_hcd(ohci), urb); 72 usb_hcd_unlink_urb_from_ep(ohci_to_hcd(ohci), urb);
77 spin_unlock (&ohci->lock); 73 spin_unlock (&ohci->lock);
@@ -147,7 +143,7 @@ static void periodic_link (struct ohci_hcd *ohci, struct ed *ed)
147{ 143{
148 unsigned i; 144 unsigned i;
149 145
150 ohci_vdbg (ohci, "link %sed %p branch %d [%dus.], interval %d\n", 146 ohci_dbg(ohci, "link %sed %p branch %d [%dus.], interval %d\n",
151 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "", 147 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
152 ed, ed->branch, ed->load, ed->interval); 148 ed, ed->branch, ed->load, ed->interval);
153 149
@@ -294,7 +290,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
294 } 290 }
295 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval; 291 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval;
296 292
297 ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n", 293 ohci_dbg(ohci, "unlink %sed %p branch %d [%dus.], interval %d\n",
298 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "", 294 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
299 ed, ed->branch, ed->load, ed->interval); 295 ed, ed->branch, ed->load, ed->interval);
300} 296}
@@ -765,7 +761,7 @@ static int td_done(struct ohci_hcd *ohci, struct urb *urb, struct td *td)
765 urb->iso_frame_desc [td->index].status = cc_to_error [cc]; 761 urb->iso_frame_desc [td->index].status = cc_to_error [cc];
766 762
767 if (cc != TD_CC_NOERROR) 763 if (cc != TD_CC_NOERROR)
768 ohci_vdbg (ohci, 764 ohci_dbg(ohci,
769 "urb %p iso td %p (%d) len %d cc %d\n", 765 "urb %p iso td %p (%d) len %d cc %d\n",
770 urb, td, 1 + td->index, dlen, cc); 766 urb, td, 1 + td->index, dlen, cc);
771 767
@@ -797,7 +793,7 @@ static int td_done(struct ohci_hcd *ohci, struct urb *urb, struct td *td)
797 } 793 }
798 794
799 if (cc != TD_CC_NOERROR && cc < 0x0E) 795 if (cc != TD_CC_NOERROR && cc < 0x0E)
800 ohci_vdbg (ohci, 796 ohci_dbg(ohci,
801 "urb %p td %p (%d) cc %d, len=%d/%d\n", 797 "urb %p td %p (%d) cc %d, len=%d/%d\n",
802 urb, td, 1 + td->index, cc, 798 urb, td, 1 + td->index, cc,
803 urb->actual_length, 799 urb->actual_length,
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index f90101b9cdb9..ff7c8f1c48fb 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -395,6 +395,7 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
395 if (retval != 0) 395 if (retval != 0)
396 goto err_ioremap; 396 goto err_ioremap;
397 397
398 device_wakeup_enable(hcd->self.controller);
398 return 0; 399 return 0;
399 400
400 err_ioremap: 401 err_ioremap:
@@ -426,28 +427,15 @@ static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev)
426static int ohci_hcd_s3c2410_drv_suspend(struct device *dev) 427static int ohci_hcd_s3c2410_drv_suspend(struct device *dev)
427{ 428{
428 struct usb_hcd *hcd = dev_get_drvdata(dev); 429 struct usb_hcd *hcd = dev_get_drvdata(dev);
429 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
430 struct platform_device *pdev = to_platform_device(dev); 430 struct platform_device *pdev = to_platform_device(dev);
431 unsigned long flags; 431 bool do_wakeup = device_may_wakeup(dev);
432 int rc = 0; 432 int rc = 0;
433 433
434 /* 434 rc = ohci_suspend(hcd, do_wakeup);
435 * Root hub was already suspended. Disable irq emission and 435 if (rc)
436 * mark HW unaccessible, bail out if RH has been resumed. Use 436 return rc;
437 * the spinlock to properly synchronize with possible pending
438 * RH suspend or resume activity.
439 */
440 spin_lock_irqsave(&ohci->lock, flags);
441 if (ohci->rh_state != OHCI_RH_SUSPENDED) {
442 rc = -EINVAL;
443 goto bail;
444 }
445
446 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
447 437
448 s3c2410_stop_hc(pdev); 438 s3c2410_stop_hc(pdev);
449bail:
450 spin_unlock_irqrestore(&ohci->lock, flags);
451 439
452 return rc; 440 return rc;
453} 441}
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index aa9e127bbe71..2ac266d692a2 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -211,8 +211,10 @@ static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
211 goto err2; 211 goto err2;
212 212
213 ret = usb_add_hcd(hcd, dev->irq[1], 0); 213 ret = usb_add_hcd(hcd, dev->irq[1], 0);
214 if (ret == 0) 214 if (ret == 0) {
215 device_wakeup_enable(hcd->self.controller);
215 return ret; 216 return ret;
217 }
216 218
217 sa1111_stop_hc(dev); 219 sa1111_stop_hc(dev);
218 err2: 220 err2:
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 2a5de5fecd8f..4e81c804c73e 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -168,6 +168,7 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
168 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 168 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
169 if (retval) 169 if (retval)
170 goto err5; 170 goto err5;
171 device_wakeup_enable(hcd->self.controller);
171 172
172 /* enable power and unmask interrupts */ 173 /* enable power and unmask interrupts */
173 174
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 6b02107d281d..4cb98abc0bef 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -103,8 +103,10 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
103 ohci = hcd_to_ohci(hcd); 103 ohci = hcd_to_ohci(hcd);
104 104
105 retval = usb_add_hcd(hcd, platform_get_irq(pdev, 0), 0); 105 retval = usb_add_hcd(hcd, platform_get_irq(pdev, 0), 0);
106 if (retval == 0) 106 if (retval == 0) {
107 device_wakeup_enable(hcd->self.controller);
107 return retval; 108 return retval;
109 }
108 110
109 clk_disable_unprepare(sohci_p->clk); 111 clk_disable_unprepare(sohci_p->clk);
110err_put_hcd: 112err_put_hcd:
@@ -129,20 +131,26 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev)
129} 131}
130 132
131#if defined(CONFIG_PM) 133#if defined(CONFIG_PM)
132static int spear_ohci_hcd_drv_suspend(struct platform_device *dev, 134static int spear_ohci_hcd_drv_suspend(struct platform_device *pdev,
133 pm_message_t message) 135 pm_message_t message)
134{ 136{
135 struct usb_hcd *hcd = platform_get_drvdata(dev); 137 struct usb_hcd *hcd = platform_get_drvdata(pdev);
136 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 138 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
137 struct spear_ohci *sohci_p = to_spear_ohci(hcd); 139 struct spear_ohci *sohci_p = to_spear_ohci(hcd);
140 bool do_wakeup = device_may_wakeup(&pdev->dev);
141 int ret;
138 142
139 if (time_before(jiffies, ohci->next_statechange)) 143 if (time_before(jiffies, ohci->next_statechange))
140 msleep(5); 144 msleep(5);
141 ohci->next_statechange = jiffies; 145 ohci->next_statechange = jiffies;
142 146
147 ret = ohci_suspend(hcd, do_wakeup);
148 if (ret)
149 return ret;
150
143 clk_disable_unprepare(sohci_p->clk); 151 clk_disable_unprepare(sohci_p->clk);
144 152
145 return 0; 153 return ret;
146} 154}
147 155
148static int spear_ohci_hcd_drv_resume(struct platform_device *dev) 156static int spear_ohci_hcd_drv_resume(struct platform_device *dev)
diff --git a/drivers/usb/host/ohci-tilegx.c b/drivers/usb/host/ohci-tilegx.c
index 22540ab71f55..0b183e0b0a8a 100644
--- a/drivers/usb/host/ohci-tilegx.c
+++ b/drivers/usb/host/ohci-tilegx.c
@@ -159,6 +159,7 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
159 ret = usb_add_hcd(hcd, pdata->irq, IRQF_SHARED); 159 ret = usb_add_hcd(hcd, pdata->irq, IRQF_SHARED);
160 if (ret == 0) { 160 if (ret == 0) {
161 platform_set_drvdata(pdev, hcd); 161 platform_set_drvdata(pdev, hcd);
162 device_wakeup_enable(hcd->self.controller);
162 return ret; 163 return ret;
163 } 164 }
164 165
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index ecb09a5ada9c..9c44093b8e1e 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -250,6 +250,7 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
250 if (ret) 250 if (ret)
251 goto err_add_hcd; 251 goto err_add_hcd;
252 252
253 device_wakeup_enable(hcd->self.controller);
253 if (ret == 0) 254 if (ret == 0)
254 return ret; 255 return ret;
255 256
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index e2e5faa5a402..9250cada13f0 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -415,12 +415,11 @@ struct ohci_hcd {
415 struct ed *ed_to_check; 415 struct ed *ed_to_check;
416 unsigned zf_delay; 416 unsigned zf_delay;
417 417
418#ifdef DEBUG
419 struct dentry *debug_dir; 418 struct dentry *debug_dir;
420 struct dentry *debug_async; 419 struct dentry *debug_async;
421 struct dentry *debug_periodic; 420 struct dentry *debug_periodic;
422 struct dentry *debug_registers; 421 struct dentry *debug_registers;
423#endif 422
424 /* platform-specific data -- must come last */ 423 /* platform-specific data -- must come last */
425 unsigned long priv[0] __aligned(sizeof(s64)); 424 unsigned long priv[0] __aligned(sizeof(s64));
426 425
@@ -474,10 +473,6 @@ static inline struct usb_hcd *ohci_to_hcd (const struct ohci_hcd *ohci)
474 473
475/*-------------------------------------------------------------------------*/ 474/*-------------------------------------------------------------------------*/
476 475
477#ifndef DEBUG
478#define STUB_DEBUG_FILES
479#endif /* DEBUG */
480
481#define ohci_dbg(ohci, fmt, args...) \ 476#define ohci_dbg(ohci, fmt, args...) \
482 dev_dbg (ohci_to_hcd(ohci)->self.controller , fmt , ## args ) 477 dev_dbg (ohci_to_hcd(ohci)->self.controller , fmt , ## args )
483#define ohci_err(ohci, fmt, args...) \ 478#define ohci_err(ohci, fmt, args...) \
@@ -487,12 +482,6 @@ static inline struct usb_hcd *ohci_to_hcd (const struct ohci_hcd *ohci)
487#define ohci_warn(ohci, fmt, args...) \ 482#define ohci_warn(ohci, fmt, args...) \
488 dev_warn (ohci_to_hcd(ohci)->self.controller , fmt , ## args ) 483 dev_warn (ohci_to_hcd(ohci)->self.controller , fmt , ## args )
489 484
490#ifdef OHCI_VERBOSE_DEBUG
491# define ohci_vdbg ohci_dbg
492#else
493# define ohci_vdbg(ohci, fmt, args...) do { } while (0)
494#endif
495
496/*-------------------------------------------------------------------------*/ 485/*-------------------------------------------------------------------------*/
497 486
498/* 487/*
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 4a6df2d8f902..778eeaf2dd14 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -60,6 +60,10 @@
60#define oxu_info(oxu, fmt, args...) \ 60#define oxu_info(oxu, fmt, args...) \
61 dev_info(oxu_to_hcd(oxu)->self.controller , fmt , ## args) 61 dev_info(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
62 62
63#ifdef CONFIG_DYNAMIC_DEBUG
64#define DEBUG
65#endif
66
63static inline struct usb_hcd *oxu_to_hcd(struct oxu_hcd *oxu) 67static inline struct usb_hcd *oxu_to_hcd(struct oxu_hcd *oxu)
64{ 68{
65 return container_of((void *) oxu, struct usb_hcd, hcd_priv); 69 return container_of((void *) oxu, struct usb_hcd, hcd_priv);
@@ -3747,6 +3751,7 @@ static struct usb_hcd *oxu_create(struct platform_device *pdev,
3747 if (ret < 0) 3751 if (ret < 0)
3748 return ERR_PTR(ret); 3752 return ERR_PTR(ret);
3749 3753
3754 device_wakeup_enable(hcd->self.controller);
3750 return hcd; 3755 return hcd;
3751} 3756}
3752 3757
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 2ad004ae747c..47b1322c7a77 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2514,6 +2514,7 @@ static int r8a66597_probe(struct platform_device *pdev)
2514 dev_err(&pdev->dev, "Failed to add hcd\n"); 2514 dev_err(&pdev->dev, "Failed to add hcd\n");
2515 goto clean_up3; 2515 goto clean_up3;
2516 } 2516 }
2517 device_wakeup_enable(hcd->self.controller);
2517 2518
2518 return 0; 2519 return 0;
2519 2520
@@ -2534,7 +2535,7 @@ static struct platform_driver r8a66597_driver = {
2534 .probe = r8a66597_probe, 2535 .probe = r8a66597_probe,
2535 .remove = r8a66597_remove, 2536 .remove = r8a66597_remove,
2536 .driver = { 2537 .driver = {
2537 .name = (char *) hcd_name, 2538 .name = hcd_name,
2538 .owner = THIS_MODULE, 2539 .owner = THIS_MODULE,
2539 .pm = R8A66597_DEV_PM_OPS, 2540 .pm = R8A66597_DEV_PM_OPS,
2540 }, 2541 },
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 79620c39217e..0115e7f51d94 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1732,6 +1732,8 @@ sl811h_probe(struct platform_device *dev)
1732 if (retval != 0) 1732 if (retval != 0)
1733 goto err6; 1733 goto err6;
1734 1734
1735 device_wakeup_enable(hcd->self.controller);
1736
1735 create_debug_file(sl811); 1737 create_debug_file(sl811);
1736 return retval; 1738 return retval;
1737 1739
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index e402beb5a069..c0671750671f 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -3133,6 +3133,7 @@ static int u132_probe(struct platform_device *pdev)
3133 u132_u132_put_kref(u132); 3133 u132_u132_put_kref(u132);
3134 return retval; 3134 return retval;
3135 } else { 3135 } else {
3136 device_wakeup_enable(hcd->self.controller);
3136 u132_monitor_queue_work(u132, 100); 3137 u132_monitor_queue_work(u132, 100);
3137 return 0; 3138 return 0;
3138 } 3139 }
@@ -3217,7 +3218,7 @@ static struct platform_driver u132_platform_driver = {
3217 .suspend = u132_suspend, 3218 .suspend = u132_suspend,
3218 .resume = u132_resume, 3219 .resume = u132_resume,
3219 .driver = { 3220 .driver = {
3220 .name = (char *)hcd_name, 3221 .name = hcd_name,
3221 .owner = THIS_MODULE, 3222 .owner = THIS_MODULE,
3222 }, 3223 },
3223}; 3224};
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 8e239cdd95d5..1b28a000d5c6 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -20,7 +20,7 @@
20 20
21static struct dentry *uhci_debugfs_root; 21static struct dentry *uhci_debugfs_root;
22 22
23#ifdef DEBUG 23#ifdef CONFIG_DYNAMIC_DEBUG
24 24
25/* Handle REALLY large printks so we don't overflow buffers */ 25/* Handle REALLY large printks so we don't overflow buffers */
26static void lprintk(char *buf) 26static void lprintk(char *buf)
@@ -635,7 +635,7 @@ static const struct file_operations uhci_debug_operations = {
635 635
636#endif /* CONFIG_DEBUG_FS */ 636#endif /* CONFIG_DEBUG_FS */
637 637
638#else /* DEBUG */ 638#else /* CONFIG_DYNAMIC_DEBUG*/
639 639
640static inline void lprintk(char *buf) 640static inline void lprintk(char *buf)
641{} 641{}
diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
index 53c23ff7d685..ab25dc397e8b 100644
--- a/drivers/usb/host/uhci-grlib.c
+++ b/drivers/usb/host/uhci-grlib.c
@@ -141,6 +141,7 @@ static int uhci_hcd_grlib_probe(struct platform_device *op)
141 if (rv) 141 if (rv)
142 goto err_uhci; 142 goto err_uhci;
143 143
144 device_wakeup_enable(hcd->self.controller);
144 return 0; 145 return 0;
145 146
146err_uhci: 147err_uhci:
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 4a86b63745b8..27f35e8f161b 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -69,18 +69,21 @@ MODULE_PARM_DESC(ignore_oc, "ignore hardware overcurrent indications");
69 * show all queues in /sys/kernel/debug/uhci/[pci_addr] 69 * show all queues in /sys/kernel/debug/uhci/[pci_addr]
70 * debug = 3, show all TDs in URBs when dumping 70 * debug = 3, show all TDs in URBs when dumping
71 */ 71 */
72#ifdef DEBUG 72#ifdef CONFIG_DYNAMIC_DEBUG
73#define DEBUG_CONFIGURED 1 73
74static int debug = 1; 74static int debug = 1;
75module_param(debug, int, S_IRUGO | S_IWUSR); 75module_param(debug, int, S_IRUGO | S_IWUSR);
76MODULE_PARM_DESC(debug, "Debug level"); 76MODULE_PARM_DESC(debug, "Debug level");
77static char *errbuf;
77 78
78#else 79#else
79#define DEBUG_CONFIGURED 0 80
80#define debug 0 81#define debug 0
82#define errbuf NULL
83
81#endif 84#endif
82 85
83static char *errbuf; 86
84#define ERRBUF_LEN (32 * 1024) 87#define ERRBUF_LEN (32 * 1024)
85 88
86static struct kmem_cache *uhci_up_cachep; /* urb_priv */ 89static struct kmem_cache *uhci_up_cachep; /* urb_priv */
@@ -516,13 +519,12 @@ static void release_uhci(struct uhci_hcd *uhci)
516{ 519{
517 int i; 520 int i;
518 521
519 if (DEBUG_CONFIGURED) {
520 spin_lock_irq(&uhci->lock);
521 uhci->is_initialized = 0;
522 spin_unlock_irq(&uhci->lock);
523 522
524 debugfs_remove(uhci->dentry); 523 spin_lock_irq(&uhci->lock);
525 } 524 uhci->is_initialized = 0;
525 spin_unlock_irq(&uhci->lock);
526
527 debugfs_remove(uhci->dentry);
526 528
527 for (i = 0; i < UHCI_NUM_SKELQH; i++) 529 for (i = 0; i < UHCI_NUM_SKELQH; i++)
528 uhci_free_qh(uhci, uhci->skelqh[i]); 530 uhci_free_qh(uhci, uhci->skelqh[i]);
@@ -868,14 +870,14 @@ static int __init uhci_hcd_init(void)
868 ignore_oc ? ", overcurrent ignored" : ""); 870 ignore_oc ? ", overcurrent ignored" : "");
869 set_bit(USB_UHCI_LOADED, &usb_hcds_loaded); 871 set_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
870 872
871 if (DEBUG_CONFIGURED) { 873#ifdef CONFIG_DYNAMIC_DEBUG
872 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); 874 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL);
873 if (!errbuf) 875 if (!errbuf)
874 goto errbuf_failed; 876 goto errbuf_failed;
875 uhci_debugfs_root = debugfs_create_dir("uhci", usb_debug_root); 877 uhci_debugfs_root = debugfs_create_dir("uhci", usb_debug_root);
876 if (!uhci_debugfs_root) 878 if (!uhci_debugfs_root)
877 goto debug_failed; 879 goto debug_failed;
878 } 880#endif
879 881
880 uhci_up_cachep = kmem_cache_create("uhci_urb_priv", 882 uhci_up_cachep = kmem_cache_create("uhci_urb_priv",
881 sizeof(struct urb_priv), 0, 0, NULL); 883 sizeof(struct urb_priv), 0, 0, NULL);
@@ -906,12 +908,14 @@ clean0:
906 kmem_cache_destroy(uhci_up_cachep); 908 kmem_cache_destroy(uhci_up_cachep);
907 909
908up_failed: 910up_failed:
911#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
909 debugfs_remove(uhci_debugfs_root); 912 debugfs_remove(uhci_debugfs_root);
910 913
911debug_failed: 914debug_failed:
912 kfree(errbuf); 915 kfree(errbuf);
913 916
914errbuf_failed: 917errbuf_failed:
918#endif
915 919
916 clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); 920 clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
917 return retval; 921 return retval;
@@ -927,7 +931,9 @@ static void __exit uhci_hcd_cleanup(void)
927#endif 931#endif
928 kmem_cache_destroy(uhci_up_cachep); 932 kmem_cache_destroy(uhci_up_cachep);
929 debugfs_remove(uhci_debugfs_root); 933 debugfs_remove(uhci_debugfs_root);
934#ifdef CONFIG_DYNAMIC_DEBUG
930 kfree(errbuf); 935 kfree(errbuf);
936#endif
931 clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded); 937 clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
932} 938}
933 939
diff --git a/drivers/usb/host/uhci-pci.c b/drivers/usb/host/uhci-pci.c
index 4cd79888804b..940304c33224 100644
--- a/drivers/usb/host/uhci-pci.c
+++ b/drivers/usb/host/uhci-pci.c
@@ -279,7 +279,7 @@ static const struct hc_driver uhci_driver = {
279 .hub_control = uhci_hub_control, 279 .hub_control = uhci_hub_control,
280}; 280};
281 281
282static DEFINE_PCI_DEVICE_TABLE(uhci_pci_ids) = { { 282static const struct pci_device_id uhci_pci_ids[] = { {
283 /* handle any USB UHCI controller */ 283 /* handle any USB UHCI controller */
284 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_UHCI, ~0), 284 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_UHCI, ~0),
285 .driver_data = (unsigned long) &uhci_driver, 285 .driver_data = (unsigned long) &uhci_driver,
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index 3003fefaa964..44e6c9da8892 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -108,6 +108,7 @@ static int uhci_hcd_platform_probe(struct platform_device *pdev)
108 if (ret) 108 if (ret)
109 goto err_uhci; 109 goto err_uhci;
110 110
111 device_wakeup_enable(hcd->self.controller);
111 return 0; 112 return 0;
112 113
113err_uhci: 114err_uhci:
diff --git a/drivers/usb/host/whci/hcd.c b/drivers/usb/host/whci/hcd.c
index 1b0888f8da9a..d7b363a418de 100644
--- a/drivers/usb/host/whci/hcd.c
+++ b/drivers/usb/host/whci/hcd.c
@@ -293,6 +293,7 @@ static int whc_probe(struct umc_dev *umc)
293 dev_err(dev, "cannot add HCD: %d\n", ret); 293 dev_err(dev, "cannot add HCD: %d\n", ret);
294 goto error_usb_add_hcd; 294 goto error_usb_add_hcd;
295 } 295 }
296 device_wakeup_enable(usb_hcd->self.controller);
296 297
297 ret = wusbhc_b_create(wusbhc); 298 ret = wusbhc_b_create(wusbhc);
298 if (ret) { 299 if (ret) {
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index 73503a81ee81..b016d38199f2 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -32,7 +32,7 @@ void xhci_dbg_regs(struct xhci_hcd *xhci)
32 32
33 xhci_dbg(xhci, "// xHCI capability registers at %p:\n", 33 xhci_dbg(xhci, "// xHCI capability registers at %p:\n",
34 xhci->cap_regs); 34 xhci->cap_regs);
35 temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase); 35 temp = readl(&xhci->cap_regs->hc_capbase);
36 xhci_dbg(xhci, "// @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n", 36 xhci_dbg(xhci, "// @%p = 0x%x (CAPLENGTH AND HCIVERSION)\n",
37 &xhci->cap_regs->hc_capbase, temp); 37 &xhci->cap_regs->hc_capbase, temp);
38 xhci_dbg(xhci, "// CAPLENGTH: 0x%x\n", 38 xhci_dbg(xhci, "// CAPLENGTH: 0x%x\n",
@@ -44,13 +44,13 @@ void xhci_dbg_regs(struct xhci_hcd *xhci)
44 44
45 xhci_dbg(xhci, "// xHCI operational registers at %p:\n", xhci->op_regs); 45 xhci_dbg(xhci, "// xHCI operational registers at %p:\n", xhci->op_regs);
46 46
47 temp = xhci_readl(xhci, &xhci->cap_regs->run_regs_off); 47 temp = readl(&xhci->cap_regs->run_regs_off);
48 xhci_dbg(xhci, "// @%p = 0x%x RTSOFF\n", 48 xhci_dbg(xhci, "// @%p = 0x%x RTSOFF\n",
49 &xhci->cap_regs->run_regs_off, 49 &xhci->cap_regs->run_regs_off,
50 (unsigned int) temp & RTSOFF_MASK); 50 (unsigned int) temp & RTSOFF_MASK);
51 xhci_dbg(xhci, "// xHCI runtime registers at %p:\n", xhci->run_regs); 51 xhci_dbg(xhci, "// xHCI runtime registers at %p:\n", xhci->run_regs);
52 52
53 temp = xhci_readl(xhci, &xhci->cap_regs->db_off); 53 temp = readl(&xhci->cap_regs->db_off);
54 xhci_dbg(xhci, "// @%p = 0x%x DBOFF\n", &xhci->cap_regs->db_off, temp); 54 xhci_dbg(xhci, "// @%p = 0x%x DBOFF\n", &xhci->cap_regs->db_off, temp);
55 xhci_dbg(xhci, "// Doorbell array at %p:\n", xhci->dba); 55 xhci_dbg(xhci, "// Doorbell array at %p:\n", xhci->dba);
56} 56}
@@ -61,7 +61,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
61 61
62 xhci_dbg(xhci, "xHCI capability registers at %p:\n", xhci->cap_regs); 62 xhci_dbg(xhci, "xHCI capability registers at %p:\n", xhci->cap_regs);
63 63
64 temp = xhci_readl(xhci, &xhci->cap_regs->hc_capbase); 64 temp = readl(&xhci->cap_regs->hc_capbase);
65 xhci_dbg(xhci, "CAPLENGTH AND HCIVERSION 0x%x:\n", 65 xhci_dbg(xhci, "CAPLENGTH AND HCIVERSION 0x%x:\n",
66 (unsigned int) temp); 66 (unsigned int) temp);
67 xhci_dbg(xhci, "CAPLENGTH: 0x%x\n", 67 xhci_dbg(xhci, "CAPLENGTH: 0x%x\n",
@@ -69,7 +69,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
69 xhci_dbg(xhci, "HCIVERSION: 0x%x\n", 69 xhci_dbg(xhci, "HCIVERSION: 0x%x\n",
70 (unsigned int) HC_VERSION(temp)); 70 (unsigned int) HC_VERSION(temp));
71 71
72 temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params1); 72 temp = readl(&xhci->cap_regs->hcs_params1);
73 xhci_dbg(xhci, "HCSPARAMS 1: 0x%x\n", 73 xhci_dbg(xhci, "HCSPARAMS 1: 0x%x\n",
74 (unsigned int) temp); 74 (unsigned int) temp);
75 xhci_dbg(xhci, " Max device slots: %u\n", 75 xhci_dbg(xhci, " Max device slots: %u\n",
@@ -79,7 +79,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
79 xhci_dbg(xhci, " Max ports: %u\n", 79 xhci_dbg(xhci, " Max ports: %u\n",
80 (unsigned int) HCS_MAX_PORTS(temp)); 80 (unsigned int) HCS_MAX_PORTS(temp));
81 81
82 temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params2); 82 temp = readl(&xhci->cap_regs->hcs_params2);
83 xhci_dbg(xhci, "HCSPARAMS 2: 0x%x\n", 83 xhci_dbg(xhci, "HCSPARAMS 2: 0x%x\n",
84 (unsigned int) temp); 84 (unsigned int) temp);
85 xhci_dbg(xhci, " Isoc scheduling threshold: %u\n", 85 xhci_dbg(xhci, " Isoc scheduling threshold: %u\n",
@@ -87,7 +87,7 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
87 xhci_dbg(xhci, " Maximum allowed segments in event ring: %u\n", 87 xhci_dbg(xhci, " Maximum allowed segments in event ring: %u\n",
88 (unsigned int) HCS_ERST_MAX(temp)); 88 (unsigned int) HCS_ERST_MAX(temp));
89 89
90 temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params3); 90 temp = readl(&xhci->cap_regs->hcs_params3);
91 xhci_dbg(xhci, "HCSPARAMS 3 0x%x:\n", 91 xhci_dbg(xhci, "HCSPARAMS 3 0x%x:\n",
92 (unsigned int) temp); 92 (unsigned int) temp);
93 xhci_dbg(xhci, " Worst case U1 device exit latency: %u\n", 93 xhci_dbg(xhci, " Worst case U1 device exit latency: %u\n",
@@ -95,14 +95,14 @@ static void xhci_print_cap_regs(struct xhci_hcd *xhci)
95 xhci_dbg(xhci, " Worst case U2 device exit latency: %u\n", 95 xhci_dbg(xhci, " Worst case U2 device exit latency: %u\n",
96 (unsigned int) HCS_U2_LATENCY(temp)); 96 (unsigned int) HCS_U2_LATENCY(temp));
97 97
98 temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params); 98 temp = readl(&xhci->cap_regs->hcc_params);
99 xhci_dbg(xhci, "HCC PARAMS 0x%x:\n", (unsigned int) temp); 99 xhci_dbg(xhci, "HCC PARAMS 0x%x:\n", (unsigned int) temp);
100 xhci_dbg(xhci, " HC generates %s bit addresses\n", 100 xhci_dbg(xhci, " HC generates %s bit addresses\n",
101 HCC_64BIT_ADDR(temp) ? "64" : "32"); 101 HCC_64BIT_ADDR(temp) ? "64" : "32");
102 /* FIXME */ 102 /* FIXME */
103 xhci_dbg(xhci, " FIXME: more HCCPARAMS debugging\n"); 103 xhci_dbg(xhci, " FIXME: more HCCPARAMS debugging\n");
104 104
105 temp = xhci_readl(xhci, &xhci->cap_regs->run_regs_off); 105 temp = readl(&xhci->cap_regs->run_regs_off);
106 xhci_dbg(xhci, "RTSOFF 0x%x:\n", temp & RTSOFF_MASK); 106 xhci_dbg(xhci, "RTSOFF 0x%x:\n", temp & RTSOFF_MASK);
107} 107}
108 108
@@ -110,7 +110,7 @@ static void xhci_print_command_reg(struct xhci_hcd *xhci)
110{ 110{
111 u32 temp; 111 u32 temp;
112 112
113 temp = xhci_readl(xhci, &xhci->op_regs->command); 113 temp = readl(&xhci->op_regs->command);
114 xhci_dbg(xhci, "USBCMD 0x%x:\n", temp); 114 xhci_dbg(xhci, "USBCMD 0x%x:\n", temp);
115 xhci_dbg(xhci, " HC is %s\n", 115 xhci_dbg(xhci, " HC is %s\n",
116 (temp & CMD_RUN) ? "running" : "being stopped"); 116 (temp & CMD_RUN) ? "running" : "being stopped");
@@ -128,7 +128,7 @@ static void xhci_print_status(struct xhci_hcd *xhci)
128{ 128{
129 u32 temp; 129 u32 temp;
130 130
131 temp = xhci_readl(xhci, &xhci->op_regs->status); 131 temp = readl(&xhci->op_regs->status);
132 xhci_dbg(xhci, "USBSTS 0x%x:\n", temp); 132 xhci_dbg(xhci, "USBSTS 0x%x:\n", temp);
133 xhci_dbg(xhci, " Event ring is %sempty\n", 133 xhci_dbg(xhci, " Event ring is %sempty\n",
134 (temp & STS_EINT) ? "not " : ""); 134 (temp & STS_EINT) ? "not " : "");
@@ -163,7 +163,7 @@ static void xhci_print_ports(struct xhci_hcd *xhci)
163 for (j = 0; j < NUM_PORT_REGS; ++j) { 163 for (j = 0; j < NUM_PORT_REGS; ++j) {
164 xhci_dbg(xhci, "%p port %s reg = 0x%x\n", 164 xhci_dbg(xhci, "%p port %s reg = 0x%x\n",
165 addr, names[j], 165 addr, names[j],
166 (unsigned int) xhci_readl(xhci, addr)); 166 (unsigned int) readl(addr));
167 addr++; 167 addr++;
168 } 168 }
169 } 169 }
@@ -177,7 +177,7 @@ void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num)
177 u64 temp_64; 177 u64 temp_64;
178 178
179 addr = &ir_set->irq_pending; 179 addr = &ir_set->irq_pending;
180 temp = xhci_readl(xhci, addr); 180 temp = readl(addr);
181 if (temp == XHCI_INIT_VALUE) 181 if (temp == XHCI_INIT_VALUE)
182 return; 182 return;
183 183
@@ -187,28 +187,28 @@ void xhci_print_ir_set(struct xhci_hcd *xhci, int set_num)
187 (unsigned int)temp); 187 (unsigned int)temp);
188 188
189 addr = &ir_set->irq_control; 189 addr = &ir_set->irq_control;
190 temp = xhci_readl(xhci, addr); 190 temp = readl(addr);
191 xhci_dbg(xhci, " %p: ir_set.control = 0x%x\n", addr, 191 xhci_dbg(xhci, " %p: ir_set.control = 0x%x\n", addr,
192 (unsigned int)temp); 192 (unsigned int)temp);
193 193
194 addr = &ir_set->erst_size; 194 addr = &ir_set->erst_size;
195 temp = xhci_readl(xhci, addr); 195 temp = readl(addr);
196 xhci_dbg(xhci, " %p: ir_set.erst_size = 0x%x\n", addr, 196 xhci_dbg(xhci, " %p: ir_set.erst_size = 0x%x\n", addr,
197 (unsigned int)temp); 197 (unsigned int)temp);
198 198
199 addr = &ir_set->rsvd; 199 addr = &ir_set->rsvd;
200 temp = xhci_readl(xhci, addr); 200 temp = readl(addr);
201 if (temp != XHCI_INIT_VALUE) 201 if (temp != XHCI_INIT_VALUE)
202 xhci_dbg(xhci, " WARN: %p: ir_set.rsvd = 0x%x\n", 202 xhci_dbg(xhci, " WARN: %p: ir_set.rsvd = 0x%x\n",
203 addr, (unsigned int)temp); 203 addr, (unsigned int)temp);
204 204
205 addr = &ir_set->erst_base; 205 addr = &ir_set->erst_base;
206 temp_64 = xhci_read_64(xhci, addr); 206 temp_64 = readq(addr);
207 xhci_dbg(xhci, " %p: ir_set.erst_base = @%08llx\n", 207 xhci_dbg(xhci, " %p: ir_set.erst_base = @%08llx\n",
208 addr, temp_64); 208 addr, temp_64);
209 209
210 addr = &ir_set->erst_dequeue; 210 addr = &ir_set->erst_dequeue;
211 temp_64 = xhci_read_64(xhci, addr); 211 temp_64 = readq(addr);
212 xhci_dbg(xhci, " %p: ir_set.erst_dequeue = @%08llx\n", 212 xhci_dbg(xhci, " %p: ir_set.erst_dequeue = @%08llx\n",
213 addr, temp_64); 213 addr, temp_64);
214} 214}
@@ -219,12 +219,12 @@ void xhci_print_run_regs(struct xhci_hcd *xhci)
219 int i; 219 int i;
220 220
221 xhci_dbg(xhci, "xHCI runtime registers at %p:\n", xhci->run_regs); 221 xhci_dbg(xhci, "xHCI runtime registers at %p:\n", xhci->run_regs);
222 temp = xhci_readl(xhci, &xhci->run_regs->microframe_index); 222 temp = readl(&xhci->run_regs->microframe_index);
223 xhci_dbg(xhci, " %p: Microframe index = 0x%x\n", 223 xhci_dbg(xhci, " %p: Microframe index = 0x%x\n",
224 &xhci->run_regs->microframe_index, 224 &xhci->run_regs->microframe_index,
225 (unsigned int) temp); 225 (unsigned int) temp);
226 for (i = 0; i < 7; ++i) { 226 for (i = 0; i < 7; ++i) {
227 temp = xhci_readl(xhci, &xhci->run_regs->rsvd[i]); 227 temp = readl(&xhci->run_regs->rsvd[i]);
228 if (temp != XHCI_INIT_VALUE) 228 if (temp != XHCI_INIT_VALUE)
229 xhci_dbg(xhci, " WARN: %p: Rsvd[%i] = 0x%x\n", 229 xhci_dbg(xhci, " WARN: %p: Rsvd[%i] = 0x%x\n",
230 &xhci->run_regs->rsvd[i], 230 &xhci->run_regs->rsvd[i],
@@ -412,7 +412,7 @@ void xhci_dbg_cmd_ptrs(struct xhci_hcd *xhci)
412{ 412{
413 u64 val; 413 u64 val;
414 414
415 val = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 415 val = readq(&xhci->op_regs->cmd_ring);
416 xhci_dbg(xhci, "// xHC command ring deq ptr low bits + flags = @%08x\n", 416 xhci_dbg(xhci, "// xHC command ring deq ptr low bits + flags = @%08x\n",
417 lower_32_bits(val)); 417 lower_32_bits(val));
418 xhci_dbg(xhci, "// xHC command ring deq ptr high bits = @%08x\n", 418 xhci_dbg(xhci, "// xHC command ring deq ptr high bits = @%08x\n",
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 805f2348eeba..9992fbfec85f 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -94,7 +94,7 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
94 */ 94 */
95 memset(port_removable, 0, sizeof(port_removable)); 95 memset(port_removable, 0, sizeof(port_removable));
96 for (i = 0; i < ports; i++) { 96 for (i = 0; i < ports; i++) {
97 portsc = xhci_readl(xhci, xhci->usb2_ports[i]); 97 portsc = readl(xhci->usb2_ports[i]);
98 /* If a device is removable, PORTSC reports a 0, same as in the 98 /* If a device is removable, PORTSC reports a 0, same as in the
99 * hub descriptor DeviceRemovable bits. 99 * hub descriptor DeviceRemovable bits.
100 */ 100 */
@@ -148,7 +148,7 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
148 port_removable = 0; 148 port_removable = 0;
149 /* bit 0 is reserved, bit 1 is for port 1, etc. */ 149 /* bit 0 is reserved, bit 1 is for port 1, etc. */
150 for (i = 0; i < ports; i++) { 150 for (i = 0; i < ports; i++) {
151 portsc = xhci_readl(xhci, xhci->usb3_ports[i]); 151 portsc = readl(xhci->usb3_ports[i]);
152 if (portsc & PORT_DEV_REMOVE) 152 if (portsc & PORT_DEV_REMOVE)
153 port_removable |= 1 << (i + 1); 153 port_removable |= 1 << (i + 1);
154 } 154 }
@@ -342,8 +342,8 @@ static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
342 } 342 }
343 343
344 /* Write 1 to disable the port */ 344 /* Write 1 to disable the port */
345 xhci_writel(xhci, port_status | PORT_PE, addr); 345 writel(port_status | PORT_PE, addr);
346 port_status = xhci_readl(xhci, addr); 346 port_status = readl(addr);
347 xhci_dbg(xhci, "disable port, actual port %d status = 0x%x\n", 347 xhci_dbg(xhci, "disable port, actual port %d status = 0x%x\n",
348 wIndex, port_status); 348 wIndex, port_status);
349} 349}
@@ -388,8 +388,8 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
388 return; 388 return;
389 } 389 }
390 /* Change bits are all write 1 to clear */ 390 /* Change bits are all write 1 to clear */
391 xhci_writel(xhci, port_status | status, addr); 391 writel(port_status | status, addr);
392 port_status = xhci_readl(xhci, addr); 392 port_status = readl(addr);
393 xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n", 393 xhci_dbg(xhci, "clear port %s change, actual port %d status = 0x%x\n",
394 port_change_bit, wIndex, port_status); 394 port_change_bit, wIndex, port_status);
395} 395}
@@ -415,11 +415,11 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array,
415{ 415{
416 u32 temp; 416 u32 temp;
417 417
418 temp = xhci_readl(xhci, port_array[port_id]); 418 temp = readl(port_array[port_id]);
419 temp = xhci_port_state_to_neutral(temp); 419 temp = xhci_port_state_to_neutral(temp);
420 temp &= ~PORT_PLS_MASK; 420 temp &= ~PORT_PLS_MASK;
421 temp |= PORT_LINK_STROBE | link_state; 421 temp |= PORT_LINK_STROBE | link_state;
422 xhci_writel(xhci, temp, port_array[port_id]); 422 writel(temp, port_array[port_id]);
423} 423}
424 424
425static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, 425static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
@@ -427,7 +427,7 @@ static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
427{ 427{
428 u32 temp; 428 u32 temp;
429 429
430 temp = xhci_readl(xhci, port_array[port_id]); 430 temp = readl(port_array[port_id]);
431 temp = xhci_port_state_to_neutral(temp); 431 temp = xhci_port_state_to_neutral(temp);
432 432
433 if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_CONNECT) 433 if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_CONNECT)
@@ -445,7 +445,7 @@ static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
445 else 445 else
446 temp &= ~PORT_WKOC_E; 446 temp &= ~PORT_WKOC_E;
447 447
448 xhci_writel(xhci, temp, port_array[port_id]); 448 writel(temp, port_array[port_id]);
449} 449}
450 450
451/* Test and clear port RWC bit */ 451/* Test and clear port RWC bit */
@@ -454,11 +454,11 @@ void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array,
454{ 454{
455 u32 temp; 455 u32 temp;
456 456
457 temp = xhci_readl(xhci, port_array[port_id]); 457 temp = readl(port_array[port_id]);
458 if (temp & port_bit) { 458 if (temp & port_bit) {
459 temp = xhci_port_state_to_neutral(temp); 459 temp = xhci_port_state_to_neutral(temp);
460 temp |= port_bit; 460 temp |= port_bit;
461 xhci_writel(xhci, temp, port_array[port_id]); 461 writel(temp, port_array[port_id]);
462 } 462 }
463} 463}
464 464
@@ -623,8 +623,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
623 } 623 }
624 xhci_ring_device(xhci, slot_id); 624 xhci_ring_device(xhci, slot_id);
625 } else { 625 } else {
626 int port_status = xhci_readl(xhci, 626 int port_status = readl(port_array[wIndex]);
627 port_array[wIndex]);
628 xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n", 627 xhci_warn(xhci, "Port resume took longer than %i msec, port status = 0x%x\n",
629 XHCI_MAX_REXIT_TIMEOUT, 628 XHCI_MAX_REXIT_TIMEOUT,
630 port_status); 629 port_status);
@@ -733,12 +732,12 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
733 /* Set the U1 and U2 exit latencies. */ 732 /* Set the U1 and U2 exit latencies. */
734 memcpy(buf, &usb_bos_descriptor, 733 memcpy(buf, &usb_bos_descriptor,
735 USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE); 734 USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE);
736 temp = xhci_readl(xhci, &xhci->cap_regs->hcs_params3); 735 temp = readl(&xhci->cap_regs->hcs_params3);
737 buf[12] = HCS_U1_LATENCY(temp); 736 buf[12] = HCS_U1_LATENCY(temp);
738 put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]); 737 put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]);
739 738
740 /* Indicate whether the host has LTM support. */ 739 /* Indicate whether the host has LTM support. */
741 temp = xhci_readl(xhci, &xhci->cap_regs->hcc_params); 740 temp = readl(&xhci->cap_regs->hcc_params);
742 if (HCC_LTC(temp)) 741 if (HCC_LTC(temp))
743 buf[8] |= USB_LTM_SUPPORT; 742 buf[8] |= USB_LTM_SUPPORT;
744 743
@@ -748,7 +747,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
748 if (!wIndex || wIndex > max_ports) 747 if (!wIndex || wIndex > max_ports)
749 goto error; 748 goto error;
750 wIndex--; 749 wIndex--;
751 temp = xhci_readl(xhci, port_array[wIndex]); 750 temp = readl(port_array[wIndex]);
752 if (temp == 0xffffffff) { 751 if (temp == 0xffffffff) {
753 retval = -ENODEV; 752 retval = -ENODEV;
754 break; 753 break;
@@ -775,7 +774,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
775 if (!wIndex || wIndex > max_ports) 774 if (!wIndex || wIndex > max_ports)
776 goto error; 775 goto error;
777 wIndex--; 776 wIndex--;
778 temp = xhci_readl(xhci, port_array[wIndex]); 777 temp = readl(port_array[wIndex]);
779 if (temp == 0xffffffff) { 778 if (temp == 0xffffffff) {
780 retval = -ENODEV; 779 retval = -ENODEV;
781 break; 780 break;
@@ -784,7 +783,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
784 /* FIXME: What new port features do we need to support? */ 783 /* FIXME: What new port features do we need to support? */
785 switch (wValue) { 784 switch (wValue) {
786 case USB_PORT_FEAT_SUSPEND: 785 case USB_PORT_FEAT_SUSPEND:
787 temp = xhci_readl(xhci, port_array[wIndex]); 786 temp = readl(port_array[wIndex]);
788 if ((temp & PORT_PLS_MASK) != XDEV_U0) { 787 if ((temp & PORT_PLS_MASK) != XDEV_U0) {
789 /* Resume the port to U0 first */ 788 /* Resume the port to U0 first */
790 xhci_set_link_state(xhci, port_array, wIndex, 789 xhci_set_link_state(xhci, port_array, wIndex,
@@ -797,7 +796,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
797 * a port unless the port reports that it is in the 796 * a port unless the port reports that it is in the
798 * enabled (PED = ‘1’,PLS < ‘3’) state. 797 * enabled (PED = ‘1’,PLS < ‘3’) state.
799 */ 798 */
800 temp = xhci_readl(xhci, port_array[wIndex]); 799 temp = readl(port_array[wIndex]);
801 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) 800 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
802 || (temp & PORT_PLS_MASK) >= XDEV_U3) { 801 || (temp & PORT_PLS_MASK) >= XDEV_U3) {
803 xhci_warn(xhci, "USB core suspending device " 802 xhci_warn(xhci, "USB core suspending device "
@@ -822,11 +821,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
822 msleep(10); /* wait device to enter */ 821 msleep(10); /* wait device to enter */
823 spin_lock_irqsave(&xhci->lock, flags); 822 spin_lock_irqsave(&xhci->lock, flags);
824 823
825 temp = xhci_readl(xhci, port_array[wIndex]); 824 temp = readl(port_array[wIndex]);
826 bus_state->suspended_ports |= 1 << wIndex; 825 bus_state->suspended_ports |= 1 << wIndex;
827 break; 826 break;
828 case USB_PORT_FEAT_LINK_STATE: 827 case USB_PORT_FEAT_LINK_STATE:
829 temp = xhci_readl(xhci, port_array[wIndex]); 828 temp = readl(port_array[wIndex]);
830 829
831 /* Disable port */ 830 /* Disable port */
832 if (link_state == USB_SS_PORT_LS_SS_DISABLED) { 831 if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
@@ -839,9 +838,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
839 temp |= PORT_CSC | PORT_PEC | PORT_WRC | 838 temp |= PORT_CSC | PORT_PEC | PORT_WRC |
840 PORT_OCC | PORT_RC | PORT_PLC | 839 PORT_OCC | PORT_RC | PORT_PLC |
841 PORT_CEC; 840 PORT_CEC;
842 xhci_writel(xhci, temp | PORT_PE, 841 writel(temp | PORT_PE, port_array[wIndex]);
843 port_array[wIndex]); 842 temp = readl(port_array[wIndex]);
844 temp = xhci_readl(xhci, port_array[wIndex]);
845 break; 843 break;
846 } 844 }
847 845
@@ -850,7 +848,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
850 xhci_dbg(xhci, "Enable port %d\n", wIndex); 848 xhci_dbg(xhci, "Enable port %d\n", wIndex);
851 xhci_set_link_state(xhci, port_array, wIndex, 849 xhci_set_link_state(xhci, port_array, wIndex,
852 link_state); 850 link_state);
853 temp = xhci_readl(xhci, port_array[wIndex]); 851 temp = readl(port_array[wIndex]);
854 break; 852 break;
855 } 853 }
856 854
@@ -884,7 +882,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
884 msleep(20); /* wait device to enter */ 882 msleep(20); /* wait device to enter */
885 spin_lock_irqsave(&xhci->lock, flags); 883 spin_lock_irqsave(&xhci->lock, flags);
886 884
887 temp = xhci_readl(xhci, port_array[wIndex]); 885 temp = readl(port_array[wIndex]);
888 if (link_state == USB_SS_PORT_LS_U3) 886 if (link_state == USB_SS_PORT_LS_U3)
889 bus_state->suspended_ports |= 1 << wIndex; 887 bus_state->suspended_ports |= 1 << wIndex;
890 break; 888 break;
@@ -895,10 +893,9 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
895 * However, khubd will ignore the roothub events until 893 * However, khubd will ignore the roothub events until
896 * the roothub is registered. 894 * the roothub is registered.
897 */ 895 */
898 xhci_writel(xhci, temp | PORT_POWER, 896 writel(temp | PORT_POWER, port_array[wIndex]);
899 port_array[wIndex]);
900 897
901 temp = xhci_readl(xhci, port_array[wIndex]); 898 temp = readl(port_array[wIndex]);
902 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp); 899 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp);
903 900
904 spin_unlock_irqrestore(&xhci->lock, flags); 901 spin_unlock_irqrestore(&xhci->lock, flags);
@@ -911,52 +908,52 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
911 break; 908 break;
912 case USB_PORT_FEAT_RESET: 909 case USB_PORT_FEAT_RESET:
913 temp = (temp | PORT_RESET); 910 temp = (temp | PORT_RESET);
914 xhci_writel(xhci, temp, port_array[wIndex]); 911 writel(temp, port_array[wIndex]);
915 912
916 temp = xhci_readl(xhci, port_array[wIndex]); 913 temp = readl(port_array[wIndex]);
917 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); 914 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp);
918 break; 915 break;
919 case USB_PORT_FEAT_REMOTE_WAKE_MASK: 916 case USB_PORT_FEAT_REMOTE_WAKE_MASK:
920 xhci_set_remote_wake_mask(xhci, port_array, 917 xhci_set_remote_wake_mask(xhci, port_array,
921 wIndex, wake_mask); 918 wIndex, wake_mask);
922 temp = xhci_readl(xhci, port_array[wIndex]); 919 temp = readl(port_array[wIndex]);
923 xhci_dbg(xhci, "set port remote wake mask, " 920 xhci_dbg(xhci, "set port remote wake mask, "
924 "actual port %d status = 0x%x\n", 921 "actual port %d status = 0x%x\n",
925 wIndex, temp); 922 wIndex, temp);
926 break; 923 break;
927 case USB_PORT_FEAT_BH_PORT_RESET: 924 case USB_PORT_FEAT_BH_PORT_RESET:
928 temp |= PORT_WR; 925 temp |= PORT_WR;
929 xhci_writel(xhci, temp, port_array[wIndex]); 926 writel(temp, port_array[wIndex]);
930 927
931 temp = xhci_readl(xhci, port_array[wIndex]); 928 temp = readl(port_array[wIndex]);
932 break; 929 break;
933 case USB_PORT_FEAT_U1_TIMEOUT: 930 case USB_PORT_FEAT_U1_TIMEOUT:
934 if (hcd->speed != HCD_USB3) 931 if (hcd->speed != HCD_USB3)
935 goto error; 932 goto error;
936 temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); 933 temp = readl(port_array[wIndex] + PORTPMSC);
937 temp &= ~PORT_U1_TIMEOUT_MASK; 934 temp &= ~PORT_U1_TIMEOUT_MASK;
938 temp |= PORT_U1_TIMEOUT(timeout); 935 temp |= PORT_U1_TIMEOUT(timeout);
939 xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); 936 writel(temp, port_array[wIndex] + PORTPMSC);
940 break; 937 break;
941 case USB_PORT_FEAT_U2_TIMEOUT: 938 case USB_PORT_FEAT_U2_TIMEOUT:
942 if (hcd->speed != HCD_USB3) 939 if (hcd->speed != HCD_USB3)
943 goto error; 940 goto error;
944 temp = xhci_readl(xhci, port_array[wIndex] + PORTPMSC); 941 temp = readl(port_array[wIndex] + PORTPMSC);
945 temp &= ~PORT_U2_TIMEOUT_MASK; 942 temp &= ~PORT_U2_TIMEOUT_MASK;
946 temp |= PORT_U2_TIMEOUT(timeout); 943 temp |= PORT_U2_TIMEOUT(timeout);
947 xhci_writel(xhci, temp, port_array[wIndex] + PORTPMSC); 944 writel(temp, port_array[wIndex] + PORTPMSC);
948 break; 945 break;
949 default: 946 default:
950 goto error; 947 goto error;
951 } 948 }
952 /* unblock any posted writes */ 949 /* unblock any posted writes */
953 temp = xhci_readl(xhci, port_array[wIndex]); 950 temp = readl(port_array[wIndex]);
954 break; 951 break;
955 case ClearPortFeature: 952 case ClearPortFeature:
956 if (!wIndex || wIndex > max_ports) 953 if (!wIndex || wIndex > max_ports)
957 goto error; 954 goto error;
958 wIndex--; 955 wIndex--;
959 temp = xhci_readl(xhci, port_array[wIndex]); 956 temp = readl(port_array[wIndex]);
960 if (temp == 0xffffffff) { 957 if (temp == 0xffffffff) {
961 retval = -ENODEV; 958 retval = -ENODEV;
962 break; 959 break;
@@ -965,7 +962,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
965 temp = xhci_port_state_to_neutral(temp); 962 temp = xhci_port_state_to_neutral(temp);
966 switch (wValue) { 963 switch (wValue) {
967 case USB_PORT_FEAT_SUSPEND: 964 case USB_PORT_FEAT_SUSPEND:
968 temp = xhci_readl(xhci, port_array[wIndex]); 965 temp = readl(port_array[wIndex]);
969 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n"); 966 xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n");
970 xhci_dbg(xhci, "PORTSC %04x\n", temp); 967 xhci_dbg(xhci, "PORTSC %04x\n", temp);
971 if (temp & PORT_RESET) 968 if (temp & PORT_RESET)
@@ -1008,8 +1005,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1008 port_array[wIndex], temp); 1005 port_array[wIndex], temp);
1009 break; 1006 break;
1010 case USB_PORT_FEAT_POWER: 1007 case USB_PORT_FEAT_POWER:
1011 xhci_writel(xhci, temp & ~PORT_POWER, 1008 writel(temp & ~PORT_POWER, port_array[wIndex]);
1012 port_array[wIndex]);
1013 1009
1014 spin_unlock_irqrestore(&xhci->lock, flags); 1010 spin_unlock_irqrestore(&xhci->lock, flags);
1015 temp = usb_acpi_power_manageable(hcd->self.root_hub, 1011 temp = usb_acpi_power_manageable(hcd->self.root_hub,
@@ -1070,7 +1066,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
1070 spin_lock_irqsave(&xhci->lock, flags); 1066 spin_lock_irqsave(&xhci->lock, flags);
1071 /* For each port, did anything change? If so, set that bit in buf. */ 1067 /* For each port, did anything change? If so, set that bit in buf. */
1072 for (i = 0; i < max_ports; i++) { 1068 for (i = 0; i < max_ports; i++) {
1073 temp = xhci_readl(xhci, port_array[i]); 1069 temp = readl(port_array[i]);
1074 if (temp == 0xffffffff) { 1070 if (temp == 0xffffffff) {
1075 retval = -ENODEV; 1071 retval = -ENODEV;
1076 break; 1072 break;
@@ -1124,7 +1120,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1124 u32 t1, t2; 1120 u32 t1, t2;
1125 int slot_id; 1121 int slot_id;
1126 1122
1127 t1 = xhci_readl(xhci, port_array[port_index]); 1123 t1 = readl(port_array[port_index]);
1128 t2 = xhci_port_state_to_neutral(t1); 1124 t2 = xhci_port_state_to_neutral(t1);
1129 1125
1130 if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) { 1126 if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {
@@ -1157,7 +1153,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1157 1153
1158 t1 = xhci_port_state_to_neutral(t1); 1154 t1 = xhci_port_state_to_neutral(t1);
1159 if (t1 != t2) 1155 if (t1 != t2)
1160 xhci_writel(xhci, t2, port_array[port_index]); 1156 writel(t2, port_array[port_index]);
1161 } 1157 }
1162 hcd->state = HC_STATE_SUSPENDED; 1158 hcd->state = HC_STATE_SUSPENDED;
1163 bus_state->next_statechange = jiffies + msecs_to_jiffies(10); 1159 bus_state->next_statechange = jiffies + msecs_to_jiffies(10);
@@ -1187,9 +1183,9 @@ int xhci_bus_resume(struct usb_hcd *hcd)
1187 } 1183 }
1188 1184
1189 /* delay the irqs */ 1185 /* delay the irqs */
1190 temp = xhci_readl(xhci, &xhci->op_regs->command); 1186 temp = readl(&xhci->op_regs->command);
1191 temp &= ~CMD_EIE; 1187 temp &= ~CMD_EIE;
1192 xhci_writel(xhci, temp, &xhci->op_regs->command); 1188 writel(temp, &xhci->op_regs->command);
1193 1189
1194 port_index = max_ports; 1190 port_index = max_ports;
1195 while (port_index--) { 1191 while (port_index--) {
@@ -1198,7 +1194,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
1198 u32 temp; 1194 u32 temp;
1199 int slot_id; 1195 int slot_id;
1200 1196
1201 temp = xhci_readl(xhci, port_array[port_index]); 1197 temp = readl(port_array[port_index]);
1202 if (DEV_SUPERSPEED(temp)) 1198 if (DEV_SUPERSPEED(temp))
1203 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS); 1199 temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
1204 else 1200 else
@@ -1235,17 +1231,17 @@ int xhci_bus_resume(struct usb_hcd *hcd)
1235 if (slot_id) 1231 if (slot_id)
1236 xhci_ring_device(xhci, slot_id); 1232 xhci_ring_device(xhci, slot_id);
1237 } else 1233 } else
1238 xhci_writel(xhci, temp, port_array[port_index]); 1234 writel(temp, port_array[port_index]);
1239 } 1235 }
1240 1236
1241 (void) xhci_readl(xhci, &xhci->op_regs->command); 1237 (void) readl(&xhci->op_regs->command);
1242 1238
1243 bus_state->next_statechange = jiffies + msecs_to_jiffies(5); 1239 bus_state->next_statechange = jiffies + msecs_to_jiffies(5);
1244 /* re-enable irqs */ 1240 /* re-enable irqs */
1245 temp = xhci_readl(xhci, &xhci->op_regs->command); 1241 temp = readl(&xhci->op_regs->command);
1246 temp |= CMD_EIE; 1242 temp |= CMD_EIE;
1247 xhci_writel(xhci, temp, &xhci->op_regs->command); 1243 writel(temp, &xhci->op_regs->command);
1248 temp = xhci_readl(xhci, &xhci->op_regs->command); 1244 temp = readl(&xhci->op_regs->command);
1249 1245
1250 spin_unlock_irqrestore(&xhci->lock, flags); 1246 spin_unlock_irqrestore(&xhci->lock, flags);
1251 return 0; 1247 return 0;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 49b8bd063fab..873c272b3ef5 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -57,7 +57,7 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
57 /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */ 57 /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */
58 if (cycle_state == 0) { 58 if (cycle_state == 0) {
59 for (i = 0; i < TRBS_PER_SEGMENT; i++) 59 for (i = 0; i < TRBS_PER_SEGMENT; i++)
60 seg->trbs[i].link.control |= TRB_CYCLE; 60 seg->trbs[i].link.control |= cpu_to_le32(TRB_CYCLE);
61 } 61 }
62 seg->dma = dma; 62 seg->dma = dma;
63 seg->next = NULL; 63 seg->next = NULL;
@@ -308,7 +308,8 @@ static void xhci_reinit_cached_ring(struct xhci_hcd *xhci,
308 sizeof(union xhci_trb)*TRBS_PER_SEGMENT); 308 sizeof(union xhci_trb)*TRBS_PER_SEGMENT);
309 if (cycle_state == 0) { 309 if (cycle_state == 0) {
310 for (i = 0; i < TRBS_PER_SEGMENT; i++) 310 for (i = 0; i < TRBS_PER_SEGMENT; i++)
311 seg->trbs[i].link.control |= TRB_CYCLE; 311 seg->trbs[i].link.control |=
312 cpu_to_le32(TRB_CYCLE);
312 } 313 }
313 /* All endpoint rings have link TRBs */ 314 /* All endpoint rings have link TRBs */
314 xhci_link_segments(xhci, seg, seg->next, type); 315 xhci_link_segments(xhci, seg, seg->next, type);
@@ -432,10 +433,10 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci,
432 unsigned int num_stream_ctxs, 433 unsigned int num_stream_ctxs,
433 struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) 434 struct xhci_stream_ctx *stream_ctx, dma_addr_t dma)
434{ 435{
435 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 436 struct device *dev = xhci_to_hcd(xhci)->self.controller;
436 437
437 if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) 438 if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE)
438 dma_free_coherent(&pdev->dev, 439 dma_free_coherent(dev,
439 sizeof(struct xhci_stream_ctx)*num_stream_ctxs, 440 sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
440 stream_ctx, dma); 441 stream_ctx, dma);
441 else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) 442 else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE)
@@ -460,10 +461,10 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci,
460 unsigned int num_stream_ctxs, dma_addr_t *dma, 461 unsigned int num_stream_ctxs, dma_addr_t *dma,
461 gfp_t mem_flags) 462 gfp_t mem_flags)
462{ 463{
463 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 464 struct device *dev = xhci_to_hcd(xhci)->self.controller;
464 465
465 if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) 466 if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE)
466 return dma_alloc_coherent(&pdev->dev, 467 return dma_alloc_coherent(dev,
467 sizeof(struct xhci_stream_ctx)*num_stream_ctxs, 468 sizeof(struct xhci_stream_ctx)*num_stream_ctxs,
468 dma, mem_flags); 469 dma, mem_flags);
469 else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) 470 else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE)
@@ -721,8 +722,7 @@ void xhci_free_stream_info(struct xhci_hcd *xhci,
721 stream_info->stream_ctx_array, 722 stream_info->stream_ctx_array,
722 stream_info->ctx_array_dma); 723 stream_info->ctx_array_dma);
723 724
724 if (stream_info) 725 kfree(stream_info->stream_rings);
725 kfree(stream_info->stream_rings);
726 kfree(stream_info); 726 kfree(stream_info);
727} 727}
728 728
@@ -1616,7 +1616,7 @@ static void scratchpad_free(struct xhci_hcd *xhci)
1616{ 1616{
1617 int num_sp; 1617 int num_sp;
1618 int i; 1618 int i;
1619 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 1619 struct device *dev = xhci_to_hcd(xhci)->self.controller;
1620 1620
1621 if (!xhci->scratchpad) 1621 if (!xhci->scratchpad)
1622 return; 1622 return;
@@ -1624,13 +1624,13 @@ static void scratchpad_free(struct xhci_hcd *xhci)
1624 num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); 1624 num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2);
1625 1625
1626 for (i = 0; i < num_sp; i++) { 1626 for (i = 0; i < num_sp; i++) {
1627 dma_free_coherent(&pdev->dev, xhci->page_size, 1627 dma_free_coherent(dev, xhci->page_size,
1628 xhci->scratchpad->sp_buffers[i], 1628 xhci->scratchpad->sp_buffers[i],
1629 xhci->scratchpad->sp_dma_buffers[i]); 1629 xhci->scratchpad->sp_dma_buffers[i]);
1630 } 1630 }
1631 kfree(xhci->scratchpad->sp_dma_buffers); 1631 kfree(xhci->scratchpad->sp_dma_buffers);
1632 kfree(xhci->scratchpad->sp_buffers); 1632 kfree(xhci->scratchpad->sp_buffers);
1633 dma_free_coherent(&pdev->dev, num_sp * sizeof(u64), 1633 dma_free_coherent(dev, num_sp * sizeof(u64),
1634 xhci->scratchpad->sp_array, 1634 xhci->scratchpad->sp_array,
1635 xhci->scratchpad->sp_dma); 1635 xhci->scratchpad->sp_dma);
1636 kfree(xhci->scratchpad); 1636 kfree(xhci->scratchpad);
@@ -1692,7 +1692,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
1692 1692
1693void xhci_mem_cleanup(struct xhci_hcd *xhci) 1693void xhci_mem_cleanup(struct xhci_hcd *xhci)
1694{ 1694{
1695 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 1695 struct device *dev = xhci_to_hcd(xhci)->self.controller;
1696 struct xhci_cd *cur_cd, *next_cd; 1696 struct xhci_cd *cur_cd, *next_cd;
1697 int size; 1697 int size;
1698 int i, j, num_ports; 1698 int i, j, num_ports;
@@ -1700,7 +1700,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1700 /* Free the Event Ring Segment Table and the actual Event Ring */ 1700 /* Free the Event Ring Segment Table and the actual Event Ring */
1701 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); 1701 size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
1702 if (xhci->erst.entries) 1702 if (xhci->erst.entries)
1703 dma_free_coherent(&pdev->dev, size, 1703 dma_free_coherent(dev, size,
1704 xhci->erst.entries, xhci->erst.erst_dma_addr); 1704 xhci->erst.entries, xhci->erst.erst_dma_addr);
1705 xhci->erst.entries = NULL; 1705 xhci->erst.entries = NULL;
1706 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed ERST"); 1706 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Freed ERST");
@@ -1748,7 +1748,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1748 "Freed medium stream array pool"); 1748 "Freed medium stream array pool");
1749 1749
1750 if (xhci->dcbaa) 1750 if (xhci->dcbaa)
1751 dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa), 1751 dma_free_coherent(dev, sizeof(*xhci->dcbaa),
1752 xhci->dcbaa, xhci->dcbaa->dma); 1752 xhci->dcbaa, xhci->dcbaa->dma);
1753 xhci->dcbaa = NULL; 1753 xhci->dcbaa = NULL;
1754 1754
@@ -1958,7 +1958,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
1958 xhci_warn(xhci, "WARN something wrong with SW event ring " 1958 xhci_warn(xhci, "WARN something wrong with SW event ring "
1959 "dequeue ptr.\n"); 1959 "dequeue ptr.\n");
1960 /* Update HC event ring dequeue pointer */ 1960 /* Update HC event ring dequeue pointer */
1961 temp = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 1961 temp = readq(&xhci->ir_set->erst_dequeue);
1962 temp &= ERST_PTR_MASK; 1962 temp &= ERST_PTR_MASK;
1963 /* Don't clear the EHB bit (which is RW1C) because 1963 /* Don't clear the EHB bit (which is RW1C) because
1964 * there might be more events to service. 1964 * there might be more events to service.
@@ -1967,7 +1967,7 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
1967 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1967 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
1968 "// Write event ring dequeue pointer, " 1968 "// Write event ring dequeue pointer, "
1969 "preserving EHB bit"); 1969 "preserving EHB bit");
1970 xhci_write_64(xhci, ((u64) deq & (u64) ~ERST_PTR_MASK) | temp, 1970 writeq(((u64) deq & (u64) ~ERST_PTR_MASK) | temp,
1971 &xhci->ir_set->erst_dequeue); 1971 &xhci->ir_set->erst_dequeue);
1972} 1972}
1973 1973
@@ -1986,7 +1986,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
1986 } 1986 }
1987 1987
1988 /* Port offset and count in the third dword, see section 7.2 */ 1988 /* Port offset and count in the third dword, see section 7.2 */
1989 temp = xhci_readl(xhci, addr + 2); 1989 temp = readl(addr + 2);
1990 port_offset = XHCI_EXT_PORT_OFF(temp); 1990 port_offset = XHCI_EXT_PORT_OFF(temp);
1991 port_count = XHCI_EXT_PORT_COUNT(temp); 1991 port_count = XHCI_EXT_PORT_COUNT(temp);
1992 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 1992 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -2069,7 +2069,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2069 int cap_count = 0; 2069 int cap_count = 0;
2070 2070
2071 addr = &xhci->cap_regs->hcc_params; 2071 addr = &xhci->cap_regs->hcc_params;
2072 offset = XHCI_HCC_EXT_CAPS(xhci_readl(xhci, addr)); 2072 offset = XHCI_HCC_EXT_CAPS(readl(addr));
2073 if (offset == 0) { 2073 if (offset == 0) {
2074 xhci_err(xhci, "No Extended Capability registers, " 2074 xhci_err(xhci, "No Extended Capability registers, "
2075 "unable to set up roothub.\n"); 2075 "unable to set up roothub.\n");
@@ -2106,7 +2106,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2106 /* count extended protocol capability entries for later caching */ 2106 /* count extended protocol capability entries for later caching */
2107 do { 2107 do {
2108 u32 cap_id; 2108 u32 cap_id;
2109 cap_id = xhci_readl(xhci, tmp_addr); 2109 cap_id = readl(tmp_addr);
2110 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL) 2110 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
2111 cap_count++; 2111 cap_count++;
2112 tmp_offset = XHCI_EXT_CAPS_NEXT(cap_id); 2112 tmp_offset = XHCI_EXT_CAPS_NEXT(cap_id);
@@ -2120,7 +2120,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2120 while (1) { 2120 while (1) {
2121 u32 cap_id; 2121 u32 cap_id;
2122 2122
2123 cap_id = xhci_readl(xhci, addr); 2123 cap_id = readl(addr);
2124 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL) 2124 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
2125 xhci_add_in_port(xhci, num_ports, addr, 2125 xhci_add_in_port(xhci, num_ports, addr,
2126 (u8) XHCI_EXT_PORT_MAJOR(cap_id), 2126 (u8) XHCI_EXT_PORT_MAJOR(cap_id),
@@ -2224,7 +2224,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2224 2224
2225 INIT_LIST_HEAD(&xhci->cancel_cmd_list); 2225 INIT_LIST_HEAD(&xhci->cancel_cmd_list);
2226 2226
2227 page_size = xhci_readl(xhci, &xhci->op_regs->page_size); 2227 page_size = readl(&xhci->op_regs->page_size);
2228 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2228 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2229 "Supported page size register = 0x%x", page_size); 2229 "Supported page size register = 0x%x", page_size);
2230 for (i = 0; i < 16; i++) { 2230 for (i = 0; i < 16; i++) {
@@ -2247,14 +2247,14 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2247 * Program the Number of Device Slots Enabled field in the CONFIG 2247 * Program the Number of Device Slots Enabled field in the CONFIG
2248 * register with the max value of slots the HC can handle. 2248 * register with the max value of slots the HC can handle.
2249 */ 2249 */
2250 val = HCS_MAX_SLOTS(xhci_readl(xhci, &xhci->cap_regs->hcs_params1)); 2250 val = HCS_MAX_SLOTS(readl(&xhci->cap_regs->hcs_params1));
2251 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2251 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2252 "// xHC can handle at most %d device slots.", val); 2252 "// xHC can handle at most %d device slots.", val);
2253 val2 = xhci_readl(xhci, &xhci->op_regs->config_reg); 2253 val2 = readl(&xhci->op_regs->config_reg);
2254 val |= (val2 & ~HCS_SLOTS_MASK); 2254 val |= (val2 & ~HCS_SLOTS_MASK);
2255 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2255 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2256 "// Setting Max device slots reg = 0x%x.", val); 2256 "// Setting Max device slots reg = 0x%x.", val);
2257 xhci_writel(xhci, val, &xhci->op_regs->config_reg); 2257 writel(val, &xhci->op_regs->config_reg);
2258 2258
2259 /* 2259 /*
2260 * Section 5.4.8 - doorbell array must be 2260 * Section 5.4.8 - doorbell array must be
@@ -2269,7 +2269,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2269 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2269 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2270 "// Device context base array address = 0x%llx (DMA), %p (virt)", 2270 "// Device context base array address = 0x%llx (DMA), %p (virt)",
2271 (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa); 2271 (unsigned long long)xhci->dcbaa->dma, xhci->dcbaa);
2272 xhci_write_64(xhci, dma, &xhci->op_regs->dcbaa_ptr); 2272 writeq(dma, &xhci->op_regs->dcbaa_ptr);
2273 2273
2274 /* 2274 /*
2275 * Initialize the ring segment pool. The ring must be a contiguous 2275 * Initialize the ring segment pool. The ring must be a contiguous
@@ -2312,13 +2312,13 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2312 (unsigned long long)xhci->cmd_ring->first_seg->dma); 2312 (unsigned long long)xhci->cmd_ring->first_seg->dma);
2313 2313
2314 /* Set the address in the Command Ring Control register */ 2314 /* Set the address in the Command Ring Control register */
2315 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 2315 val_64 = readq(&xhci->op_regs->cmd_ring);
2316 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) | 2316 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
2317 (xhci->cmd_ring->first_seg->dma & (u64) ~CMD_RING_RSVD_BITS) | 2317 (xhci->cmd_ring->first_seg->dma & (u64) ~CMD_RING_RSVD_BITS) |
2318 xhci->cmd_ring->cycle_state; 2318 xhci->cmd_ring->cycle_state;
2319 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2319 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2320 "// Setting command ring address to 0x%x", val); 2320 "// Setting command ring address to 0x%x", val);
2321 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring); 2321 writeq(val_64, &xhci->op_regs->cmd_ring);
2322 xhci_dbg_cmd_ptrs(xhci); 2322 xhci_dbg_cmd_ptrs(xhci);
2323 2323
2324 xhci->lpm_command = xhci_alloc_command(xhci, true, true, flags); 2324 xhci->lpm_command = xhci_alloc_command(xhci, true, true, flags);
@@ -2331,7 +2331,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2331 */ 2331 */
2332 xhci->cmd_ring_reserved_trbs++; 2332 xhci->cmd_ring_reserved_trbs++;
2333 2333
2334 val = xhci_readl(xhci, &xhci->cap_regs->db_off); 2334 val = readl(&xhci->cap_regs->db_off);
2335 val &= DBOFF_MASK; 2335 val &= DBOFF_MASK;
2336 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2336 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2337 "// Doorbell array is located at offset 0x%x" 2337 "// Doorbell array is located at offset 0x%x"
@@ -2382,13 +2382,13 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2382 } 2382 }
2383 2383
2384 /* set ERST count with the number of entries in the segment table */ 2384 /* set ERST count with the number of entries in the segment table */
2385 val = xhci_readl(xhci, &xhci->ir_set->erst_size); 2385 val = readl(&xhci->ir_set->erst_size);
2386 val &= ERST_SIZE_MASK; 2386 val &= ERST_SIZE_MASK;
2387 val |= ERST_NUM_SEGS; 2387 val |= ERST_NUM_SEGS;
2388 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2388 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2389 "// Write ERST size = %i to ir_set 0 (some bits preserved)", 2389 "// Write ERST size = %i to ir_set 0 (some bits preserved)",
2390 val); 2390 val);
2391 xhci_writel(xhci, val, &xhci->ir_set->erst_size); 2391 writel(val, &xhci->ir_set->erst_size);
2392 2392
2393 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2393 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2394 "// Set ERST entries to point to event ring."); 2394 "// Set ERST entries to point to event ring.");
@@ -2396,10 +2396,10 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2396 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2396 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2397 "// Set ERST base address for ir_set 0 = 0x%llx", 2397 "// Set ERST base address for ir_set 0 = 0x%llx",
2398 (unsigned long long)xhci->erst.erst_dma_addr); 2398 (unsigned long long)xhci->erst.erst_dma_addr);
2399 val_64 = xhci_read_64(xhci, &xhci->ir_set->erst_base); 2399 val_64 = readq(&xhci->ir_set->erst_base);
2400 val_64 &= ERST_PTR_MASK; 2400 val_64 &= ERST_PTR_MASK;
2401 val_64 |= (xhci->erst.erst_dma_addr & (u64) ~ERST_PTR_MASK); 2401 val_64 |= (xhci->erst.erst_dma_addr & (u64) ~ERST_PTR_MASK);
2402 xhci_write_64(xhci, val_64, &xhci->ir_set->erst_base); 2402 writeq(val_64, &xhci->ir_set->erst_base);
2403 2403
2404 /* Set the event ring dequeue address */ 2404 /* Set the event ring dequeue address */
2405 xhci_set_hc_event_deq(xhci); 2405 xhci_set_hc_event_deq(xhci);
@@ -2431,10 +2431,10 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
2431 * is necessary for allowing USB 3.0 devices to do remote wakeup from 2431 * is necessary for allowing USB 3.0 devices to do remote wakeup from
2432 * U3 (device suspend). 2432 * U3 (device suspend).
2433 */ 2433 */
2434 temp = xhci_readl(xhci, &xhci->op_regs->dev_notification); 2434 temp = readl(&xhci->op_regs->dev_notification);
2435 temp &= ~DEV_NOTE_MASK; 2435 temp &= ~DEV_NOTE_MASK;
2436 temp |= DEV_NOTE_FWAKE; 2436 temp |= DEV_NOTE_FWAKE;
2437 xhci_writel(xhci, temp, &xhci->op_regs->dev_notification); 2437 writel(temp, &xhci->op_regs->dev_notification);
2438 2438
2439 return 0; 2439 return 0;
2440 2440
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index b8dffd59eb25..4221dee924b5 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -331,6 +331,7 @@ static const struct hc_driver xhci_pci_hc_driver = {
331 .check_bandwidth = xhci_check_bandwidth, 331 .check_bandwidth = xhci_check_bandwidth,
332 .reset_bandwidth = xhci_reset_bandwidth, 332 .reset_bandwidth = xhci_reset_bandwidth,
333 .address_device = xhci_address_device, 333 .address_device = xhci_address_device,
334 .enable_device = xhci_enable_device,
334 .update_hub_device = xhci_update_hub_device, 335 .update_hub_device = xhci_update_hub_device,
335 .reset_device = xhci_discover_or_reset_device, 336 .reset_device = xhci_discover_or_reset_device,
336 337
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d9c169f470d3..8abda5c73ca1 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -69,6 +69,7 @@ static const struct hc_driver xhci_plat_xhci_driver = {
69 .check_bandwidth = xhci_check_bandwidth, 69 .check_bandwidth = xhci_check_bandwidth,
70 .reset_bandwidth = xhci_reset_bandwidth, 70 .reset_bandwidth = xhci_reset_bandwidth,
71 .address_device = xhci_address_device, 71 .address_device = xhci_address_device,
72 .enable_device = xhci_enable_device,
72 .update_hub_device = xhci_update_hub_device, 73 .update_hub_device = xhci_update_hub_device,
73 .reset_device = xhci_discover_or_reset_device, 74 .reset_device = xhci_discover_or_reset_device,
74 75
@@ -139,6 +140,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
139 ret = usb_add_hcd(hcd, irq, IRQF_SHARED); 140 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
140 if (ret) 141 if (ret)
141 goto unmap_registers; 142 goto unmap_registers;
143 device_wakeup_enable(hcd->self.controller);
142 144
143 /* USB 2.0 roothub is stored in the platform_device now. */ 145 /* USB 2.0 roothub is stored in the platform_device now. */
144 hcd = platform_get_drvdata(pdev); 146 hcd = platform_get_drvdata(pdev);
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 53c2e296467f..c06df38b57b0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -295,9 +295,9 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci)
295 return; 295 return;
296 296
297 xhci_dbg(xhci, "// Ding dong!\n"); 297 xhci_dbg(xhci, "// Ding dong!\n");
298 xhci_writel(xhci, DB_VALUE_HOST, &xhci->dba->doorbell[0]); 298 writel(DB_VALUE_HOST, &xhci->dba->doorbell[0]);
299 /* Flush PCI posted writes */ 299 /* Flush PCI posted writes */
300 xhci_readl(xhci, &xhci->dba->doorbell[0]); 300 readl(&xhci->dba->doorbell[0]);
301} 301}
302 302
303static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) 303static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
@@ -313,14 +313,13 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
313 return 0; 313 return 0;
314 } 314 }
315 315
316 temp_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 316 temp_64 = readq(&xhci->op_regs->cmd_ring);
317 if (!(temp_64 & CMD_RING_RUNNING)) { 317 if (!(temp_64 & CMD_RING_RUNNING)) {
318 xhci_dbg(xhci, "Command ring had been stopped\n"); 318 xhci_dbg(xhci, "Command ring had been stopped\n");
319 return 0; 319 return 0;
320 } 320 }
321 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED; 321 xhci->cmd_ring_state = CMD_RING_STATE_ABORTED;
322 xhci_write_64(xhci, temp_64 | CMD_RING_ABORT, 322 writeq(temp_64 | CMD_RING_ABORT, &xhci->op_regs->cmd_ring);
323 &xhci->op_regs->cmd_ring);
324 323
325 /* Section 4.6.1.2 of xHCI 1.0 spec says software should 324 /* Section 4.6.1.2 of xHCI 1.0 spec says software should
326 * time the completion od all xHCI commands, including 325 * time the completion od all xHCI commands, including
@@ -427,7 +426,7 @@ void xhci_ring_ep_doorbell(struct xhci_hcd *xhci,
427 if ((ep_state & EP_HALT_PENDING) || (ep_state & SET_DEQ_PENDING) || 426 if ((ep_state & EP_HALT_PENDING) || (ep_state & SET_DEQ_PENDING) ||
428 (ep_state & EP_HALTED)) 427 (ep_state & EP_HALTED))
429 return; 428 return;
430 xhci_writel(xhci, DB_VALUE(ep_index, stream_id), db_addr); 429 writel(DB_VALUE(ep_index, stream_id), db_addr);
431 /* The CPU has better things to do at this point than wait for a 430 /* The CPU has better things to do at this point than wait for a
432 * write-posting flush. It'll get there soon enough. 431 * write-posting flush. It'll get there soon enough.
433 */ 432 */
@@ -1655,7 +1654,7 @@ static void handle_device_notification(struct xhci_hcd *xhci,
1655 u32 slot_id; 1654 u32 slot_id;
1656 struct usb_device *udev; 1655 struct usb_device *udev;
1657 1656
1658 slot_id = TRB_TO_SLOT_ID(event->generic.field[3]); 1657 slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->generic.field[3]));
1659 if (!xhci->devs[slot_id]) { 1658 if (!xhci->devs[slot_id]) {
1660 xhci_warn(xhci, "Device Notification event for " 1659 xhci_warn(xhci, "Device Notification event for "
1661 "unused slot %u\n", slot_id); 1660 "unused slot %u\n", slot_id);
@@ -1739,7 +1738,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1739 faked_port_index = find_faked_portnum_from_hw_portnum(hcd, xhci, 1738 faked_port_index = find_faked_portnum_from_hw_portnum(hcd, xhci,
1740 port_id); 1739 port_id);
1741 1740
1742 temp = xhci_readl(xhci, port_array[faked_port_index]); 1741 temp = readl(port_array[faked_port_index]);
1743 if (hcd->state == HC_STATE_SUSPENDED) { 1742 if (hcd->state == HC_STATE_SUSPENDED) {
1744 xhci_dbg(xhci, "resume root hub\n"); 1743 xhci_dbg(xhci, "resume root hub\n");
1745 usb_hcd_resume_root_hub(hcd); 1744 usb_hcd_resume_root_hub(hcd);
@@ -1748,7 +1747,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1748 if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_RESUME) { 1747 if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_RESUME) {
1749 xhci_dbg(xhci, "port resume event for port %d\n", port_id); 1748 xhci_dbg(xhci, "port resume event for port %d\n", port_id);
1750 1749
1751 temp1 = xhci_readl(xhci, &xhci->op_regs->command); 1750 temp1 = readl(&xhci->op_regs->command);
1752 if (!(temp1 & CMD_RUN)) { 1751 if (!(temp1 & CMD_RUN)) {
1753 xhci_warn(xhci, "xHC is not running.\n"); 1752 xhci_warn(xhci, "xHC is not running.\n");
1754 goto cleanup; 1753 goto cleanup;
@@ -2831,7 +2830,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2831 2830
2832 spin_lock(&xhci->lock); 2831 spin_lock(&xhci->lock);
2833 /* Check if the xHC generated the interrupt, or the irq is shared */ 2832 /* Check if the xHC generated the interrupt, or the irq is shared */
2834 status = xhci_readl(xhci, &xhci->op_regs->status); 2833 status = readl(&xhci->op_regs->status);
2835 if (status == 0xffffffff) 2834 if (status == 0xffffffff)
2836 goto hw_died; 2835 goto hw_died;
2837 2836
@@ -2853,16 +2852,16 @@ hw_died:
2853 * Write 1 to clear the interrupt status. 2852 * Write 1 to clear the interrupt status.
2854 */ 2853 */
2855 status |= STS_EINT; 2854 status |= STS_EINT;
2856 xhci_writel(xhci, status, &xhci->op_regs->status); 2855 writel(status, &xhci->op_regs->status);
2857 /* FIXME when MSI-X is supported and there are multiple vectors */ 2856 /* FIXME when MSI-X is supported and there are multiple vectors */
2858 /* Clear the MSI-X event interrupt status */ 2857 /* Clear the MSI-X event interrupt status */
2859 2858
2860 if (hcd->irq) { 2859 if (hcd->irq) {
2861 u32 irq_pending; 2860 u32 irq_pending;
2862 /* Acknowledge the PCI interrupt */ 2861 /* Acknowledge the PCI interrupt */
2863 irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); 2862 irq_pending = readl(&xhci->ir_set->irq_pending);
2864 irq_pending |= IMAN_IP; 2863 irq_pending |= IMAN_IP;
2865 xhci_writel(xhci, irq_pending, &xhci->ir_set->irq_pending); 2864 writel(irq_pending, &xhci->ir_set->irq_pending);
2866 } 2865 }
2867 2866
2868 if (xhci->xhc_state & XHCI_STATE_DYING) { 2867 if (xhci->xhc_state & XHCI_STATE_DYING) {
@@ -2871,9 +2870,8 @@ hw_died:
2871 /* Clear the event handler busy flag (RW1C); 2870 /* Clear the event handler busy flag (RW1C);
2872 * the event ring should be empty. 2871 * the event ring should be empty.
2873 */ 2872 */
2874 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 2873 temp_64 = readq(&xhci->ir_set->erst_dequeue);
2875 xhci_write_64(xhci, temp_64 | ERST_EHB, 2874 writeq(temp_64 | ERST_EHB, &xhci->ir_set->erst_dequeue);
2876 &xhci->ir_set->erst_dequeue);
2877 spin_unlock(&xhci->lock); 2875 spin_unlock(&xhci->lock);
2878 2876
2879 return IRQ_HANDLED; 2877 return IRQ_HANDLED;
@@ -2885,7 +2883,7 @@ hw_died:
2885 */ 2883 */
2886 while (xhci_handle_event(xhci) > 0) {} 2884 while (xhci_handle_event(xhci) > 0) {}
2887 2885
2888 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 2886 temp_64 = readq(&xhci->ir_set->erst_dequeue);
2889 /* If necessary, update the HW's version of the event ring deq ptr. */ 2887 /* If necessary, update the HW's version of the event ring deq ptr. */
2890 if (event_ring_deq != xhci->event_ring->dequeue) { 2888 if (event_ring_deq != xhci->event_ring->dequeue) {
2891 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg, 2889 deq = xhci_trb_virt_to_dma(xhci->event_ring->deq_seg,
@@ -2900,7 +2898,7 @@ hw_died:
2900 2898
2901 /* Clear the event handler busy flag (RW1C); event ring is empty. */ 2899 /* Clear the event handler busy flag (RW1C); event ring is empty. */
2902 temp_64 |= ERST_EHB; 2900 temp_64 |= ERST_EHB;
2903 xhci_write_64(xhci, temp_64, &xhci->ir_set->erst_dequeue); 2901 writeq(temp_64, &xhci->ir_set->erst_dequeue);
2904 2902
2905 spin_unlock(&xhci->lock); 2903 spin_unlock(&xhci->lock);
2906 2904
@@ -3981,7 +3979,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
3981 if (ret) 3979 if (ret)
3982 return ret; 3980 return ret;
3983 3981
3984 start_frame = xhci_readl(xhci, &xhci->run_regs->microframe_index); 3982 start_frame = readl(&xhci->run_regs->microframe_index);
3985 start_frame &= 0x3fff; 3983 start_frame &= 0x3fff;
3986 3984
3987 urb->start_frame = start_frame; 3985 urb->start_frame = start_frame;
@@ -4056,12 +4054,12 @@ int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id)
4056 4054
4057/* Queue an address device command TRB */ 4055/* Queue an address device command TRB */
4058int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, 4056int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
4059 u32 slot_id) 4057 u32 slot_id, enum xhci_setup_dev setup)
4060{ 4058{
4061 return queue_command(xhci, lower_32_bits(in_ctx_ptr), 4059 return queue_command(xhci, lower_32_bits(in_ctx_ptr),
4062 upper_32_bits(in_ctx_ptr), 0, 4060 upper_32_bits(in_ctx_ptr), 0,
4063 TRB_TYPE(TRB_ADDR_DEV) | SLOT_ID_FOR_TRB(slot_id), 4061 TRB_TYPE(TRB_ADDR_DEV) | SLOT_ID_FOR_TRB(slot_id)
4064 false); 4062 | (setup == SETUP_CONTEXT_ONLY ? TRB_BSR : 0), false);
4065} 4063}
4066 4064
4067int xhci_queue_vendor_command(struct xhci_hcd *xhci, 4065int xhci_queue_vendor_command(struct xhci_hcd *xhci,
diff --git a/drivers/usb/host/xhci-trace.h b/drivers/usb/host/xhci-trace.h
index 20364cc8d2fb..dde3959b7a33 100644
--- a/drivers/usb/host/xhci-trace.h
+++ b/drivers/usb/host/xhci-trace.h
@@ -116,12 +116,12 @@ DECLARE_EVENT_CLASS(xhci_log_event,
116 __field(u64, dma) 116 __field(u64, dma)
117 __field(u32, status) 117 __field(u32, status)
118 __field(u32, flags) 118 __field(u32, flags)
119 __dynamic_array(__le32, trb, 4) 119 __dynamic_array(u8, trb, sizeof(struct xhci_generic_trb))
120 ), 120 ),
121 TP_fast_assign( 121 TP_fast_assign(
122 __entry->va = trb_va; 122 __entry->va = trb_va;
123 __entry->dma = le64_to_cpu(((u64)ev->field[1]) << 32 | 123 __entry->dma = ((u64)le32_to_cpu(ev->field[1])) << 32 |
124 ev->field[0]); 124 le32_to_cpu(ev->field[0]);
125 __entry->status = le32_to_cpu(ev->field[2]); 125 __entry->status = le32_to_cpu(ev->field[2]);
126 __entry->flags = le32_to_cpu(ev->field[3]); 126 __entry->flags = le32_to_cpu(ev->field[3]);
127 memcpy(__get_dynamic_array(trb), trb_va, 127 memcpy(__get_dynamic_array(trb), trb_va,
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 4265b48856f6..d68ec1aa473d 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -60,7 +60,7 @@ int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,
60 u32 result; 60 u32 result;
61 61
62 do { 62 do {
63 result = xhci_readl(xhci, ptr); 63 result = readl(ptr);
64 if (result == ~(u32)0) /* card removed */ 64 if (result == ~(u32)0) /* card removed */
65 return -ENODEV; 65 return -ENODEV;
66 result &= mask; 66 result &= mask;
@@ -82,13 +82,13 @@ void xhci_quiesce(struct xhci_hcd *xhci)
82 u32 mask; 82 u32 mask;
83 83
84 mask = ~(XHCI_IRQS); 84 mask = ~(XHCI_IRQS);
85 halted = xhci_readl(xhci, &xhci->op_regs->status) & STS_HALT; 85 halted = readl(&xhci->op_regs->status) & STS_HALT;
86 if (!halted) 86 if (!halted)
87 mask &= ~CMD_RUN; 87 mask &= ~CMD_RUN;
88 88
89 cmd = xhci_readl(xhci, &xhci->op_regs->command); 89 cmd = readl(&xhci->op_regs->command);
90 cmd &= mask; 90 cmd &= mask;
91 xhci_writel(xhci, cmd, &xhci->op_regs->command); 91 writel(cmd, &xhci->op_regs->command);
92} 92}
93 93
94/* 94/*
@@ -124,11 +124,11 @@ static int xhci_start(struct xhci_hcd *xhci)
124 u32 temp; 124 u32 temp;
125 int ret; 125 int ret;
126 126
127 temp = xhci_readl(xhci, &xhci->op_regs->command); 127 temp = readl(&xhci->op_regs->command);
128 temp |= (CMD_RUN); 128 temp |= (CMD_RUN);
129 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Turn on HC, cmd = 0x%x.", 129 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Turn on HC, cmd = 0x%x.",
130 temp); 130 temp);
131 xhci_writel(xhci, temp, &xhci->op_regs->command); 131 writel(temp, &xhci->op_regs->command);
132 132
133 /* 133 /*
134 * Wait for the HCHalted Status bit to be 0 to indicate the host is 134 * Wait for the HCHalted Status bit to be 0 to indicate the host is
@@ -158,16 +158,16 @@ int xhci_reset(struct xhci_hcd *xhci)
158 u32 state; 158 u32 state;
159 int ret, i; 159 int ret, i;
160 160
161 state = xhci_readl(xhci, &xhci->op_regs->status); 161 state = readl(&xhci->op_regs->status);
162 if ((state & STS_HALT) == 0) { 162 if ((state & STS_HALT) == 0) {
163 xhci_warn(xhci, "Host controller not halted, aborting reset.\n"); 163 xhci_warn(xhci, "Host controller not halted, aborting reset.\n");
164 return 0; 164 return 0;
165 } 165 }
166 166
167 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC"); 167 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC");
168 command = xhci_readl(xhci, &xhci->op_regs->command); 168 command = readl(&xhci->op_regs->command);
169 command |= CMD_RESET; 169 command |= CMD_RESET;
170 xhci_writel(xhci, command, &xhci->op_regs->command); 170 writel(command, &xhci->op_regs->command);
171 171
172 ret = xhci_handshake(xhci, &xhci->op_regs->command, 172 ret = xhci_handshake(xhci, &xhci->op_regs->command,
173 CMD_RESET, 0, 10 * 1000 * 1000); 173 CMD_RESET, 0, 10 * 1000 * 1000);
@@ -422,7 +422,7 @@ static void compliance_mode_recovery(unsigned long arg)
422 xhci = (struct xhci_hcd *)arg; 422 xhci = (struct xhci_hcd *)arg;
423 423
424 for (i = 0; i < xhci->num_usb3_ports; i++) { 424 for (i = 0; i < xhci->num_usb3_ports; i++) {
425 temp = xhci_readl(xhci, xhci->usb3_ports[i]); 425 temp = readl(xhci->usb3_ports[i]);
426 if ((temp & PORT_PLS_MASK) == USB_SS_PORT_LS_COMP_MOD) { 426 if ((temp & PORT_PLS_MASK) == USB_SS_PORT_LS_COMP_MOD) {
427 /* 427 /*
428 * Compliance Mode Detected. Letting USB Core 428 * Compliance Mode Detected. Letting USB Core
@@ -604,31 +604,30 @@ int xhci_run(struct usb_hcd *hcd)
604 xhci_dbg(xhci, "Event ring:\n"); 604 xhci_dbg(xhci, "Event ring:\n");
605 xhci_debug_ring(xhci, xhci->event_ring); 605 xhci_debug_ring(xhci, xhci->event_ring);
606 xhci_dbg_ring_ptrs(xhci, xhci->event_ring); 606 xhci_dbg_ring_ptrs(xhci, xhci->event_ring);
607 temp_64 = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 607 temp_64 = readq(&xhci->ir_set->erst_dequeue);
608 temp_64 &= ~ERST_PTR_MASK; 608 temp_64 &= ~ERST_PTR_MASK;
609 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 609 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
610 "ERST deq = 64'h%0lx", (long unsigned int) temp_64); 610 "ERST deq = 64'h%0lx", (long unsigned int) temp_64);
611 611
612 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 612 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
613 "// Set the interrupt modulation register"); 613 "// Set the interrupt modulation register");
614 temp = xhci_readl(xhci, &xhci->ir_set->irq_control); 614 temp = readl(&xhci->ir_set->irq_control);
615 temp &= ~ER_IRQ_INTERVAL_MASK; 615 temp &= ~ER_IRQ_INTERVAL_MASK;
616 temp |= (u32) 160; 616 temp |= (u32) 160;
617 xhci_writel(xhci, temp, &xhci->ir_set->irq_control); 617 writel(temp, &xhci->ir_set->irq_control);
618 618
619 /* Set the HCD state before we enable the irqs */ 619 /* Set the HCD state before we enable the irqs */
620 temp = xhci_readl(xhci, &xhci->op_regs->command); 620 temp = readl(&xhci->op_regs->command);
621 temp |= (CMD_EIE); 621 temp |= (CMD_EIE);
622 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 622 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
623 "// Enable interrupts, cmd = 0x%x.", temp); 623 "// Enable interrupts, cmd = 0x%x.", temp);
624 xhci_writel(xhci, temp, &xhci->op_regs->command); 624 writel(temp, &xhci->op_regs->command);
625 625
626 temp = xhci_readl(xhci, &xhci->ir_set->irq_pending); 626 temp = readl(&xhci->ir_set->irq_pending);
627 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 627 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
628 "// Enabling event ring interrupter %p by writing 0x%x to irq_pending", 628 "// Enabling event ring interrupter %p by writing 0x%x to irq_pending",
629 xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp)); 629 xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp));
630 xhci_writel(xhci, ER_IRQ_ENABLE(temp), 630 writel(ER_IRQ_ENABLE(temp), &xhci->ir_set->irq_pending);
631 &xhci->ir_set->irq_pending);
632 xhci_print_ir_set(xhci, 0); 631 xhci_print_ir_set(xhci, 0);
633 632
634 if (xhci->quirks & XHCI_NEC_HOST) 633 if (xhci->quirks & XHCI_NEC_HOST)
@@ -698,18 +697,17 @@ void xhci_stop(struct usb_hcd *hcd)
698 697
699 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 698 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
700 "// Disabling event ring interrupts"); 699 "// Disabling event ring interrupts");
701 temp = xhci_readl(xhci, &xhci->op_regs->status); 700 temp = readl(&xhci->op_regs->status);
702 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status); 701 writel(temp & ~STS_EINT, &xhci->op_regs->status);
703 temp = xhci_readl(xhci, &xhci->ir_set->irq_pending); 702 temp = readl(&xhci->ir_set->irq_pending);
704 xhci_writel(xhci, ER_IRQ_DISABLE(temp), 703 writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending);
705 &xhci->ir_set->irq_pending);
706 xhci_print_ir_set(xhci, 0); 704 xhci_print_ir_set(xhci, 0);
707 705
708 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory"); 706 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory");
709 xhci_mem_cleanup(xhci); 707 xhci_mem_cleanup(xhci);
710 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 708 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
711 "xhci_stop completed - status = %x", 709 "xhci_stop completed - status = %x",
712 xhci_readl(xhci, &xhci->op_regs->status)); 710 readl(&xhci->op_regs->status));
713} 711}
714 712
715/* 713/*
@@ -739,7 +737,7 @@ void xhci_shutdown(struct usb_hcd *hcd)
739 737
740 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 738 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
741 "xhci_shutdown completed - status = %x", 739 "xhci_shutdown completed - status = %x",
742 xhci_readl(xhci, &xhci->op_regs->status)); 740 readl(&xhci->op_regs->status));
743 741
744 /* Yet another workaround for spurious wakeups at shutdown with HSW */ 742 /* Yet another workaround for spurious wakeups at shutdown with HSW */
745 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) 743 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
@@ -749,28 +747,28 @@ void xhci_shutdown(struct usb_hcd *hcd)
749#ifdef CONFIG_PM 747#ifdef CONFIG_PM
750static void xhci_save_registers(struct xhci_hcd *xhci) 748static void xhci_save_registers(struct xhci_hcd *xhci)
751{ 749{
752 xhci->s3.command = xhci_readl(xhci, &xhci->op_regs->command); 750 xhci->s3.command = readl(&xhci->op_regs->command);
753 xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification); 751 xhci->s3.dev_nt = readl(&xhci->op_regs->dev_notification);
754 xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); 752 xhci->s3.dcbaa_ptr = readq(&xhci->op_regs->dcbaa_ptr);
755 xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg); 753 xhci->s3.config_reg = readl(&xhci->op_regs->config_reg);
756 xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size); 754 xhci->s3.erst_size = readl(&xhci->ir_set->erst_size);
757 xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base); 755 xhci->s3.erst_base = readq(&xhci->ir_set->erst_base);
758 xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue); 756 xhci->s3.erst_dequeue = readq(&xhci->ir_set->erst_dequeue);
759 xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); 757 xhci->s3.irq_pending = readl(&xhci->ir_set->irq_pending);
760 xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control); 758 xhci->s3.irq_control = readl(&xhci->ir_set->irq_control);
761} 759}
762 760
763static void xhci_restore_registers(struct xhci_hcd *xhci) 761static void xhci_restore_registers(struct xhci_hcd *xhci)
764{ 762{
765 xhci_writel(xhci, xhci->s3.command, &xhci->op_regs->command); 763 writel(xhci->s3.command, &xhci->op_regs->command);
766 xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification); 764 writel(xhci->s3.dev_nt, &xhci->op_regs->dev_notification);
767 xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr); 765 writeq(xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr);
768 xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg); 766 writel(xhci->s3.config_reg, &xhci->op_regs->config_reg);
769 xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size); 767 writel(xhci->s3.erst_size, &xhci->ir_set->erst_size);
770 xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base); 768 writeq(xhci->s3.erst_base, &xhci->ir_set->erst_base);
771 xhci_write_64(xhci, xhci->s3.erst_dequeue, &xhci->ir_set->erst_dequeue); 769 writeq(xhci->s3.erst_dequeue, &xhci->ir_set->erst_dequeue);
772 xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending); 770 writel(xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
773 xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control); 771 writel(xhci->s3.irq_control, &xhci->ir_set->irq_control);
774} 772}
775 773
776static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci) 774static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
@@ -778,7 +776,7 @@ static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
778 u64 val_64; 776 u64 val_64;
779 777
780 /* step 2: initialize command ring buffer */ 778 /* step 2: initialize command ring buffer */
781 val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring); 779 val_64 = readq(&xhci->op_regs->cmd_ring);
782 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) | 780 val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
783 (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg, 781 (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
784 xhci->cmd_ring->dequeue) & 782 xhci->cmd_ring->dequeue) &
@@ -787,7 +785,7 @@ static void xhci_set_cmd_ring_deq(struct xhci_hcd *xhci)
787 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 785 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
788 "// Setting command ring address to 0x%llx", 786 "// Setting command ring address to 0x%llx",
789 (long unsigned long) val_64); 787 (long unsigned long) val_64);
790 xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring); 788 writeq(val_64, &xhci->op_regs->cmd_ring);
791} 789}
792 790
793/* 791/*
@@ -866,9 +864,9 @@ int xhci_suspend(struct xhci_hcd *xhci)
866 /* skipped assuming that port suspend has done */ 864 /* skipped assuming that port suspend has done */
867 865
868 /* step 2: clear Run/Stop bit */ 866 /* step 2: clear Run/Stop bit */
869 command = xhci_readl(xhci, &xhci->op_regs->command); 867 command = readl(&xhci->op_regs->command);
870 command &= ~CMD_RUN; 868 command &= ~CMD_RUN;
871 xhci_writel(xhci, command, &xhci->op_regs->command); 869 writel(command, &xhci->op_regs->command);
872 870
873 /* Some chips from Fresco Logic need an extraordinary delay */ 871 /* Some chips from Fresco Logic need an extraordinary delay */
874 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; 872 delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1;
@@ -885,9 +883,9 @@ int xhci_suspend(struct xhci_hcd *xhci)
885 xhci_save_registers(xhci); 883 xhci_save_registers(xhci);
886 884
887 /* step 4: set CSS flag */ 885 /* step 4: set CSS flag */
888 command = xhci_readl(xhci, &xhci->op_regs->command); 886 command = readl(&xhci->op_regs->command);
889 command |= CMD_CSS; 887 command |= CMD_CSS;
890 xhci_writel(xhci, command, &xhci->op_regs->command); 888 writel(command, &xhci->op_regs->command);
891 if (xhci_handshake(xhci, &xhci->op_regs->status, 889 if (xhci_handshake(xhci, &xhci->op_regs->status,
892 STS_SAVE, 0, 10 * 1000)) { 890 STS_SAVE, 0, 10 * 1000)) {
893 xhci_warn(xhci, "WARN: xHC save state timeout\n"); 891 xhci_warn(xhci, "WARN: xHC save state timeout\n");
@@ -951,16 +949,16 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
951 xhci_set_cmd_ring_deq(xhci); 949 xhci_set_cmd_ring_deq(xhci);
952 /* step 3: restore state and start state*/ 950 /* step 3: restore state and start state*/
953 /* step 3: set CRS flag */ 951 /* step 3: set CRS flag */
954 command = xhci_readl(xhci, &xhci->op_regs->command); 952 command = readl(&xhci->op_regs->command);
955 command |= CMD_CRS; 953 command |= CMD_CRS;
956 xhci_writel(xhci, command, &xhci->op_regs->command); 954 writel(command, &xhci->op_regs->command);
957 if (xhci_handshake(xhci, &xhci->op_regs->status, 955 if (xhci_handshake(xhci, &xhci->op_regs->status,
958 STS_RESTORE, 0, 10 * 1000)) { 956 STS_RESTORE, 0, 10 * 1000)) {
959 xhci_warn(xhci, "WARN: xHC restore state timeout\n"); 957 xhci_warn(xhci, "WARN: xHC restore state timeout\n");
960 spin_unlock_irq(&xhci->lock); 958 spin_unlock_irq(&xhci->lock);
961 return -ETIMEDOUT; 959 return -ETIMEDOUT;
962 } 960 }
963 temp = xhci_readl(xhci, &xhci->op_regs->status); 961 temp = readl(&xhci->op_regs->status);
964 } 962 }
965 963
966 /* If restore operation fails, re-initialize the HC during resume */ 964 /* If restore operation fails, re-initialize the HC during resume */
@@ -984,17 +982,16 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
984 xhci_cleanup_msix(xhci); 982 xhci_cleanup_msix(xhci);
985 983
986 xhci_dbg(xhci, "// Disabling event ring interrupts\n"); 984 xhci_dbg(xhci, "// Disabling event ring interrupts\n");
987 temp = xhci_readl(xhci, &xhci->op_regs->status); 985 temp = readl(&xhci->op_regs->status);
988 xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status); 986 writel(temp & ~STS_EINT, &xhci->op_regs->status);
989 temp = xhci_readl(xhci, &xhci->ir_set->irq_pending); 987 temp = readl(&xhci->ir_set->irq_pending);
990 xhci_writel(xhci, ER_IRQ_DISABLE(temp), 988 writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending);
991 &xhci->ir_set->irq_pending);
992 xhci_print_ir_set(xhci, 0); 989 xhci_print_ir_set(xhci, 0);
993 990
994 xhci_dbg(xhci, "cleaning up memory\n"); 991 xhci_dbg(xhci, "cleaning up memory\n");
995 xhci_mem_cleanup(xhci); 992 xhci_mem_cleanup(xhci);
996 xhci_dbg(xhci, "xhci_stop completed - status = %x\n", 993 xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
997 xhci_readl(xhci, &xhci->op_regs->status)); 994 readl(&xhci->op_regs->status));
998 995
999 /* USB core calls the PCI reinit and start functions twice: 996 /* USB core calls the PCI reinit and start functions twice:
1000 * first with the primary HCD, and then with the secondary HCD. 997 * first with the primary HCD, and then with the secondary HCD.
@@ -1023,9 +1020,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1023 } 1020 }
1024 1021
1025 /* step 4: set Run/Stop bit */ 1022 /* step 4: set Run/Stop bit */
1026 command = xhci_readl(xhci, &xhci->op_regs->command); 1023 command = readl(&xhci->op_regs->command);
1027 command |= CMD_RUN; 1024 command |= CMD_RUN;
1028 xhci_writel(xhci, command, &xhci->op_regs->command); 1025 writel(command, &xhci->op_regs->command);
1029 xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT, 1026 xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT,
1030 0, 250 * 1000); 1027 0, 250 * 1000);
1031 1028
@@ -1464,7 +1461,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
1464 ret = usb_hcd_check_unlink_urb(hcd, urb, status); 1461 ret = usb_hcd_check_unlink_urb(hcd, urb, status);
1465 if (ret || !urb->hcpriv) 1462 if (ret || !urb->hcpriv)
1466 goto done; 1463 goto done;
1467 temp = xhci_readl(xhci, &xhci->op_regs->status); 1464 temp = readl(&xhci->op_regs->status);
1468 if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) { 1465 if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) {
1469 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 1466 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
1470 "HW died, freeing TD."); 1467 "HW died, freeing TD.");
@@ -1892,8 +1889,8 @@ static u32 xhci_count_num_new_endpoints(struct xhci_hcd *xhci,
1892 * (bit 1). The default control endpoint is added during the Address 1889 * (bit 1). The default control endpoint is added during the Address
1893 * Device command and is never removed until the slot is disabled. 1890 * Device command and is never removed until the slot is disabled.
1894 */ 1891 */
1895 valid_add_flags = ctrl_ctx->add_flags >> 2; 1892 valid_add_flags = le32_to_cpu(ctrl_ctx->add_flags) >> 2;
1896 valid_drop_flags = ctrl_ctx->drop_flags >> 2; 1893 valid_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags) >> 2;
1897 1894
1898 /* Use hweight32 to count the number of ones in the add flags, or 1895 /* Use hweight32 to count the number of ones in the add flags, or
1899 * number of endpoints added. Don't count endpoints that are changed 1896 * number of endpoints added. Don't count endpoints that are changed
@@ -1909,8 +1906,8 @@ static unsigned int xhci_count_num_dropped_endpoints(struct xhci_hcd *xhci,
1909 u32 valid_add_flags; 1906 u32 valid_add_flags;
1910 u32 valid_drop_flags; 1907 u32 valid_drop_flags;
1911 1908
1912 valid_add_flags = ctrl_ctx->add_flags >> 2; 1909 valid_add_flags = le32_to_cpu(ctrl_ctx->add_flags) >> 2;
1913 valid_drop_flags = ctrl_ctx->drop_flags >> 2; 1910 valid_drop_flags = le32_to_cpu(ctrl_ctx->drop_flags) >> 2;
1914 1911
1915 return hweight32(valid_drop_flags) - 1912 return hweight32(valid_drop_flags) -
1916 hweight32(valid_add_flags & valid_drop_flags); 1913 hweight32(valid_add_flags & valid_drop_flags);
@@ -3585,7 +3582,7 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
3585 3582
3586 spin_lock_irqsave(&xhci->lock, flags); 3583 spin_lock_irqsave(&xhci->lock, flags);
3587 /* Don't disable the slot if the host controller is dead. */ 3584 /* Don't disable the slot if the host controller is dead. */
3588 state = xhci_readl(xhci, &xhci->op_regs->status); 3585 state = readl(&xhci->op_regs->status);
3589 if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) || 3586 if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
3590 (xhci->xhc_state & XHCI_STATE_HALTED)) { 3587 (xhci->xhc_state & XHCI_STATE_HALTED)) {
3591 xhci_free_virt_device(xhci, udev->slot_id); 3588 xhci_free_virt_device(xhci, udev->slot_id);
@@ -3712,13 +3709,15 @@ disable_slot:
3712} 3709}
3713 3710
3714/* 3711/*
3715 * Issue an Address Device command (which will issue a SetAddress request to 3712 * Issue an Address Device command and optionally send a corresponding
3716 * the device). 3713 * SetAddress request to the device.
3717 * We should be protected by the usb_address0_mutex in khubd's hub_port_init, so 3714 * We should be protected by the usb_address0_mutex in khubd's hub_port_init, so
3718 * we should only issue and wait on one address command at the same time. 3715 * we should only issue and wait on one address command at the same time.
3719 */ 3716 */
3720int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) 3717static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3718 enum xhci_setup_dev setup)
3721{ 3719{
3720 const char *act = setup == SETUP_CONTEXT_ONLY ? "context" : "address";
3722 unsigned long flags; 3721 unsigned long flags;
3723 int timeleft; 3722 int timeleft;
3724 struct xhci_virt_device *virt_dev; 3723 struct xhci_virt_device *virt_dev;
@@ -3771,12 +3770,12 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3771 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); 3770 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
3772 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); 3771 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
3773 trace_xhci_address_ctx(xhci, virt_dev->in_ctx, 3772 trace_xhci_address_ctx(xhci, virt_dev->in_ctx,
3774 slot_ctx->dev_info >> 27); 3773 le32_to_cpu(slot_ctx->dev_info) >> 27);
3775 3774
3776 spin_lock_irqsave(&xhci->lock, flags); 3775 spin_lock_irqsave(&xhci->lock, flags);
3777 cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring); 3776 cmd_trb = xhci_find_next_enqueue(xhci->cmd_ring);
3778 ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma, 3777 ret = xhci_queue_address_device(xhci, virt_dev->in_ctx->dma,
3779 udev->slot_id); 3778 udev->slot_id, setup);
3780 if (ret) { 3779 if (ret) {
3781 spin_unlock_irqrestore(&xhci->lock, flags); 3780 spin_unlock_irqrestore(&xhci->lock, flags);
3782 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3781 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
@@ -3794,8 +3793,8 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3794 * command on a timeout. 3793 * command on a timeout.
3795 */ 3794 */
3796 if (timeleft <= 0) { 3795 if (timeleft <= 0) {
3797 xhci_warn(xhci, "%s while waiting for address device command\n", 3796 xhci_warn(xhci, "%s while waiting for setup %s command\n",
3798 timeleft == 0 ? "Timeout" : "Signal"); 3797 timeleft == 0 ? "Timeout" : "Signal", act);
3799 /* cancel the address device command */ 3798 /* cancel the address device command */
3800 ret = xhci_cancel_cmd(xhci, NULL, cmd_trb); 3799 ret = xhci_cancel_cmd(xhci, NULL, cmd_trb);
3801 if (ret < 0) 3800 if (ret < 0)
@@ -3806,26 +3805,27 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3806 switch (virt_dev->cmd_status) { 3805 switch (virt_dev->cmd_status) {
3807 case COMP_CTX_STATE: 3806 case COMP_CTX_STATE:
3808 case COMP_EBADSLT: 3807 case COMP_EBADSLT:
3809 xhci_err(xhci, "Setup ERROR: address device command for slot %d.\n", 3808 xhci_err(xhci, "Setup ERROR: setup %s command for slot %d.\n",
3810 udev->slot_id); 3809 act, udev->slot_id);
3811 ret = -EINVAL; 3810 ret = -EINVAL;
3812 break; 3811 break;
3813 case COMP_TX_ERR: 3812 case COMP_TX_ERR:
3814 dev_warn(&udev->dev, "Device not responding to set address.\n"); 3813 dev_warn(&udev->dev, "Device not responding to setup %s.\n", act);
3815 ret = -EPROTO; 3814 ret = -EPROTO;
3816 break; 3815 break;
3817 case COMP_DEV_ERR: 3816 case COMP_DEV_ERR:
3818 dev_warn(&udev->dev, "ERROR: Incompatible device for address " 3817 dev_warn(&udev->dev,
3819 "device command.\n"); 3818 "ERROR: Incompatible device for setup %s command\n", act);
3820 ret = -ENODEV; 3819 ret = -ENODEV;
3821 break; 3820 break;
3822 case COMP_SUCCESS: 3821 case COMP_SUCCESS:
3823 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3822 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
3824 "Successful Address Device command"); 3823 "Successful setup %s command", act);
3825 break; 3824 break;
3826 default: 3825 default:
3827 xhci_err(xhci, "ERROR: unexpected command completion " 3826 xhci_err(xhci,
3828 "code 0x%x.\n", virt_dev->cmd_status); 3827 "ERROR: unexpected setup %s command completion code 0x%x.\n",
3828 act, virt_dev->cmd_status);
3829 xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id); 3829 xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
3830 xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2); 3830 xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2);
3831 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, 1); 3831 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, 1);
@@ -3835,7 +3835,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3835 if (ret) { 3835 if (ret) {
3836 return ret; 3836 return ret;
3837 } 3837 }
3838 temp_64 = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr); 3838 temp_64 = readq(&xhci->op_regs->dcbaa_ptr);
3839 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3839 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
3840 "Op regs DCBAA ptr = %#016llx", temp_64); 3840 "Op regs DCBAA ptr = %#016llx", temp_64);
3841 xhci_dbg_trace(xhci, trace_xhci_dbg_address, 3841 xhci_dbg_trace(xhci, trace_xhci_dbg_address,
@@ -3850,7 +3850,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3850 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id); 3850 xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
3851 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2); 3851 xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
3852 trace_xhci_address_ctx(xhci, virt_dev->in_ctx, 3852 trace_xhci_address_ctx(xhci, virt_dev->in_ctx,
3853 slot_ctx->dev_info >> 27); 3853 le32_to_cpu(slot_ctx->dev_info) >> 27);
3854 xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id); 3854 xhci_dbg(xhci, "Slot ID %d Output Context:\n", udev->slot_id);
3855 xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2); 3855 xhci_dbg_ctx(xhci, virt_dev->out_ctx, 2);
3856 /* 3856 /*
@@ -3859,7 +3859,7 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3859 */ 3859 */
3860 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx); 3860 slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
3861 trace_xhci_address_ctx(xhci, virt_dev->out_ctx, 3861 trace_xhci_address_ctx(xhci, virt_dev->out_ctx,
3862 slot_ctx->dev_info >> 27); 3862 le32_to_cpu(slot_ctx->dev_info) >> 27);
3863 /* Zero the input context control for later use */ 3863 /* Zero the input context control for later use */
3864 ctrl_ctx->add_flags = 0; 3864 ctrl_ctx->add_flags = 0;
3865 ctrl_ctx->drop_flags = 0; 3865 ctrl_ctx->drop_flags = 0;
@@ -3871,6 +3871,16 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3871 return 0; 3871 return 0;
3872} 3872}
3873 3873
3874int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
3875{
3876 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS);
3877}
3878
3879int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
3880{
3881 return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ONLY);
3882}
3883
3874/* 3884/*
3875 * Transfer the port index into real index in the HW port status 3885 * Transfer the port index into real index in the HW port status
3876 * registers. Caculate offset between the port's PORTSC register 3886 * registers. Caculate offset between the port's PORTSC register
@@ -4042,7 +4052,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4042 port_array = xhci->usb2_ports; 4052 port_array = xhci->usb2_ports;
4043 port_num = udev->portnum - 1; 4053 port_num = udev->portnum - 1;
4044 pm_addr = port_array[port_num] + PORTPMSC; 4054 pm_addr = port_array[port_num] + PORTPMSC;
4045 pm_val = xhci_readl(xhci, pm_addr); 4055 pm_val = readl(pm_addr);
4046 hlpm_addr = port_array[port_num] + PORTHLPMC; 4056 hlpm_addr = port_array[port_num] + PORTHLPMC;
4047 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); 4057 field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
4048 4058
@@ -4082,26 +4092,26 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
4082 spin_lock_irqsave(&xhci->lock, flags); 4092 spin_lock_irqsave(&xhci->lock, flags);
4083 4093
4084 hlpm_val = xhci_calculate_usb2_hw_lpm_params(udev); 4094 hlpm_val = xhci_calculate_usb2_hw_lpm_params(udev);
4085 xhci_writel(xhci, hlpm_val, hlpm_addr); 4095 writel(hlpm_val, hlpm_addr);
4086 /* flush write */ 4096 /* flush write */
4087 xhci_readl(xhci, hlpm_addr); 4097 readl(hlpm_addr);
4088 } else { 4098 } else {
4089 hird = xhci_calculate_hird_besl(xhci, udev); 4099 hird = xhci_calculate_hird_besl(xhci, udev);
4090 } 4100 }
4091 4101
4092 pm_val &= ~PORT_HIRD_MASK; 4102 pm_val &= ~PORT_HIRD_MASK;
4093 pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id); 4103 pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
4094 xhci_writel(xhci, pm_val, pm_addr); 4104 writel(pm_val, pm_addr);
4095 pm_val = xhci_readl(xhci, pm_addr); 4105 pm_val = readl(pm_addr);
4096 pm_val |= PORT_HLE; 4106 pm_val |= PORT_HLE;
4097 xhci_writel(xhci, pm_val, pm_addr); 4107 writel(pm_val, pm_addr);
4098 /* flush write */ 4108 /* flush write */
4099 xhci_readl(xhci, pm_addr); 4109 readl(pm_addr);
4100 } else { 4110 } else {
4101 pm_val &= ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK | PORT_L1DS_MASK); 4111 pm_val &= ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK | PORT_L1DS_MASK);
4102 xhci_writel(xhci, pm_val, pm_addr); 4112 writel(pm_val, pm_addr);
4103 /* flush write */ 4113 /* flush write */
4104 xhci_readl(xhci, pm_addr); 4114 readl(pm_addr);
4105 if (udev->usb2_hw_lpm_besl_capable) { 4115 if (udev->usb2_hw_lpm_besl_capable) {
4106 spin_unlock_irqrestore(&xhci->lock, flags); 4116 spin_unlock_irqrestore(&xhci->lock, flags);
4107 mutex_lock(hcd->bandwidth_mutex); 4117 mutex_lock(hcd->bandwidth_mutex);
@@ -4455,7 +4465,7 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd,
4455 if (!config) 4465 if (!config)
4456 return timeout; 4466 return timeout;
4457 4467
4458 for (i = 0; i < USB_MAXINTERFACES; i++) { 4468 for (i = 0; i < config->desc.bNumInterfaces; i++) {
4459 struct usb_driver *driver; 4469 struct usb_driver *driver;
4460 struct usb_interface *intf = config->interface[i]; 4470 struct usb_interface *intf = config->interface[i];
4461 4471
@@ -4704,7 +4714,7 @@ int xhci_get_frame(struct usb_hcd *hcd)
4704{ 4714{
4705 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 4715 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
4706 /* EHCI mods by the periodic size. Why? */ 4716 /* EHCI mods by the periodic size. Why? */
4707 return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3; 4717 return readl(&xhci->run_regs->microframe_index) >> 3;
4708} 4718}
4709 4719
4710int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) 4720int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
@@ -4748,16 +4758,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4748 4758
4749 xhci->cap_regs = hcd->regs; 4759 xhci->cap_regs = hcd->regs;
4750 xhci->op_regs = hcd->regs + 4760 xhci->op_regs = hcd->regs +
4751 HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase)); 4761 HC_LENGTH(readl(&xhci->cap_regs->hc_capbase));
4752 xhci->run_regs = hcd->regs + 4762 xhci->run_regs = hcd->regs +
4753 (xhci_readl(xhci, &xhci->cap_regs->run_regs_off) & RTSOFF_MASK); 4763 (readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
4754 /* Cache read-only capability registers */ 4764 /* Cache read-only capability registers */
4755 xhci->hcs_params1 = xhci_readl(xhci, &xhci->cap_regs->hcs_params1); 4765 xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1);
4756 xhci->hcs_params2 = xhci_readl(xhci, &xhci->cap_regs->hcs_params2); 4766 xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2);
4757 xhci->hcs_params3 = xhci_readl(xhci, &xhci->cap_regs->hcs_params3); 4767 xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3);
4758 xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hc_capbase); 4768 xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase);
4759 xhci->hci_version = HC_VERSION(xhci->hcc_params); 4769 xhci->hci_version = HC_VERSION(xhci->hcc_params);
4760 xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params); 4770 xhci->hcc_params = readl(&xhci->cap_regs->hcc_params);
4761 xhci_print_registers(xhci); 4771 xhci_print_registers(xhci);
4762 4772
4763 get_quirks(dev, xhci); 4773 get_quirks(dev, xhci);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 03c74b7965f8..24344aab2107 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -28,6 +28,17 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/usb/hcd.h> 29#include <linux/usb/hcd.h>
30 30
31/*
32 * Registers should always be accessed with double word or quad word accesses.
33 *
34 * Some xHCI implementations may support 64-bit address pointers. Registers
35 * with 64-bit address pointers should be written to with dword accesses by
36 * writing the low dword first (ptr[0]), then the high dword (ptr[1]) second.
37 * xHCI implementations that do not support 64-bit address pointers will ignore
38 * the high dword, and write order is irrelevant.
39 */
40#include <asm-generic/io-64-nonatomic-lo-hi.h>
41
31/* Code sharing between pci-quirks and xhci hcd */ 42/* Code sharing between pci-quirks and xhci hcd */
32#include "xhci-ext-caps.h" 43#include "xhci-ext-caps.h"
33#include "pci-quirks.h" 44#include "pci-quirks.h"
@@ -752,7 +763,7 @@ struct xhci_stream_ctx {
752}; 763};
753 764
754/* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */ 765/* Stream Context Types (section 6.4.1) - bits 3:1 of stream ctx deq ptr */
755#define SCT_FOR_CTX(p) (((p) << 1) & 0x7) 766#define SCT_FOR_CTX(p) (((p) & 0x7) << 1)
756/* Secondary stream array type, dequeue pointer is to a transfer ring */ 767/* Secondary stream array type, dequeue pointer is to a transfer ring */
757#define SCT_SEC_TR 0 768#define SCT_SEC_TR 0
758/* Primary stream array type, dequeue pointer is to a transfer ring */ 769/* Primary stream array type, dequeue pointer is to a transfer ring */
@@ -1097,6 +1108,14 @@ struct xhci_event_cmd {
1097}; 1108};
1098 1109
1099/* flags bitmasks */ 1110/* flags bitmasks */
1111
1112/* Address device - disable SetAddress */
1113#define TRB_BSR (1<<9)
1114enum xhci_setup_dev {
1115 SETUP_CONTEXT_ONLY,
1116 SETUP_CONTEXT_ADDRESS,
1117};
1118
1100/* bits 16:23 are the virtual function ID */ 1119/* bits 16:23 are the virtual function ID */
1101/* bits 24:31 are the slot ID */ 1120/* bits 24:31 are the slot ID */
1102#define TRB_TO_SLOT_ID(p) (((p) & (0xff<<24)) >> 24) 1121#define TRB_TO_SLOT_ID(p) (((p) & (0xff<<24)) >> 24)
@@ -1595,47 +1614,6 @@ static inline struct usb_hcd *xhci_to_hcd(struct xhci_hcd *xhci)
1595#define xhci_warn_ratelimited(xhci, fmt, args...) \ 1614#define xhci_warn_ratelimited(xhci, fmt, args...) \
1596 dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args) 1615 dev_warn_ratelimited(xhci_to_hcd(xhci)->self.controller , fmt , ## args)
1597 1616
1598/* TODO: copied from ehci.h - can be refactored? */
1599/* xHCI spec says all registers are little endian */
1600static inline unsigned int xhci_readl(const struct xhci_hcd *xhci,
1601 __le32 __iomem *regs)
1602{
1603 return readl(regs);
1604}
1605static inline void xhci_writel(struct xhci_hcd *xhci,
1606 const unsigned int val, __le32 __iomem *regs)
1607{
1608 writel(val, regs);
1609}
1610
1611/*
1612 * Registers should always be accessed with double word or quad word accesses.
1613 *
1614 * Some xHCI implementations may support 64-bit address pointers. Registers
1615 * with 64-bit address pointers should be written to with dword accesses by
1616 * writing the low dword first (ptr[0]), then the high dword (ptr[1]) second.
1617 * xHCI implementations that do not support 64-bit address pointers will ignore
1618 * the high dword, and write order is irrelevant.
1619 */
1620static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
1621 __le64 __iomem *regs)
1622{
1623 __u32 __iomem *ptr = (__u32 __iomem *) regs;
1624 u64 val_lo = readl(ptr);
1625 u64 val_hi = readl(ptr + 1);
1626 return val_lo + (val_hi << 32);
1627}
1628static inline void xhci_write_64(struct xhci_hcd *xhci,
1629 const u64 val, __le64 __iomem *regs)
1630{
1631 __u32 __iomem *ptr = (__u32 __iomem *) regs;
1632 u32 val_lo = lower_32_bits(val);
1633 u32 val_hi = upper_32_bits(val);
1634
1635 writel(val_lo, ptr);
1636 writel(val_hi, ptr + 1);
1637}
1638
1639static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci) 1617static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci)
1640{ 1618{
1641 return xhci->quirks & XHCI_LINK_TRB_QUIRK; 1619 return xhci->quirks & XHCI_LINK_TRB_QUIRK;
@@ -1790,6 +1768,7 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
1790 struct usb_host_endpoint **eps, unsigned int num_eps, 1768 struct usb_host_endpoint **eps, unsigned int num_eps,
1791 gfp_t mem_flags); 1769 gfp_t mem_flags);
1792int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev); 1770int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev);
1771int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev);
1793int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev); 1772int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev);
1794int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, 1773int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
1795 struct usb_device *udev, int enable); 1774 struct usb_device *udev, int enable);
@@ -1813,7 +1792,7 @@ int xhci_is_vendor_info_code(struct xhci_hcd *xhci, unsigned int trb_comp_code);
1813void xhci_ring_cmd_db(struct xhci_hcd *xhci); 1792void xhci_ring_cmd_db(struct xhci_hcd *xhci);
1814int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id); 1793int xhci_queue_slot_control(struct xhci_hcd *xhci, u32 trb_type, u32 slot_id);
1815int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr, 1794int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
1816 u32 slot_id); 1795 u32 slot_id, enum xhci_setup_dev);
1817int xhci_queue_vendor_command(struct xhci_hcd *xhci, 1796int xhci_queue_vendor_command(struct xhci_hcd *xhci,
1818 u32 field1, u32 field2, u32 field3, u32 field4); 1797 u32 field1, u32 field2, u32 field3, u32 field4);
1819int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id, 1798int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index b4152820d655..bff058ea222e 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -619,8 +619,8 @@ static int is_good_ext(struct usbtest_dev *tdev, u8 *buf)
619 } 619 }
620 620
621 attr = le32_to_cpu(ext->bmAttributes); 621 attr = le32_to_cpu(ext->bmAttributes);
622 /* bits[1:4] is used and others are reserved */ 622 /* bits[1:15] is used and others are reserved */
623 if (attr & ~0x1e) { /* reserved == 0 */ 623 if (attr & ~0xfffe) { /* reserved == 0 */
624 ERROR(tdev, "reserved bits set\n"); 624 ERROR(tdev, "reserved bits set\n");
625 return 0; 625 return 0;
626 } 626 }
@@ -763,7 +763,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
763 * there's always [9.4.3] a bos device descriptor [9.6.2] in USB 763 * there's always [9.4.3] a bos device descriptor [9.6.2] in USB
764 * 3.0 spec 764 * 3.0 spec
765 */ 765 */
766 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0300) { 766 if (le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0210) {
767 struct usb_bos_descriptor *bos = NULL; 767 struct usb_bos_descriptor *bos = NULL;
768 struct usb_dev_cap_header *header = NULL; 768 struct usb_dev_cap_header *header = NULL;
769 unsigned total, num, length; 769 unsigned total, num, length;
@@ -944,7 +944,7 @@ struct ctrl_ctx {
944 int last; 944 int last;
945}; 945};
946 946
947#define NUM_SUBCASES 15 /* how many test subcases here? */ 947#define NUM_SUBCASES 16 /* how many test subcases here? */
948 948
949struct subcase { 949struct subcase {
950 struct usb_ctrlrequest setup; 950 struct usb_ctrlrequest setup;
@@ -1218,6 +1218,15 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
1218 } 1218 }
1219 expected = -EREMOTEIO; 1219 expected = -EREMOTEIO;
1220 break; 1220 break;
1221 case 15:
1222 req.wValue = cpu_to_le16(USB_DT_BOS << 8);
1223 if (udev->bos)
1224 len = le16_to_cpu(udev->bos->desc->wTotalLength);
1225 else
1226 len = sizeof(struct usb_bos_descriptor);
1227 if (udev->speed != USB_SPEED_SUPER)
1228 expected = -EPIPE;
1229 break;
1221 default: 1230 default:
1222 ERROR(dev, "bogus number of ctrl queue testcases!\n"); 1231 ERROR(dev, "bogus number of ctrl queue testcases!\n");
1223 context.status = -EINVAL; 1232 context.status = -EINVAL;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 6582a20bec05..e2083757e87c 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2657,6 +2657,7 @@ int musb_host_setup(struct musb *musb, int power_budget)
2657 if (ret < 0) 2657 if (ret < 0)
2658 return ret; 2658 return ret;
2659 2659
2660 device_wakeup_enable(hcd->self.controller);
2660 return 0; 2661 return 0;
2661} 2662}
2662 2663
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index e9d4cd960ecd..37752832b770 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -669,6 +669,7 @@ static void msm_otg_start_host(struct usb_phy *phy, int on)
669 pdata->setup_gpio(OTG_STATE_A_HOST); 669 pdata->setup_gpio(OTG_STATE_A_HOST);
670#ifdef CONFIG_USB 670#ifdef CONFIG_USB
671 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); 671 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
672 device_wakeup_enable(hcd->self.controller);
672#endif 673#endif
673 } else { 674 } else {
674 dev_dbg(phy->dev, "host off\n"); 675 dev_dbg(phy->dev, "host off\n");
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index 98f6ac6a78ea..44f316e287ef 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -213,10 +213,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on)
213 213
214 hcd = bus_to_hcd(otg->host); 214 hcd = bus_to_hcd(otg->host);
215 215
216 if (on) 216 if (on) {
217 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); 217 usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
218 else 218 device_wakeup_enable(hcd->self.controller);
219 } else {
219 usb_remove_hcd(hcd); 220 usb_remove_hcd(hcd);
221 }
220#endif /* CONFIG_USB */ 222#endif /* CONFIG_USB */
221} 223}
222 224
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index e40f565004d0..10e1ded9c9cc 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1469,6 +1469,7 @@ static int usbhsh_start(struct usbhs_priv *priv)
1469 ret = usb_add_hcd(hcd, 0, 0); 1469 ret = usb_add_hcd(hcd, 0, 0);
1470 if (ret < 0) 1470 if (ret < 0)
1471 return 0; 1471 return 0;
1472 device_wakeup_enable(hcd->self.controller);
1472 1473
1473 /* 1474 /*
1474 * pipe initialize and enable DCP 1475 * pipe initialize and enable DCP
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
index 5dfb4c36a1b0..12e3c2fac642 100644
--- a/drivers/usb/storage/protocol.c
+++ b/drivers/usb/storage/protocol.c
@@ -135,69 +135,42 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
135 unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr, 135 unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr,
136 unsigned int *offset, enum xfer_buf_dir dir) 136 unsigned int *offset, enum xfer_buf_dir dir)
137{ 137{
138 unsigned int cnt; 138 unsigned int cnt = 0;
139 struct scatterlist *sg = *sgptr; 139 struct scatterlist *sg = *sgptr;
140 struct sg_mapping_iter miter;
141 unsigned int nents = scsi_sg_count(srb);
140 142
141 /* We have to go through the list one entry 143 if (sg)
142 * at a time. Each s-g entry contains some number of pages, and 144 nents = sg_nents(sg);
143 * each page has to be kmap()'ed separately. If the page is already 145 else
144 * in kernel-addressable memory then kmap() will return its address.
145 * If the page is not directly accessible -- such as a user buffer
146 * located in high memory -- then kmap() will map it to a temporary
147 * position in the kernel's virtual address space.
148 */
149
150 if (!sg)
151 sg = scsi_sglist(srb); 146 sg = scsi_sglist(srb);
152 147
153 /* This loop handles a single s-g list entry, which may 148 sg_miter_start(&miter, sg, nents, dir == FROM_XFER_BUF ?
154 * include multiple pages. Find the initial page structure 149 SG_MITER_FROM_SG: SG_MITER_TO_SG);
155 * and the starting offset within the page, and update
156 * the *offset and **sgptr values for the next loop.
157 */
158 cnt = 0;
159 while (cnt < buflen && sg) {
160 struct page *page = sg_page(sg) +
161 ((sg->offset + *offset) >> PAGE_SHIFT);
162 unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE-1);
163 unsigned int sglen = sg->length - *offset;
164
165 if (sglen > buflen - cnt) {
166
167 /* Transfer ends within this s-g entry */
168 sglen = buflen - cnt;
169 *offset += sglen;
170 } else {
171 150
172 /* Transfer continues to next s-g entry */ 151 if (!sg_miter_skip(&miter, *offset))
173 *offset = 0; 152 return cnt;
174 sg = sg_next(sg); 153
175 } 154 while (sg_miter_next(&miter) && cnt < buflen) {
155 unsigned int len = min_t(unsigned int, miter.length,
156 buflen - cnt);
157
158 if (dir == FROM_XFER_BUF)
159 memcpy(buffer + cnt, miter.addr, len);
160 else
161 memcpy(miter.addr, buffer + cnt, len);
176 162
177 /* Transfer the data for all the pages in this 163 if (*offset + len < miter.piter.sg->length) {
178 * s-g entry. For each page: call kmap(), do the 164 *offset += len;
179 * transfer, and call kunmap() immediately after. */ 165 *sgptr = miter.piter.sg;
180 while (sglen > 0) { 166 } else {
181 unsigned int plen = min(sglen, (unsigned int) 167 *offset = 0;
182 PAGE_SIZE - poff); 168 *sgptr = sg_next(miter.piter.sg);
183 unsigned char *ptr = kmap(page);
184
185 if (dir == TO_XFER_BUF)
186 memcpy(ptr + poff, buffer + cnt, plen);
187 else
188 memcpy(buffer + cnt, ptr + poff, plen);
189 kunmap(page);
190
191 /* Start at the beginning of the next page */
192 poff = 0;
193 ++page;
194 cnt += plen;
195 sglen -= plen;
196 } 169 }
170 cnt += len;
197 } 171 }
198 *sgptr = sg; 172 sg_miter_stop(&miter);
199 173
200 /* Return the amount actually transferred */
201 return cnt; 174 return cnt;
202} 175}
203EXPORT_SYMBOL_GPL(usb_stor_access_xfer_buf); 176EXPORT_SYMBOL_GPL(usb_stor_access_xfer_buf);
diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
index f06ed82e63d1..56310fc9b9c3 100644
--- a/drivers/usb/wusbcore/cbaf.c
+++ b/drivers/usb/wusbcore/cbaf.c
@@ -144,7 +144,7 @@ static int cbaf_check(struct cbaf *cbaf)
144 CBAF_REQ_GET_ASSOCIATION_INFORMATION, 144 CBAF_REQ_GET_ASSOCIATION_INFORMATION,
145 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 145 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
146 0, cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber, 146 0, cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber,
147 cbaf->buffer, cbaf->buffer_size, 1000 /* FIXME: arbitrary */); 147 cbaf->buffer, cbaf->buffer_size, USB_CTRL_GET_TIMEOUT);
148 if (result < 0) { 148 if (result < 0) {
149 dev_err(dev, "Cannot get available association types: %d\n", 149 dev_err(dev, "Cannot get available association types: %d\n",
150 result); 150 result);
@@ -265,7 +265,7 @@ static int cbaf_send_host_info(struct cbaf *cbaf)
265 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 265 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
266 0x0101, 266 0x0101,
267 cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber, 267 cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber,
268 hi, hi_size, 1000 /* FIXME: arbitrary */); 268 hi, hi_size, USB_CTRL_SET_TIMEOUT);
269} 269}
270 270
271/* 271/*
@@ -288,7 +288,7 @@ static int cbaf_cdid_get(struct cbaf *cbaf)
288 CBAF_REQ_GET_ASSOCIATION_REQUEST, 288 CBAF_REQ_GET_ASSOCIATION_REQUEST,
289 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 289 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
290 0x0200, cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber, 290 0x0200, cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber,
291 di, cbaf->buffer_size, 1000 /* FIXME: arbitrary */); 291 di, cbaf->buffer_size, USB_CTRL_GET_TIMEOUT);
292 if (result < 0) { 292 if (result < 0) {
293 dev_err(dev, "Cannot request device information: %d\n", result); 293 dev_err(dev, "Cannot request device information: %d\n", result);
294 return result; 294 return result;
@@ -536,7 +536,7 @@ static int cbaf_cc_upload(struct cbaf *cbaf)
536 CBAF_REQ_SET_ASSOCIATION_RESPONSE, 536 CBAF_REQ_SET_ASSOCIATION_RESPONSE,
537 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 537 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
538 0x0201, cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber, 538 0x0201, cbaf->usb_iface->cur_altsetting->desc.bInterfaceNumber,
539 ccd, sizeof(*ccd), 1000 /* FIXME: arbitrary */); 539 ccd, sizeof(*ccd), USB_CTRL_SET_TIMEOUT);
540 540
541 return result; 541 return result;
542} 542}
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index 4c40d0dbf53d..790c0b5c354c 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -165,7 +165,7 @@ static int wusb_dev_set_encryption(struct usb_device *usb_dev, int value)
165 result = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), 165 result = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
166 USB_REQ_SET_ENCRYPTION, 166 USB_REQ_SET_ENCRYPTION,
167 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 167 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
168 value, 0, NULL, 0, 1000 /* FIXME: arbitrary */); 168 value, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
169 if (result < 0) 169 if (result < 0)
170 dev_err(dev, "Can't set device's WUSB encryption to " 170 dev_err(dev, "Can't set device's WUSB encryption to "
171 "%s (value %d): %d\n", 171 "%s (value %d): %d\n",
@@ -191,7 +191,7 @@ static int wusb_dev_set_gtk(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
191 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 191 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
192 USB_DT_KEY << 8 | key_index, 0, 192 USB_DT_KEY << 8 | key_index, 0,
193 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength, 193 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength,
194 1000); 194 USB_CTRL_SET_TIMEOUT);
195} 195}
196 196
197 197
@@ -301,8 +301,9 @@ int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
301 301
302 /* Set address 0 */ 302 /* Set address 0 */
303 result = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), 303 result = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
304 USB_REQ_SET_ADDRESS, 0, 304 USB_REQ_SET_ADDRESS,
305 0, 0, NULL, 0, 1000 /* FIXME: arbitrary */); 305 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
306 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
306 if (result < 0) { 307 if (result < 0) {
307 dev_err(dev, "auth failed: can't set address 0: %d\n", 308 dev_err(dev, "auth failed: can't set address 0: %d\n",
308 result); 309 result);
@@ -316,9 +317,10 @@ int wusb_dev_update_address(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
316 317
317 /* Set new (authenticated) address. */ 318 /* Set new (authenticated) address. */
318 result = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), 319 result = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
319 USB_REQ_SET_ADDRESS, 0, 320 USB_REQ_SET_ADDRESS,
320 new_address, 0, NULL, 0, 321 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
321 1000 /* FIXME: arbitrary */); 322 new_address, 0, NULL, 0,
323 USB_CTRL_SET_TIMEOUT);
322 if (result < 0) { 324 if (result < 0) {
323 dev_err(dev, "auth failed: can't set address %u: %d\n", 325 dev_err(dev, "auth failed: can't set address %u: %d\n",
324 new_address, result); 326 new_address, result);
@@ -381,7 +383,7 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
381 usb_dev, usb_sndctrlpipe(usb_dev, 0), 383 usb_dev, usb_sndctrlpipe(usb_dev, 0),
382 USB_REQ_SET_HANDSHAKE, 384 USB_REQ_SET_HANDSHAKE,
383 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 385 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
384 1, 0, &hs[0], sizeof(hs[0]), 1000 /* FIXME: arbitrary */); 386 1, 0, &hs[0], sizeof(hs[0]), USB_CTRL_SET_TIMEOUT);
385 if (result < 0) { 387 if (result < 0) {
386 dev_err(dev, "Handshake1: request failed: %d\n", result); 388 dev_err(dev, "Handshake1: request failed: %d\n", result);
387 goto error_hs1; 389 goto error_hs1;
@@ -392,7 +394,7 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
392 usb_dev, usb_rcvctrlpipe(usb_dev, 0), 394 usb_dev, usb_rcvctrlpipe(usb_dev, 0),
393 USB_REQ_GET_HANDSHAKE, 395 USB_REQ_GET_HANDSHAKE,
394 USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 396 USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
395 2, 0, &hs[1], sizeof(hs[1]), 1000 /* FIXME: arbitrary */); 397 2, 0, &hs[1], sizeof(hs[1]), USB_CTRL_GET_TIMEOUT);
396 if (result < 0) { 398 if (result < 0) {
397 dev_err(dev, "Handshake2: request failed: %d\n", result); 399 dev_err(dev, "Handshake2: request failed: %d\n", result);
398 goto error_hs2; 400 goto error_hs2;
@@ -469,7 +471,7 @@ int wusb_dev_4way_handshake(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev,
469 usb_dev, usb_sndctrlpipe(usb_dev, 0), 471 usb_dev, usb_sndctrlpipe(usb_dev, 0),
470 USB_REQ_SET_HANDSHAKE, 472 USB_REQ_SET_HANDSHAKE,
471 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 473 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
472 3, 0, &hs[2], sizeof(hs[2]), 1000 /* FIXME: arbitrary */); 474 3, 0, &hs[2], sizeof(hs[2]), USB_CTRL_SET_TIMEOUT);
473 if (result < 0) { 475 if (result < 0) {
474 dev_err(dev, "Handshake3: request failed: %d\n", result); 476 dev_err(dev, "Handshake3: request failed: %d\n", result);
475 goto error_hs3; 477 goto error_hs3;
diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
index e614f02f0cf2..b93d2cbdf33f 100644
--- a/drivers/usb/wusbcore/wa-hc.h
+++ b/drivers/usb/wusbcore/wa-hc.h
@@ -332,7 +332,7 @@ static inline int rpipe_avail_inc(struct wa_rpipe *rpipe)
332/* Transferring data */ 332/* Transferring data */
333extern int wa_urb_enqueue(struct wahc *, struct usb_host_endpoint *, 333extern int wa_urb_enqueue(struct wahc *, struct usb_host_endpoint *,
334 struct urb *, gfp_t); 334 struct urb *, gfp_t);
335extern int wa_urb_dequeue(struct wahc *, struct urb *); 335extern int wa_urb_dequeue(struct wahc *, struct urb *, int);
336extern void wa_handle_notif_xfer(struct wahc *, struct wa_notif_hdr *); 336extern void wa_handle_notif_xfer(struct wahc *, struct wa_notif_hdr *);
337 337
338 338
@@ -366,7 +366,7 @@ static inline int __wa_feature(struct wahc *wa, unsigned op, u16 feature)
366 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 366 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
367 feature, 367 feature,
368 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber, 368 wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
369 NULL, 0, 1000 /* FIXME: arbitrary */); 369 NULL, 0, USB_CTRL_SET_TIMEOUT);
370} 370}
371 371
372 372
@@ -400,8 +400,7 @@ s32 __wa_get_status(struct wahc *wa)
400 USB_REQ_GET_STATUS, 400 USB_REQ_GET_STATUS,
401 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 401 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
402 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber, 402 0, wa->usb_iface->cur_altsetting->desc.bInterfaceNumber,
403 &wa->status, sizeof(wa->status), 403 &wa->status, sizeof(wa->status), USB_CTRL_GET_TIMEOUT);
404 1000 /* FIXME: arbitrary */);
405 if (result >= 0) 404 if (result >= 0)
406 result = wa->status; 405 result = wa->status;
407 return result; 406 return result;
diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c
index b48e74cc54d7..accdd15f5393 100644
--- a/drivers/usb/wusbcore/wa-rpipe.c
+++ b/drivers/usb/wusbcore/wa-rpipe.c
@@ -80,7 +80,7 @@ static int __rpipe_get_descr(struct wahc *wa,
80 USB_REQ_GET_DESCRIPTOR, 80 USB_REQ_GET_DESCRIPTOR,
81 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_RPIPE, 81 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_RPIPE,
82 USB_DT_RPIPE<<8, index, descr, sizeof(*descr), 82 USB_DT_RPIPE<<8, index, descr, sizeof(*descr),
83 1000 /* FIXME: arbitrary */); 83 USB_CTRL_GET_TIMEOUT);
84 if (result < 0) { 84 if (result < 0) {
85 dev_err(dev, "rpipe %u: get descriptor failed: %d\n", 85 dev_err(dev, "rpipe %u: get descriptor failed: %d\n",
86 index, (int)result); 86 index, (int)result);
@@ -118,7 +118,7 @@ static int __rpipe_set_descr(struct wahc *wa,
118 USB_REQ_SET_DESCRIPTOR, 118 USB_REQ_SET_DESCRIPTOR,
119 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE, 119 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE,
120 USB_DT_RPIPE<<8, index, descr, sizeof(*descr), 120 USB_DT_RPIPE<<8, index, descr, sizeof(*descr),
121 HZ / 10); 121 USB_CTRL_SET_TIMEOUT);
122 if (result < 0) { 122 if (result < 0) {
123 dev_err(dev, "rpipe %u: set descriptor failed: %d\n", 123 dev_err(dev, "rpipe %u: set descriptor failed: %d\n",
124 index, (int)result); 124 index, (int)result);
@@ -237,7 +237,7 @@ static int __rpipe_reset(struct wahc *wa, unsigned index)
237 wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0), 237 wa->usb_dev, usb_sndctrlpipe(wa->usb_dev, 0),
238 USB_REQ_RPIPE_RESET, 238 USB_REQ_RPIPE_RESET,
239 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE, 239 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE,
240 0, index, NULL, 0, 1000 /* FIXME: arbitrary */); 240 0, index, NULL, 0, USB_CTRL_SET_TIMEOUT);
241 if (result < 0) 241 if (result < 0)
242 dev_err(dev, "rpipe %u: reset failed: %d\n", 242 dev_err(dev, "rpipe %u: reset failed: %d\n",
243 index, result); 243 index, result);
@@ -527,7 +527,7 @@ void rpipe_ep_disable(struct wahc *wa, struct usb_host_endpoint *ep)
527 wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0), 527 wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0),
528 USB_REQ_RPIPE_ABORT, 528 USB_REQ_RPIPE_ABORT,
529 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE, 529 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE,
530 0, index, NULL, 0, 1000 /* FIXME: arbitrary */); 530 0, index, NULL, 0, USB_CTRL_SET_TIMEOUT);
531 rpipe_put(rpipe); 531 rpipe_put(rpipe);
532 } 532 }
533 mutex_unlock(&wa->rpipe_mutex); 533 mutex_unlock(&wa->rpipe_mutex);
@@ -548,7 +548,7 @@ void rpipe_clear_feature_stalled(struct wahc *wa, struct usb_host_endpoint *ep)
548 wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0), 548 wa->usb_dev, usb_rcvctrlpipe(wa->usb_dev, 0),
549 USB_REQ_CLEAR_FEATURE, 549 USB_REQ_CLEAR_FEATURE,
550 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE, 550 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_RPIPE,
551 RPIPE_STALL, index, NULL, 0, 1000); 551 RPIPE_STALL, index, NULL, 0, USB_CTRL_SET_TIMEOUT);
552 } 552 }
553 mutex_unlock(&wa->rpipe_mutex); 553 mutex_unlock(&wa->rpipe_mutex);
554} 554}
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index ed5abe87b049..a70e142da330 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -124,6 +124,8 @@ struct wa_seg {
124 u8 index; /* which segment we are */ 124 u8 index; /* which segment we are */
125 int isoc_frame_count; /* number of isoc frames in this segment. */ 125 int isoc_frame_count; /* number of isoc frames in this segment. */
126 int isoc_frame_offset; /* starting frame offset in the xfer URB. */ 126 int isoc_frame_offset; /* starting frame offset in the xfer URB. */
127 /* Isoc frame that the current transfer buffer corresponds to. */
128 int isoc_frame_index;
127 int isoc_size; /* size of all isoc frames sent by this seg. */ 129 int isoc_size; /* size of all isoc frames sent by this seg. */
128 enum wa_seg_status status; 130 enum wa_seg_status status;
129 ssize_t result; /* bytes xfered or error */ 131 ssize_t result; /* bytes xfered or error */
@@ -158,8 +160,6 @@ struct wa_xfer {
158 unsigned is_dma:1; 160 unsigned is_dma:1;
159 size_t seg_size; 161 size_t seg_size;
160 int result; 162 int result;
161 /* Isoc frame that the current transfer buffer corresponds to. */
162 int dto_isoc_frame_index;
163 163
164 gfp_t gfp; /* allocation mask */ 164 gfp_t gfp; /* allocation mask */
165 165
@@ -282,6 +282,7 @@ static void wa_xfer_giveback(struct wa_xfer *xfer)
282 282
283 spin_lock_irqsave(&xfer->wa->xfer_list_lock, flags); 283 spin_lock_irqsave(&xfer->wa->xfer_list_lock, flags);
284 list_del_init(&xfer->list_node); 284 list_del_init(&xfer->list_node);
285 usb_hcd_unlink_urb_from_ep(&(xfer->wa->wusb->usb_hcd), xfer->urb);
285 spin_unlock_irqrestore(&xfer->wa->xfer_list_lock, flags); 286 spin_unlock_irqrestore(&xfer->wa->xfer_list_lock, flags);
286 /* FIXME: segmentation broken -- kills DWA */ 287 /* FIXME: segmentation broken -- kills DWA */
287 wusbhc_giveback_urb(xfer->wa->wusb, xfer->urb, xfer->result); 288 wusbhc_giveback_urb(xfer->wa->wusb, xfer->urb, xfer->result);
@@ -372,10 +373,10 @@ static unsigned __wa_xfer_is_done(struct wa_xfer *xfer)
372 seg->result); 373 seg->result);
373 goto out; 374 goto out;
374 case WA_SEG_ABORTED: 375 case WA_SEG_ABORTED:
375 dev_dbg(dev, "xfer %p ID %08X#%u ABORTED: result %d\n", 376 xfer->result = seg->result;
376 xfer, wa_xfer_id(xfer), seg->index, 377 dev_dbg(dev, "xfer %p ID %08X#%u: ABORTED result %zu(0x%08zX)\n",
377 urb->status); 378 xfer, wa_xfer_id(xfer), seg->index, seg->result,
378 xfer->result = urb->status; 379 seg->result);
379 goto out; 380 goto out;
380 default: 381 default:
381 dev_warn(dev, "xfer %p ID %08X#%u: is_done bad state %d\n", 382 dev_warn(dev, "xfer %p ID %08X#%u: is_done bad state %d\n",
@@ -700,23 +701,23 @@ static void wa_seg_dto_cb(struct urb *urb)
700 if (usb_pipeisoc(xfer->urb->pipe)) { 701 if (usb_pipeisoc(xfer->urb->pipe)) {
701 /* Alereon HWA sends all isoc frames in a single transfer. */ 702 /* Alereon HWA sends all isoc frames in a single transfer. */
702 if (wa->quirks & WUSB_QUIRK_ALEREON_HWA_CONCAT_ISOC) 703 if (wa->quirks & WUSB_QUIRK_ALEREON_HWA_CONCAT_ISOC)
703 xfer->dto_isoc_frame_index += seg->isoc_frame_count; 704 seg->isoc_frame_index += seg->isoc_frame_count;
704 else 705 else
705 xfer->dto_isoc_frame_index += 1; 706 seg->isoc_frame_index += 1;
706 if (xfer->dto_isoc_frame_index < seg->isoc_frame_count) { 707 if (seg->isoc_frame_index < seg->isoc_frame_count) {
707 data_send_done = 0; 708 data_send_done = 0;
708 holding_dto = 1; /* checked in error cases. */ 709 holding_dto = 1; /* checked in error cases. */
709 /* 710 /*
710 * if this is the last isoc frame of the segment, we 711 * if this is the last isoc frame of the segment, we
711 * can release DTO after sending this frame. 712 * can release DTO after sending this frame.
712 */ 713 */
713 if ((xfer->dto_isoc_frame_index + 1) >= 714 if ((seg->isoc_frame_index + 1) >=
714 seg->isoc_frame_count) 715 seg->isoc_frame_count)
715 release_dto = 1; 716 release_dto = 1;
716 } 717 }
717 dev_dbg(dev, "xfer 0x%08X#%u: isoc frame = %d, holding_dto = %d, release_dto = %d.\n", 718 dev_dbg(dev, "xfer 0x%08X#%u: isoc frame = %d, holding_dto = %d, release_dto = %d.\n",
718 wa_xfer_id(xfer), seg->index, 719 wa_xfer_id(xfer), seg->index, seg->isoc_frame_index,
719 xfer->dto_isoc_frame_index, holding_dto, release_dto); 720 holding_dto, release_dto);
720 } 721 }
721 spin_unlock_irqrestore(&xfer->lock, flags); 722 spin_unlock_irqrestore(&xfer->lock, flags);
722 723
@@ -736,8 +737,7 @@ static void wa_seg_dto_cb(struct urb *urb)
736 * send the URB and release DTO if we no longer need it. 737 * send the URB and release DTO if we no longer need it.
737 */ 738 */
738 __wa_populate_dto_urb_isoc(xfer, seg, 739 __wa_populate_dto_urb_isoc(xfer, seg,
739 seg->isoc_frame_offset + 740 seg->isoc_frame_offset + seg->isoc_frame_index);
740 xfer->dto_isoc_frame_index);
741 741
742 /* resubmit the URB with the next isoc frame. */ 742 /* resubmit the URB with the next isoc frame. */
743 result = usb_submit_urb(seg->dto_urb, GFP_ATOMIC); 743 result = usb_submit_urb(seg->dto_urb, GFP_ATOMIC);
@@ -1259,8 +1259,11 @@ static int __wa_xfer_setup(struct wa_xfer *xfer, struct urb *urb)
1259 for (cnt = 1; cnt < xfer->segs; cnt++) { 1259 for (cnt = 1; cnt < xfer->segs; cnt++) {
1260 struct wa_xfer_packet_info_hwaiso *packet_desc; 1260 struct wa_xfer_packet_info_hwaiso *packet_desc;
1261 struct wa_seg *seg = xfer->seg[cnt]; 1261 struct wa_seg *seg = xfer->seg[cnt];
1262 struct wa_xfer_hwaiso *xfer_iso;
1262 1263
1263 xfer_hdr = &seg->xfer_hdr; 1264 xfer_hdr = &seg->xfer_hdr;
1265 xfer_iso = container_of(xfer_hdr,
1266 struct wa_xfer_hwaiso, hdr);
1264 packet_desc = ((void *)xfer_hdr) + xfer_hdr_size; 1267 packet_desc = ((void *)xfer_hdr) + xfer_hdr_size;
1265 /* 1268 /*
1266 * Copy values from the 0th header. Segment specific 1269 * Copy values from the 0th header. Segment specific
@@ -1270,6 +1273,8 @@ static int __wa_xfer_setup(struct wa_xfer *xfer, struct urb *urb)
1270 xfer_hdr->bTransferSegment = cnt; 1273 xfer_hdr->bTransferSegment = cnt;
1271 xfer_hdr->dwTransferLength = 1274 xfer_hdr->dwTransferLength =
1272 cpu_to_le32(seg->isoc_size); 1275 cpu_to_le32(seg->isoc_size);
1276 xfer_iso->dwNumOfPackets =
1277 cpu_to_le32(seg->isoc_frame_count);
1273 __wa_setup_isoc_packet_descr(packet_desc, xfer, seg); 1278 __wa_setup_isoc_packet_descr(packet_desc, xfer, seg);
1274 seg->status = WA_SEG_READY; 1279 seg->status = WA_SEG_READY;
1275 } 1280 }
@@ -1323,12 +1328,12 @@ static int __wa_seg_submit(struct wa_rpipe *rpipe, struct wa_xfer *xfer,
1323 struct wahc *wa = xfer->wa; 1328 struct wahc *wa = xfer->wa;
1324 1329
1325 result = usb_submit_urb(seg->isoc_pack_desc_urb, GFP_ATOMIC); 1330 result = usb_submit_urb(seg->isoc_pack_desc_urb, GFP_ATOMIC);
1331 seg->isoc_frame_index = 0;
1326 if (result < 0) { 1332 if (result < 0) {
1327 pr_err("%s: xfer %p#%u: ISO packet descriptor submit failed: %d\n", 1333 pr_err("%s: xfer %p#%u: ISO packet descriptor submit failed: %d\n",
1328 __func__, xfer, seg->index, result); 1334 __func__, xfer, seg->index, result);
1329 goto error_iso_pack_desc_submit; 1335 goto error_iso_pack_desc_submit;
1330 } 1336 }
1331 xfer->dto_isoc_frame_index = 0;
1332 /* 1337 /*
1333 * If this segment contains more than one isoc frame, hold 1338 * If this segment contains more than one isoc frame, hold
1334 * onto the dto resource until we send all frames. 1339 * onto the dto resource until we send all frames.
@@ -1567,7 +1572,8 @@ static int wa_urb_enqueue_b(struct wa_xfer *xfer)
1567 wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, urb->dev); 1572 wusb_dev = __wusb_dev_get_by_usb_dev(wusbhc, urb->dev);
1568 if (wusb_dev == NULL) { 1573 if (wusb_dev == NULL) {
1569 mutex_unlock(&wusbhc->mutex); 1574 mutex_unlock(&wusbhc->mutex);
1570 pr_err("%s: error wusb dev gone\n", __func__); 1575 dev_err(&(urb->dev->dev), "%s: error wusb dev gone\n",
1576 __func__);
1571 goto error_dev_gone; 1577 goto error_dev_gone;
1572 } 1578 }
1573 mutex_unlock(&wusbhc->mutex); 1579 mutex_unlock(&wusbhc->mutex);
@@ -1576,18 +1582,18 @@ static int wa_urb_enqueue_b(struct wa_xfer *xfer)
1576 xfer->wusb_dev = wusb_dev; 1582 xfer->wusb_dev = wusb_dev;
1577 result = urb->status; 1583 result = urb->status;
1578 if (urb->status != -EINPROGRESS) { 1584 if (urb->status != -EINPROGRESS) {
1579 pr_err("%s: error_dequeued\n", __func__); 1585 dev_err(&(urb->dev->dev), "%s: error_dequeued\n", __func__);
1580 goto error_dequeued; 1586 goto error_dequeued;
1581 } 1587 }
1582 1588
1583 result = __wa_xfer_setup(xfer, urb); 1589 result = __wa_xfer_setup(xfer, urb);
1584 if (result < 0) { 1590 if (result < 0) {
1585 pr_err("%s: error_xfer_setup\n", __func__); 1591 dev_err(&(urb->dev->dev), "%s: error_xfer_setup\n", __func__);
1586 goto error_xfer_setup; 1592 goto error_xfer_setup;
1587 } 1593 }
1588 result = __wa_xfer_submit(xfer); 1594 result = __wa_xfer_submit(xfer);
1589 if (result < 0) { 1595 if (result < 0) {
1590 pr_err("%s: error_xfer_submit\n", __func__); 1596 dev_err(&(urb->dev->dev), "%s: error_xfer_submit\n", __func__);
1591 goto error_xfer_submit; 1597 goto error_xfer_submit;
1592 } 1598 }
1593 spin_unlock_irqrestore(&xfer->lock, flags); 1599 spin_unlock_irqrestore(&xfer->lock, flags);
@@ -1730,6 +1736,12 @@ int wa_urb_enqueue(struct wahc *wa, struct usb_host_endpoint *ep,
1730 dump_stack(); 1736 dump_stack();
1731 } 1737 }
1732 1738
1739 spin_lock_irqsave(&wa->xfer_list_lock, my_flags);
1740 result = usb_hcd_link_urb_to_ep(&(wa->wusb->usb_hcd), urb);
1741 spin_unlock_irqrestore(&wa->xfer_list_lock, my_flags);
1742 if (result < 0)
1743 goto error_link_urb;
1744
1733 result = -ENOMEM; 1745 result = -ENOMEM;
1734 xfer = kzalloc(sizeof(*xfer), gfp); 1746 xfer = kzalloc(sizeof(*xfer), gfp);
1735 if (xfer == NULL) 1747 if (xfer == NULL)
@@ -1769,6 +1781,9 @@ int wa_urb_enqueue(struct wahc *wa, struct usb_host_endpoint *ep,
1769 __func__, result); 1781 __func__, result);
1770 wa_put(xfer->wa); 1782 wa_put(xfer->wa);
1771 wa_xfer_put(xfer); 1783 wa_xfer_put(xfer);
1784 spin_lock_irqsave(&wa->xfer_list_lock, my_flags);
1785 usb_hcd_unlink_urb_from_ep(&(wa->wusb->usb_hcd), urb);
1786 spin_unlock_irqrestore(&wa->xfer_list_lock, my_flags);
1772 return result; 1787 return result;
1773 } 1788 }
1774 } 1789 }
@@ -1777,6 +1792,10 @@ int wa_urb_enqueue(struct wahc *wa, struct usb_host_endpoint *ep,
1777error_dequeued: 1792error_dequeued:
1778 kfree(xfer); 1793 kfree(xfer);
1779error_kmalloc: 1794error_kmalloc:
1795 spin_lock_irqsave(&wa->xfer_list_lock, my_flags);
1796 usb_hcd_unlink_urb_from_ep(&(wa->wusb->usb_hcd), urb);
1797 spin_unlock_irqrestore(&wa->xfer_list_lock, my_flags);
1798error_link_urb:
1780 return result; 1799 return result;
1781} 1800}
1782EXPORT_SYMBOL_GPL(wa_urb_enqueue); 1801EXPORT_SYMBOL_GPL(wa_urb_enqueue);
@@ -1799,7 +1818,7 @@ EXPORT_SYMBOL_GPL(wa_urb_enqueue);
1799 * asynch request] and then make sure we cancel each segment. 1818 * asynch request] and then make sure we cancel each segment.
1800 * 1819 *
1801 */ 1820 */
1802int wa_urb_dequeue(struct wahc *wa, struct urb *urb) 1821int wa_urb_dequeue(struct wahc *wa, struct urb *urb, int status)
1803{ 1822{
1804 unsigned long flags, flags2; 1823 unsigned long flags, flags2;
1805 struct wa_xfer *xfer; 1824 struct wa_xfer *xfer;
@@ -1807,6 +1826,14 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
1807 struct wa_rpipe *rpipe; 1826 struct wa_rpipe *rpipe;
1808 unsigned cnt, done = 0, xfer_abort_pending; 1827 unsigned cnt, done = 0, xfer_abort_pending;
1809 unsigned rpipe_ready = 0; 1828 unsigned rpipe_ready = 0;
1829 int result;
1830
1831 /* check if it is safe to unlink. */
1832 spin_lock_irqsave(&wa->xfer_list_lock, flags);
1833 result = usb_hcd_check_unlink_urb(&(wa->wusb->usb_hcd), urb, status);
1834 spin_unlock_irqrestore(&wa->xfer_list_lock, flags);
1835 if (result)
1836 return result;
1810 1837
1811 xfer = urb->hcpriv; 1838 xfer = urb->hcpriv;
1812 if (xfer == NULL) { 1839 if (xfer == NULL) {
@@ -1822,9 +1849,10 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
1822 pr_debug("%s: DEQUEUE xfer id 0x%08X\n", __func__, wa_xfer_id(xfer)); 1849 pr_debug("%s: DEQUEUE xfer id 0x%08X\n", __func__, wa_xfer_id(xfer));
1823 rpipe = xfer->ep->hcpriv; 1850 rpipe = xfer->ep->hcpriv;
1824 if (rpipe == NULL) { 1851 if (rpipe == NULL) {
1825 pr_debug("%s: xfer id 0x%08X has no RPIPE. %s", 1852 pr_debug("%s: xfer %p id 0x%08X has no RPIPE. %s",
1826 __func__, wa_xfer_id(xfer), 1853 __func__, xfer, wa_xfer_id(xfer),
1827 "Probably already aborted.\n" ); 1854 "Probably already aborted.\n" );
1855 result = -ENOENT;
1828 goto out_unlock; 1856 goto out_unlock;
1829 } 1857 }
1830 /* Check the delayed list -> if there, release and complete */ 1858 /* Check the delayed list -> if there, release and complete */
@@ -1855,6 +1883,7 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
1855 * segments will be completed in the DTI interrupt. 1883 * segments will be completed in the DTI interrupt.
1856 */ 1884 */
1857 seg->status = WA_SEG_ABORTED; 1885 seg->status = WA_SEG_ABORTED;
1886 seg->result = -ENOENT;
1858 spin_lock_irqsave(&rpipe->seg_lock, flags2); 1887 spin_lock_irqsave(&rpipe->seg_lock, flags2);
1859 list_del(&seg->list_node); 1888 list_del(&seg->list_node);
1860 xfer->segs_done++; 1889 xfer->segs_done++;
@@ -1894,12 +1923,12 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
1894 wa_xfer_completion(xfer); 1923 wa_xfer_completion(xfer);
1895 if (rpipe_ready) 1924 if (rpipe_ready)
1896 wa_xfer_delayed_run(rpipe); 1925 wa_xfer_delayed_run(rpipe);
1897 return 0; 1926 return result;
1898 1927
1899out_unlock: 1928out_unlock:
1900 spin_unlock_irqrestore(&xfer->lock, flags); 1929 spin_unlock_irqrestore(&xfer->lock, flags);
1901out: 1930out:
1902 return 0; 1931 return result;
1903 1932
1904dequeue_delayed: 1933dequeue_delayed:
1905 list_del_init(&xfer->list_node); 1934 list_del_init(&xfer->list_node);
@@ -1935,7 +1964,7 @@ static int wa_xfer_status_to_errno(u8 status)
1935 [WA_XFER_STATUS_NOT_FOUND] = 0, 1964 [WA_XFER_STATUS_NOT_FOUND] = 0,
1936 [WA_XFER_STATUS_INSUFFICIENT_RESOURCE] = -ENOMEM, 1965 [WA_XFER_STATUS_INSUFFICIENT_RESOURCE] = -ENOMEM,
1937 [WA_XFER_STATUS_TRANSACTION_ERROR] = -EILSEQ, 1966 [WA_XFER_STATUS_TRANSACTION_ERROR] = -EILSEQ,
1938 [WA_XFER_STATUS_ABORTED] = -EINTR, 1967 [WA_XFER_STATUS_ABORTED] = -ENOENT,
1939 [WA_XFER_STATUS_RPIPE_NOT_READY] = EINVAL, 1968 [WA_XFER_STATUS_RPIPE_NOT_READY] = EINVAL,
1940 [WA_XFER_INVALID_FORMAT] = EINVAL, 1969 [WA_XFER_INVALID_FORMAT] = EINVAL,
1941 [WA_XFER_UNEXPECTED_SEGMENT_NUMBER] = EINVAL, 1970 [WA_XFER_UNEXPECTED_SEGMENT_NUMBER] = EINVAL,
@@ -1968,7 +1997,7 @@ static int wa_xfer_status_to_errno(u8 status)
1968 * the xfer will complete cleanly. 1997 * the xfer will complete cleanly.
1969 */ 1998 */
1970static void wa_complete_remaining_xfer_segs(struct wa_xfer *xfer, 1999static void wa_complete_remaining_xfer_segs(struct wa_xfer *xfer,
1971 struct wa_seg *incoming_seg) 2000 struct wa_seg *incoming_seg, enum wa_seg_status status)
1972{ 2001{
1973 int index; 2002 int index;
1974 struct wa_rpipe *rpipe = xfer->ep->hcpriv; 2003 struct wa_rpipe *rpipe = xfer->ep->hcpriv;
@@ -1990,7 +2019,7 @@ static void wa_complete_remaining_xfer_segs(struct wa_xfer *xfer,
1990 */ 2019 */
1991 case WA_SEG_DELAYED: 2020 case WA_SEG_DELAYED:
1992 xfer->segs_done++; 2021 xfer->segs_done++;
1993 current_seg->status = incoming_seg->status; 2022 current_seg->status = status;
1994 break; 2023 break;
1995 case WA_SEG_ABORTED: 2024 case WA_SEG_ABORTED:
1996 break; 2025 break;
@@ -2003,6 +2032,58 @@ static void wa_complete_remaining_xfer_segs(struct wa_xfer *xfer,
2003 } 2032 }
2004} 2033}
2005 2034
2035/* Populate the wa->buf_in_urb based on the current transfer state. */
2036static int wa_populate_buf_in_urb(struct wahc *wa, struct wa_xfer *xfer,
2037 unsigned int seg_idx, unsigned int bytes_transferred)
2038{
2039 int result = 0;
2040 struct wa_seg *seg = xfer->seg[seg_idx];
2041
2042 BUG_ON(wa->buf_in_urb->status == -EINPROGRESS);
2043 /* this should always be 0 before a resubmit. */
2044 wa->buf_in_urb->num_mapped_sgs = 0;
2045
2046 if (xfer->is_dma) {
2047 wa->buf_in_urb->transfer_dma = xfer->urb->transfer_dma
2048 + (seg_idx * xfer->seg_size);
2049 wa->buf_in_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2050 wa->buf_in_urb->transfer_buffer = NULL;
2051 wa->buf_in_urb->sg = NULL;
2052 wa->buf_in_urb->num_sgs = 0;
2053 } else {
2054 /* do buffer or SG processing. */
2055 wa->buf_in_urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP;
2056
2057 if (xfer->urb->transfer_buffer) {
2058 wa->buf_in_urb->transfer_buffer =
2059 xfer->urb->transfer_buffer
2060 + (seg_idx * xfer->seg_size);
2061 wa->buf_in_urb->sg = NULL;
2062 wa->buf_in_urb->num_sgs = 0;
2063 } else {
2064 /* allocate an SG list to store seg_size bytes
2065 and copy the subset of the xfer->urb->sg
2066 that matches the buffer subset we are
2067 about to read. */
2068 wa->buf_in_urb->sg = wa_xfer_create_subset_sg(
2069 xfer->urb->sg,
2070 seg_idx * xfer->seg_size,
2071 bytes_transferred,
2072 &(wa->buf_in_urb->num_sgs));
2073
2074 if (!(wa->buf_in_urb->sg)) {
2075 wa->buf_in_urb->num_sgs = 0;
2076 result = -ENOMEM;
2077 }
2078 wa->buf_in_urb->transfer_buffer = NULL;
2079 }
2080 }
2081 wa->buf_in_urb->transfer_buffer_length = bytes_transferred;
2082 wa->buf_in_urb->context = seg;
2083
2084 return result;
2085}
2086
2006/* 2087/*
2007 * Process a xfer result completion message 2088 * Process a xfer result completion message
2008 * 2089 *
@@ -2016,12 +2097,13 @@ static void wa_xfer_result_chew(struct wahc *wa, struct wa_xfer *xfer,
2016 int result; 2097 int result;
2017 struct device *dev = &wa->usb_iface->dev; 2098 struct device *dev = &wa->usb_iface->dev;
2018 unsigned long flags; 2099 unsigned long flags;
2019 u8 seg_idx; 2100 unsigned int seg_idx;
2020 struct wa_seg *seg; 2101 struct wa_seg *seg;
2021 struct wa_rpipe *rpipe; 2102 struct wa_rpipe *rpipe;
2022 unsigned done = 0; 2103 unsigned done = 0;
2023 u8 usb_status; 2104 u8 usb_status;
2024 unsigned rpipe_ready = 0; 2105 unsigned rpipe_ready = 0;
2106 unsigned bytes_transferred = le32_to_cpu(xfer_result->dwTransferLength);
2025 2107
2026 spin_lock_irqsave(&xfer->lock, flags); 2108 spin_lock_irqsave(&xfer->lock, flags);
2027 seg_idx = xfer_result->bTransferSegment & 0x7f; 2109 seg_idx = xfer_result->bTransferSegment & 0x7f;
@@ -2054,66 +2136,33 @@ static void wa_xfer_result_chew(struct wahc *wa, struct wa_xfer *xfer,
2054 /* FIXME: we ignore warnings, tally them for stats */ 2136 /* FIXME: we ignore warnings, tally them for stats */
2055 if (usb_status & 0x40) /* Warning?... */ 2137 if (usb_status & 0x40) /* Warning?... */
2056 usb_status = 0; /* ... pass */ 2138 usb_status = 0; /* ... pass */
2139 /*
2140 * If the last segment bit is set, complete the remaining segments.
2141 * When the current segment is completed, either in wa_buf_in_cb for
2142 * transfers with data or below for no data, the xfer will complete.
2143 */
2144 if (xfer_result->bTransferSegment & 0x80)
2145 wa_complete_remaining_xfer_segs(xfer, seg, WA_SEG_DONE);
2057 if (usb_pipeisoc(xfer->urb->pipe)) { 2146 if (usb_pipeisoc(xfer->urb->pipe)) {
2058 /* set up WA state to read the isoc packet status next. */ 2147 /* set up WA state to read the isoc packet status next. */
2059 wa->dti_isoc_xfer_in_progress = wa_xfer_id(xfer); 2148 wa->dti_isoc_xfer_in_progress = wa_xfer_id(xfer);
2060 wa->dti_isoc_xfer_seg = seg_idx; 2149 wa->dti_isoc_xfer_seg = seg_idx;
2061 wa->dti_state = WA_DTI_ISOC_PACKET_STATUS_PENDING; 2150 wa->dti_state = WA_DTI_ISOC_PACKET_STATUS_PENDING;
2062 } else if (xfer->is_inbound) { /* IN data phase: read to buffer */ 2151 } else if ((xfer->is_inbound)
2152 && (bytes_transferred > 0)) {
2153 /* IN data phase: read to buffer */
2063 seg->status = WA_SEG_DTI_PENDING; 2154 seg->status = WA_SEG_DTI_PENDING;
2064 BUG_ON(wa->buf_in_urb->status == -EINPROGRESS); 2155 result = wa_populate_buf_in_urb(wa, xfer, seg_idx,
2065 /* this should always be 0 before a resubmit. */ 2156 bytes_transferred);
2066 wa->buf_in_urb->num_mapped_sgs = 0; 2157 if (result < 0)
2067 2158 goto error_buf_in_populate;
2068 if (xfer->is_dma) {
2069 wa->buf_in_urb->transfer_dma =
2070 xfer->urb->transfer_dma
2071 + (seg_idx * xfer->seg_size);
2072 wa->buf_in_urb->transfer_flags
2073 |= URB_NO_TRANSFER_DMA_MAP;
2074 wa->buf_in_urb->transfer_buffer = NULL;
2075 wa->buf_in_urb->sg = NULL;
2076 wa->buf_in_urb->num_sgs = 0;
2077 } else {
2078 /* do buffer or SG processing. */
2079 wa->buf_in_urb->transfer_flags
2080 &= ~URB_NO_TRANSFER_DMA_MAP;
2081
2082 if (xfer->urb->transfer_buffer) {
2083 wa->buf_in_urb->transfer_buffer =
2084 xfer->urb->transfer_buffer
2085 + (seg_idx * xfer->seg_size);
2086 wa->buf_in_urb->sg = NULL;
2087 wa->buf_in_urb->num_sgs = 0;
2088 } else {
2089 /* allocate an SG list to store seg_size bytes
2090 and copy the subset of the xfer->urb->sg
2091 that matches the buffer subset we are
2092 about to read. */
2093 wa->buf_in_urb->sg = wa_xfer_create_subset_sg(
2094 xfer->urb->sg,
2095 seg_idx * xfer->seg_size,
2096 le32_to_cpu(
2097 xfer_result->dwTransferLength),
2098 &(wa->buf_in_urb->num_sgs));
2099
2100 if (!(wa->buf_in_urb->sg)) {
2101 wa->buf_in_urb->num_sgs = 0;
2102 goto error_sg_alloc;
2103 }
2104 wa->buf_in_urb->transfer_buffer = NULL;
2105 }
2106 }
2107 wa->buf_in_urb->transfer_buffer_length =
2108 le32_to_cpu(xfer_result->dwTransferLength);
2109 wa->buf_in_urb->context = seg;
2110 result = usb_submit_urb(wa->buf_in_urb, GFP_ATOMIC); 2159 result = usb_submit_urb(wa->buf_in_urb, GFP_ATOMIC);
2111 if (result < 0) 2160 if (result < 0)
2112 goto error_submit_buf_in; 2161 goto error_submit_buf_in;
2113 } else { 2162 } else {
2114 /* OUT data phase, complete it -- */ 2163 /* OUT data phase or no data, complete it -- */
2115 seg->status = WA_SEG_DONE; 2164 seg->status = WA_SEG_DONE;
2116 seg->result = le32_to_cpu(xfer_result->dwTransferLength); 2165 seg->result = bytes_transferred;
2117 xfer->segs_done++; 2166 xfer->segs_done++;
2118 rpipe_ready = rpipe_avail_inc(rpipe); 2167 rpipe_ready = rpipe_avail_inc(rpipe);
2119 done = __wa_xfer_is_done(xfer); 2168 done = __wa_xfer_is_done(xfer);
@@ -2137,13 +2186,13 @@ error_submit_buf_in:
2137 seg->result = result; 2186 seg->result = result;
2138 kfree(wa->buf_in_urb->sg); 2187 kfree(wa->buf_in_urb->sg);
2139 wa->buf_in_urb->sg = NULL; 2188 wa->buf_in_urb->sg = NULL;
2140error_sg_alloc: 2189error_buf_in_populate:
2141 __wa_xfer_abort(xfer); 2190 __wa_xfer_abort(xfer);
2142 seg->status = WA_SEG_ERROR; 2191 seg->status = WA_SEG_ERROR;
2143error_complete: 2192error_complete:
2144 xfer->segs_done++; 2193 xfer->segs_done++;
2145 rpipe_ready = rpipe_avail_inc(rpipe); 2194 rpipe_ready = rpipe_avail_inc(rpipe);
2146 wa_complete_remaining_xfer_segs(xfer, seg); 2195 wa_complete_remaining_xfer_segs(xfer, seg, seg->status);
2147 done = __wa_xfer_is_done(xfer); 2196 done = __wa_xfer_is_done(xfer);
2148 /* 2197 /*
2149 * queue work item to clear STALL for control endpoints. 2198 * queue work item to clear STALL for control endpoints.
@@ -2172,7 +2221,7 @@ error_complete:
2172 2221
2173error_bad_seg: 2222error_bad_seg:
2174 spin_unlock_irqrestore(&xfer->lock, flags); 2223 spin_unlock_irqrestore(&xfer->lock, flags);
2175 wa_urb_dequeue(wa, xfer->urb); 2224 wa_urb_dequeue(wa, xfer->urb, -ENOENT);
2176 if (printk_ratelimit()) 2225 if (printk_ratelimit())
2177 dev_err(dev, "xfer %p#%u: bad segment\n", xfer, seg_idx); 2226 dev_err(dev, "xfer %p#%u: bad segment\n", xfer, seg_idx);
2178 if (edc_inc(&wa->dti_edc, EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) { 2227 if (edc_inc(&wa->dti_edc, EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {