diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-07 17:45:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-07 17:45:22 -0400 |
commit | d4669bb1427cca46dfb4a0f789febee56deab47e (patch) | |
tree | 5da31c96bcaee62996db2d22e6e2327d8be1321a | |
parent | d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff) | |
parent | b2e2c94b878be2500d4d42c1f52a2fa1fe7648b4 (diff) |
Merge tag 'fixes-for-v4.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus
Felipe writes:
usb: fixes for-v4.2-rc2
The first set of fixes for this -rc cycle. Most importantly
we have a NULL pointer dereference fix on DWC3, a fix to a
really old bug on musb_start() and another NULL pointer
dereference fix on MXS phy driver.
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc2/core.c | 55 | ||||
-rw-r--r-- | drivers/usb/dwc2/core.h | 9 | ||||
-rw-r--r-- | drivers/usb/dwc2/hcd.c | 55 | ||||
-rw-r--r-- | drivers/usb/dwc2/hcd.h | 5 | ||||
-rw-r--r-- | drivers/usb/dwc2/hcd_queue.c | 49 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.c | 6 | ||||
-rw-r--r-- | drivers/usb/gadget/composite.c | 11 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 6 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_mass_storage.c | 16 | ||||
-rw-r--r-- | drivers/usb/gadget/function/f_midi.c | 4 | ||||
-rw-r--r-- | drivers/usb/gadget/udc/fotg210-udc.c | 3 | ||||
-rw-r--r-- | drivers/usb/musb/musb_virthub.c | 4 | ||||
-rw-r--r-- | drivers/usb/phy/phy-mxs-usb.c | 3 |
13 files changed, 113 insertions, 113 deletions
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index e5b546f1152e..c3cc1a78d1e2 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c | |||
@@ -72,17 +72,7 @@ static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) | |||
72 | dev_dbg(hsotg->dev, "%s\n", __func__); | 72 | dev_dbg(hsotg->dev, "%s\n", __func__); |
73 | 73 | ||
74 | /* Backup Host regs */ | 74 | /* Backup Host regs */ |
75 | hr = hsotg->hr_backup; | 75 | hr = &hsotg->hr_backup; |
76 | if (!hr) { | ||
77 | hr = devm_kzalloc(hsotg->dev, sizeof(*hr), GFP_KERNEL); | ||
78 | if (!hr) { | ||
79 | dev_err(hsotg->dev, "%s: can't allocate host regs\n", | ||
80 | __func__); | ||
81 | return -ENOMEM; | ||
82 | } | ||
83 | |||
84 | hsotg->hr_backup = hr; | ||
85 | } | ||
86 | hr->hcfg = readl(hsotg->regs + HCFG); | 76 | hr->hcfg = readl(hsotg->regs + HCFG); |
87 | hr->haintmsk = readl(hsotg->regs + HAINTMSK); | 77 | hr->haintmsk = readl(hsotg->regs + HAINTMSK); |
88 | for (i = 0; i < hsotg->core_params->host_channels; ++i) | 78 | for (i = 0; i < hsotg->core_params->host_channels; ++i) |
@@ -90,6 +80,7 @@ static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) | |||
90 | 80 | ||
91 | hr->hprt0 = readl(hsotg->regs + HPRT0); | 81 | hr->hprt0 = readl(hsotg->regs + HPRT0); |
92 | hr->hfir = readl(hsotg->regs + HFIR); | 82 | hr->hfir = readl(hsotg->regs + HFIR); |
83 | hr->valid = true; | ||
93 | 84 | ||
94 | return 0; | 85 | return 0; |
95 | } | 86 | } |
@@ -109,12 +100,13 @@ static int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg) | |||
109 | dev_dbg(hsotg->dev, "%s\n", __func__); | 100 | dev_dbg(hsotg->dev, "%s\n", __func__); |
110 | 101 | ||
111 | /* Restore host regs */ | 102 | /* Restore host regs */ |
112 | hr = hsotg->hr_backup; | 103 | hr = &hsotg->hr_backup; |
113 | if (!hr) { | 104 | if (!hr->valid) { |
114 | dev_err(hsotg->dev, "%s: no host registers to restore\n", | 105 | dev_err(hsotg->dev, "%s: no host registers to restore\n", |
115 | __func__); | 106 | __func__); |
116 | return -EINVAL; | 107 | return -EINVAL; |
117 | } | 108 | } |
109 | hr->valid = false; | ||
118 | 110 | ||
119 | writel(hr->hcfg, hsotg->regs + HCFG); | 111 | writel(hr->hcfg, hsotg->regs + HCFG); |
120 | writel(hr->haintmsk, hsotg->regs + HAINTMSK); | 112 | writel(hr->haintmsk, hsotg->regs + HAINTMSK); |
@@ -152,17 +144,7 @@ static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) | |||
152 | dev_dbg(hsotg->dev, "%s\n", __func__); | 144 | dev_dbg(hsotg->dev, "%s\n", __func__); |
153 | 145 | ||
154 | /* Backup dev regs */ | 146 | /* Backup dev regs */ |
155 | dr = hsotg->dr_backup; | 147 | dr = &hsotg->dr_backup; |
156 | if (!dr) { | ||
157 | dr = devm_kzalloc(hsotg->dev, sizeof(*dr), GFP_KERNEL); | ||
158 | if (!dr) { | ||
159 | dev_err(hsotg->dev, "%s: can't allocate device regs\n", | ||
160 | __func__); | ||
161 | return -ENOMEM; | ||
162 | } | ||
163 | |||
164 | hsotg->dr_backup = dr; | ||
165 | } | ||
166 | 148 | ||
167 | dr->dcfg = readl(hsotg->regs + DCFG); | 149 | dr->dcfg = readl(hsotg->regs + DCFG); |
168 | dr->dctl = readl(hsotg->regs + DCTL); | 150 | dr->dctl = readl(hsotg->regs + DCTL); |
@@ -195,7 +177,7 @@ static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg) | |||
195 | dr->doeptsiz[i] = readl(hsotg->regs + DOEPTSIZ(i)); | 177 | dr->doeptsiz[i] = readl(hsotg->regs + DOEPTSIZ(i)); |
196 | dr->doepdma[i] = readl(hsotg->regs + DOEPDMA(i)); | 178 | dr->doepdma[i] = readl(hsotg->regs + DOEPDMA(i)); |
197 | } | 179 | } |
198 | 180 | dr->valid = true; | |
199 | return 0; | 181 | return 0; |
200 | } | 182 | } |
201 | 183 | ||
@@ -215,12 +197,13 @@ static int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg) | |||
215 | dev_dbg(hsotg->dev, "%s\n", __func__); | 197 | dev_dbg(hsotg->dev, "%s\n", __func__); |
216 | 198 | ||
217 | /* Restore dev regs */ | 199 | /* Restore dev regs */ |
218 | dr = hsotg->dr_backup; | 200 | dr = &hsotg->dr_backup; |
219 | if (!dr) { | 201 | if (!dr->valid) { |
220 | dev_err(hsotg->dev, "%s: no device registers to restore\n", | 202 | dev_err(hsotg->dev, "%s: no device registers to restore\n", |
221 | __func__); | 203 | __func__); |
222 | return -EINVAL; | 204 | return -EINVAL; |
223 | } | 205 | } |
206 | dr->valid = false; | ||
224 | 207 | ||
225 | writel(dr->dcfg, hsotg->regs + DCFG); | 208 | writel(dr->dcfg, hsotg->regs + DCFG); |
226 | writel(dr->dctl, hsotg->regs + DCTL); | 209 | writel(dr->dctl, hsotg->regs + DCTL); |
@@ -268,17 +251,7 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg) | |||
268 | int i; | 251 | int i; |
269 | 252 | ||
270 | /* Backup global regs */ | 253 | /* Backup global regs */ |
271 | gr = hsotg->gr_backup; | 254 | gr = &hsotg->gr_backup; |
272 | if (!gr) { | ||
273 | gr = devm_kzalloc(hsotg->dev, sizeof(*gr), GFP_KERNEL); | ||
274 | if (!gr) { | ||
275 | dev_err(hsotg->dev, "%s: can't allocate global regs\n", | ||
276 | __func__); | ||
277 | return -ENOMEM; | ||
278 | } | ||
279 | |||
280 | hsotg->gr_backup = gr; | ||
281 | } | ||
282 | 255 | ||
283 | gr->gotgctl = readl(hsotg->regs + GOTGCTL); | 256 | gr->gotgctl = readl(hsotg->regs + GOTGCTL); |
284 | gr->gintmsk = readl(hsotg->regs + GINTMSK); | 257 | gr->gintmsk = readl(hsotg->regs + GINTMSK); |
@@ -291,6 +264,7 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg *hsotg) | |||
291 | for (i = 0; i < MAX_EPS_CHANNELS; i++) | 264 | for (i = 0; i < MAX_EPS_CHANNELS; i++) |
292 | gr->dtxfsiz[i] = readl(hsotg->regs + DPTXFSIZN(i)); | 265 | gr->dtxfsiz[i] = readl(hsotg->regs + DPTXFSIZN(i)); |
293 | 266 | ||
267 | gr->valid = true; | ||
294 | return 0; | 268 | return 0; |
295 | } | 269 | } |
296 | 270 | ||
@@ -309,12 +283,13 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg) | |||
309 | dev_dbg(hsotg->dev, "%s\n", __func__); | 283 | dev_dbg(hsotg->dev, "%s\n", __func__); |
310 | 284 | ||
311 | /* Restore global regs */ | 285 | /* Restore global regs */ |
312 | gr = hsotg->gr_backup; | 286 | gr = &hsotg->gr_backup; |
313 | if (!gr) { | 287 | if (!gr->valid) { |
314 | dev_err(hsotg->dev, "%s: no global registers to restore\n", | 288 | dev_err(hsotg->dev, "%s: no global registers to restore\n", |
315 | __func__); | 289 | __func__); |
316 | return -EINVAL; | 290 | return -EINVAL; |
317 | } | 291 | } |
292 | gr->valid = false; | ||
318 | 293 | ||
319 | writel(0xffffffff, hsotg->regs + GINTSTS); | 294 | writel(0xffffffff, hsotg->regs + GINTSTS); |
320 | writel(gr->gotgctl, hsotg->regs + GOTGCTL); | 295 | writel(gr->gotgctl, hsotg->regs + GOTGCTL); |
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 53b8de03f102..0ed87620941b 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h | |||
@@ -492,6 +492,7 @@ struct dwc2_gregs_backup { | |||
492 | u32 gdfifocfg; | 492 | u32 gdfifocfg; |
493 | u32 dtxfsiz[MAX_EPS_CHANNELS]; | 493 | u32 dtxfsiz[MAX_EPS_CHANNELS]; |
494 | u32 gpwrdn; | 494 | u32 gpwrdn; |
495 | bool valid; | ||
495 | }; | 496 | }; |
496 | 497 | ||
497 | /** | 498 | /** |
@@ -521,6 +522,7 @@ struct dwc2_dregs_backup { | |||
521 | u32 doepctl[MAX_EPS_CHANNELS]; | 522 | u32 doepctl[MAX_EPS_CHANNELS]; |
522 | u32 doeptsiz[MAX_EPS_CHANNELS]; | 523 | u32 doeptsiz[MAX_EPS_CHANNELS]; |
523 | u32 doepdma[MAX_EPS_CHANNELS]; | 524 | u32 doepdma[MAX_EPS_CHANNELS]; |
525 | bool valid; | ||
524 | }; | 526 | }; |
525 | 527 | ||
526 | /** | 528 | /** |
@@ -538,6 +540,7 @@ struct dwc2_hregs_backup { | |||
538 | u32 hcintmsk[MAX_EPS_CHANNELS]; | 540 | u32 hcintmsk[MAX_EPS_CHANNELS]; |
539 | u32 hprt0; | 541 | u32 hprt0; |
540 | u32 hfir; | 542 | u32 hfir; |
543 | bool valid; | ||
541 | }; | 544 | }; |
542 | 545 | ||
543 | /** | 546 | /** |
@@ -705,9 +708,9 @@ struct dwc2_hsotg { | |||
705 | struct work_struct wf_otg; | 708 | struct work_struct wf_otg; |
706 | struct timer_list wkp_timer; | 709 | struct timer_list wkp_timer; |
707 | enum dwc2_lx_state lx_state; | 710 | enum dwc2_lx_state lx_state; |
708 | struct dwc2_gregs_backup *gr_backup; | 711 | struct dwc2_gregs_backup gr_backup; |
709 | struct dwc2_dregs_backup *dr_backup; | 712 | struct dwc2_dregs_backup dr_backup; |
710 | struct dwc2_hregs_backup *hr_backup; | 713 | struct dwc2_hregs_backup hr_backup; |
711 | 714 | ||
712 | struct dentry *debug_root; | 715 | struct dentry *debug_root; |
713 | struct debugfs_regset32 *regset; | 716 | struct debugfs_regset32 *regset; |
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index b10377c65064..f845c41fe9e5 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c | |||
@@ -359,10 +359,9 @@ void dwc2_hcd_stop(struct dwc2_hsotg *hsotg) | |||
359 | 359 | ||
360 | /* Caller must hold driver lock */ | 360 | /* Caller must hold driver lock */ |
361 | static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, | 361 | static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, |
362 | struct dwc2_hcd_urb *urb, void **ep_handle, | 362 | struct dwc2_hcd_urb *urb, struct dwc2_qh *qh, |
363 | gfp_t mem_flags) | 363 | struct dwc2_qtd *qtd) |
364 | { | 364 | { |
365 | struct dwc2_qtd *qtd; | ||
366 | u32 intr_mask; | 365 | u32 intr_mask; |
367 | int retval; | 366 | int retval; |
368 | int dev_speed; | 367 | int dev_speed; |
@@ -386,18 +385,15 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg, | |||
386 | return -ENODEV; | 385 | return -ENODEV; |
387 | } | 386 | } |
388 | 387 | ||
389 | qtd = kzalloc(sizeof(*qtd), mem_flags); | ||
390 | if (!qtd) | 388 | if (!qtd) |
391 | return -ENOMEM; | 389 | return -EINVAL; |
392 | 390 | ||
393 | dwc2_hcd_qtd_init(qtd, urb); | 391 | dwc2_hcd_qtd_init(qtd, urb); |
394 | retval = dwc2_hcd_qtd_add(hsotg, qtd, (struct dwc2_qh **)ep_handle, | 392 | retval = dwc2_hcd_qtd_add(hsotg, qtd, qh); |
395 | mem_flags); | ||
396 | if (retval) { | 393 | if (retval) { |
397 | dev_err(hsotg->dev, | 394 | dev_err(hsotg->dev, |
398 | "DWC OTG HCD URB Enqueue failed adding QTD. Error status %d\n", | 395 | "DWC OTG HCD URB Enqueue failed adding QTD. Error status %d\n", |
399 | retval); | 396 | retval); |
400 | kfree(qtd); | ||
401 | return retval; | 397 | return retval; |
402 | } | 398 | } |
403 | 399 | ||
@@ -2445,6 +2441,9 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
2445 | u32 tflags = 0; | 2441 | u32 tflags = 0; |
2446 | void *buf; | 2442 | void *buf; |
2447 | unsigned long flags; | 2443 | unsigned long flags; |
2444 | struct dwc2_qh *qh; | ||
2445 | bool qh_allocated = false; | ||
2446 | struct dwc2_qtd *qtd; | ||
2448 | 2447 | ||
2449 | if (dbg_urb(urb)) { | 2448 | if (dbg_urb(urb)) { |
2450 | dev_vdbg(hsotg->dev, "DWC OTG HCD URB Enqueue\n"); | 2449 | dev_vdbg(hsotg->dev, "DWC OTG HCD URB Enqueue\n"); |
@@ -2523,15 +2522,32 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
2523 | urb->iso_frame_desc[i].length); | 2522 | urb->iso_frame_desc[i].length); |
2524 | 2523 | ||
2525 | urb->hcpriv = dwc2_urb; | 2524 | urb->hcpriv = dwc2_urb; |
2525 | qh = (struct dwc2_qh *) ep->hcpriv; | ||
2526 | /* Create QH for the endpoint if it doesn't exist */ | ||
2527 | if (!qh) { | ||
2528 | qh = dwc2_hcd_qh_create(hsotg, dwc2_urb, mem_flags); | ||
2529 | if (!qh) { | ||
2530 | retval = -ENOMEM; | ||
2531 | goto fail0; | ||
2532 | } | ||
2533 | ep->hcpriv = qh; | ||
2534 | qh_allocated = true; | ||
2535 | } | ||
2536 | |||
2537 | qtd = kzalloc(sizeof(*qtd), mem_flags); | ||
2538 | if (!qtd) { | ||
2539 | retval = -ENOMEM; | ||
2540 | goto fail1; | ||
2541 | } | ||
2526 | 2542 | ||
2527 | spin_lock_irqsave(&hsotg->lock, flags); | 2543 | spin_lock_irqsave(&hsotg->lock, flags); |
2528 | retval = usb_hcd_link_urb_to_ep(hcd, urb); | 2544 | retval = usb_hcd_link_urb_to_ep(hcd, urb); |
2529 | if (retval) | 2545 | if (retval) |
2530 | goto fail1; | 2546 | goto fail2; |
2531 | 2547 | ||
2532 | retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, &ep->hcpriv, mem_flags); | 2548 | retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, qh, qtd); |
2533 | if (retval) | 2549 | if (retval) |
2534 | goto fail2; | 2550 | goto fail3; |
2535 | 2551 | ||
2536 | if (alloc_bandwidth) { | 2552 | if (alloc_bandwidth) { |
2537 | dwc2_allocate_bus_bandwidth(hcd, | 2553 | dwc2_allocate_bus_bandwidth(hcd, |
@@ -2543,12 +2559,25 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, | |||
2543 | 2559 | ||
2544 | return 0; | 2560 | return 0; |
2545 | 2561 | ||
2546 | fail2: | 2562 | fail3: |
2547 | dwc2_urb->priv = NULL; | 2563 | dwc2_urb->priv = NULL; |
2548 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 2564 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
2549 | fail1: | 2565 | fail2: |
2550 | spin_unlock_irqrestore(&hsotg->lock, flags); | 2566 | spin_unlock_irqrestore(&hsotg->lock, flags); |
2551 | urb->hcpriv = NULL; | 2567 | urb->hcpriv = NULL; |
2568 | kfree(qtd); | ||
2569 | fail1: | ||
2570 | if (qh_allocated) { | ||
2571 | struct dwc2_qtd *qtd2, *qtd2_tmp; | ||
2572 | |||
2573 | ep->hcpriv = NULL; | ||
2574 | dwc2_hcd_qh_unlink(hsotg, qh); | ||
2575 | /* Free each QTD in the QH's QTD list */ | ||
2576 | list_for_each_entry_safe(qtd2, qtd2_tmp, &qh->qtd_list, | ||
2577 | qtd_list_entry) | ||
2578 | dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh); | ||
2579 | dwc2_hcd_qh_free(hsotg, qh); | ||
2580 | } | ||
2552 | fail0: | 2581 | fail0: |
2553 | kfree(dwc2_urb); | 2582 | kfree(dwc2_urb); |
2554 | 2583 | ||
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 7b5841c40033..fc1054965552 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h | |||
@@ -463,6 +463,9 @@ extern void dwc2_hcd_queue_transactions(struct dwc2_hsotg *hsotg, | |||
463 | /* Schedule Queue Functions */ | 463 | /* Schedule Queue Functions */ |
464 | /* Implemented in hcd_queue.c */ | 464 | /* Implemented in hcd_queue.c */ |
465 | extern void dwc2_hcd_init_usecs(struct dwc2_hsotg *hsotg); | 465 | extern void dwc2_hcd_init_usecs(struct dwc2_hsotg *hsotg); |
466 | extern struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, | ||
467 | struct dwc2_hcd_urb *urb, | ||
468 | gfp_t mem_flags); | ||
466 | extern void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); | 469 | extern void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); |
467 | extern int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); | 470 | extern int dwc2_hcd_qh_add(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); |
468 | extern void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); | 471 | extern void dwc2_hcd_qh_unlink(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh); |
@@ -471,7 +474,7 @@ extern void dwc2_hcd_qh_deactivate(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, | |||
471 | 474 | ||
472 | extern void dwc2_hcd_qtd_init(struct dwc2_qtd *qtd, struct dwc2_hcd_urb *urb); | 475 | extern void dwc2_hcd_qtd_init(struct dwc2_qtd *qtd, struct dwc2_hcd_urb *urb); |
473 | extern int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, | 476 | extern int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, |
474 | struct dwc2_qh **qh, gfp_t mem_flags); | 477 | struct dwc2_qh *qh); |
475 | 478 | ||
476 | /* Unlinks and frees a QTD */ | 479 | /* Unlinks and frees a QTD */ |
477 | static inline void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg, | 480 | static inline void dwc2_hcd_qtd_unlink_and_free(struct dwc2_hsotg *hsotg, |
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 9b5c36256627..3ad63d392e13 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c | |||
@@ -191,7 +191,7 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, | |||
191 | * | 191 | * |
192 | * Return: Pointer to the newly allocated QH, or NULL on error | 192 | * Return: Pointer to the newly allocated QH, or NULL on error |
193 | */ | 193 | */ |
194 | static struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, | 194 | struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, |
195 | struct dwc2_hcd_urb *urb, | 195 | struct dwc2_hcd_urb *urb, |
196 | gfp_t mem_flags) | 196 | gfp_t mem_flags) |
197 | { | 197 | { |
@@ -767,57 +767,32 @@ void dwc2_hcd_qtd_init(struct dwc2_qtd *qtd, struct dwc2_hcd_urb *urb) | |||
767 | * | 767 | * |
768 | * @hsotg: The DWC HCD structure | 768 | * @hsotg: The DWC HCD structure |
769 | * @qtd: The QTD to add | 769 | * @qtd: The QTD to add |
770 | * @qh: Out parameter to return queue head | 770 | * @qh: Queue head to add qtd to |
771 | * @atomic_alloc: Flag to do atomic alloc if needed | ||
772 | * | 771 | * |
773 | * Return: 0 if successful, negative error code otherwise | 772 | * Return: 0 if successful, negative error code otherwise |
774 | * | 773 | * |
775 | * Finds the correct QH to place the QTD into. If it does not find a QH, it | 774 | * If the QH to which the QTD is added is not currently scheduled, it is placed |
776 | * will create a new QH. If the QH to which the QTD is added is not currently | 775 | * into the proper schedule based on its EP type. |
777 | * scheduled, it is placed into the proper schedule based on its EP type. | ||
778 | */ | 776 | */ |
779 | int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, | 777 | int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, |
780 | struct dwc2_qh **qh, gfp_t mem_flags) | 778 | struct dwc2_qh *qh) |
781 | { | 779 | { |
782 | struct dwc2_hcd_urb *urb = qtd->urb; | ||
783 | int allocated = 0; | ||
784 | int retval; | 780 | int retval; |
785 | 781 | ||
786 | /* | 782 | if (unlikely(!qh)) { |
787 | * Get the QH which holds the QTD-list to insert to. Create QH if it | 783 | dev_err(hsotg->dev, "%s: Invalid QH\n", __func__); |
788 | * doesn't exist. | 784 | retval = -EINVAL; |
789 | */ | 785 | goto fail; |
790 | if (*qh == NULL) { | ||
791 | *qh = dwc2_hcd_qh_create(hsotg, urb, mem_flags); | ||
792 | if (*qh == NULL) | ||
793 | return -ENOMEM; | ||
794 | allocated = 1; | ||
795 | } | 786 | } |
796 | 787 | ||
797 | retval = dwc2_hcd_qh_add(hsotg, *qh); | 788 | retval = dwc2_hcd_qh_add(hsotg, qh); |
798 | if (retval) | 789 | if (retval) |
799 | goto fail; | 790 | goto fail; |
800 | 791 | ||
801 | qtd->qh = *qh; | 792 | qtd->qh = qh; |
802 | list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list); | 793 | list_add_tail(&qtd->qtd_list_entry, &qh->qtd_list); |
803 | 794 | ||
804 | return 0; | 795 | return 0; |
805 | |||
806 | fail: | 796 | fail: |
807 | if (allocated) { | ||
808 | struct dwc2_qtd *qtd2, *qtd2_tmp; | ||
809 | struct dwc2_qh *qh_tmp = *qh; | ||
810 | |||
811 | *qh = NULL; | ||
812 | dwc2_hcd_qh_unlink(hsotg, qh_tmp); | ||
813 | |||
814 | /* Free each QTD in the QH's QTD list */ | ||
815 | list_for_each_entry_safe(qtd2, qtd2_tmp, &qh_tmp->qtd_list, | ||
816 | qtd_list_entry) | ||
817 | dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh_tmp); | ||
818 | |||
819 | dwc2_hcd_qh_free(hsotg, qh_tmp); | ||
820 | } | ||
821 | |||
822 | return retval; | 797 | return retval; |
823 | } | 798 | } |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 5c110d8e293b..ff5773c66b84 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -446,10 +446,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc) | |||
446 | /* Select the HS PHY interface */ | 446 | /* Select the HS PHY interface */ |
447 | switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { | 447 | switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { |
448 | case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI: | 448 | case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI: |
449 | if (!strncmp(dwc->hsphy_interface, "utmi", 4)) { | 449 | if (dwc->hsphy_interface && |
450 | !strncmp(dwc->hsphy_interface, "utmi", 4)) { | ||
450 | reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI; | 451 | reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI; |
451 | break; | 452 | break; |
452 | } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) { | 453 | } else if (dwc->hsphy_interface && |
454 | !strncmp(dwc->hsphy_interface, "ulpi", 4)) { | ||
453 | reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI; | 455 | reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI; |
454 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | 456 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); |
455 | } else { | 457 | } else { |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 4e3447bbd097..58b4657fc721 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -1758,10 +1758,13 @@ unknown: | |||
1758 | * take such requests too, if that's ever needed: to work | 1758 | * take such requests too, if that's ever needed: to work |
1759 | * in config 0, etc. | 1759 | * in config 0, etc. |
1760 | */ | 1760 | */ |
1761 | list_for_each_entry(f, &cdev->config->functions, list) | 1761 | if (cdev->config) { |
1762 | if (f->req_match && f->req_match(f, ctrl)) | 1762 | list_for_each_entry(f, &cdev->config->functions, list) |
1763 | goto try_fun_setup; | 1763 | if (f->req_match && f->req_match(f, ctrl)) |
1764 | f = NULL; | 1764 | goto try_fun_setup; |
1765 | f = NULL; | ||
1766 | } | ||
1767 | |||
1765 | switch (ctrl->bRequestType & USB_RECIP_MASK) { | 1768 | switch (ctrl->bRequestType & USB_RECIP_MASK) { |
1766 | case USB_RECIP_INTERFACE: | 1769 | case USB_RECIP_INTERFACE: |
1767 | if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) | 1770 | if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) |
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 45b8c8b338df..6e7be91e6097 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -924,7 +924,8 @@ static ssize_t ffs_epfile_write_iter(struct kiocb *kiocb, struct iov_iter *from) | |||
924 | 924 | ||
925 | kiocb->private = p; | 925 | kiocb->private = p; |
926 | 926 | ||
927 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); | 927 | if (p->aio) |
928 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); | ||
928 | 929 | ||
929 | res = ffs_epfile_io(kiocb->ki_filp, p); | 930 | res = ffs_epfile_io(kiocb->ki_filp, p); |
930 | if (res == -EIOCBQUEUED) | 931 | if (res == -EIOCBQUEUED) |
@@ -968,7 +969,8 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to) | |||
968 | 969 | ||
969 | kiocb->private = p; | 970 | kiocb->private = p; |
970 | 971 | ||
971 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); | 972 | if (p->aio) |
973 | kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); | ||
972 | 974 | ||
973 | res = ffs_epfile_io(kiocb->ki_filp, p); | 975 | res = ffs_epfile_io(kiocb->ki_filp, p); |
974 | if (res == -EIOCBQUEUED) | 976 | if (res == -EIOCBQUEUED) |
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index d2259c663996..f936268d26c6 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c | |||
@@ -2786,7 +2786,7 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) | |||
2786 | return -EINVAL; | 2786 | return -EINVAL; |
2787 | } | 2787 | } |
2788 | 2788 | ||
2789 | curlun = kcalloc(nluns, sizeof(*curlun), GFP_KERNEL); | 2789 | curlun = kcalloc(FSG_MAX_LUNS, sizeof(*curlun), GFP_KERNEL); |
2790 | if (unlikely(!curlun)) | 2790 | if (unlikely(!curlun)) |
2791 | return -ENOMEM; | 2791 | return -ENOMEM; |
2792 | 2792 | ||
@@ -2796,8 +2796,6 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) | |||
2796 | common->luns = curlun; | 2796 | common->luns = curlun; |
2797 | common->nluns = nluns; | 2797 | common->nluns = nluns; |
2798 | 2798 | ||
2799 | pr_info("Number of LUNs=%d\n", common->nluns); | ||
2800 | |||
2801 | return 0; | 2799 | return 0; |
2802 | } | 2800 | } |
2803 | EXPORT_SYMBOL_GPL(fsg_common_set_nluns); | 2801 | EXPORT_SYMBOL_GPL(fsg_common_set_nluns); |
@@ -3563,14 +3561,26 @@ static struct usb_function *fsg_alloc(struct usb_function_instance *fi) | |||
3563 | struct fsg_opts *opts = fsg_opts_from_func_inst(fi); | 3561 | struct fsg_opts *opts = fsg_opts_from_func_inst(fi); |
3564 | struct fsg_common *common = opts->common; | 3562 | struct fsg_common *common = opts->common; |
3565 | struct fsg_dev *fsg; | 3563 | struct fsg_dev *fsg; |
3564 | unsigned nluns, i; | ||
3566 | 3565 | ||
3567 | fsg = kzalloc(sizeof(*fsg), GFP_KERNEL); | 3566 | fsg = kzalloc(sizeof(*fsg), GFP_KERNEL); |
3568 | if (unlikely(!fsg)) | 3567 | if (unlikely(!fsg)) |
3569 | return ERR_PTR(-ENOMEM); | 3568 | return ERR_PTR(-ENOMEM); |
3570 | 3569 | ||
3571 | mutex_lock(&opts->lock); | 3570 | mutex_lock(&opts->lock); |
3571 | if (!opts->refcnt) { | ||
3572 | for (nluns = i = 0; i < FSG_MAX_LUNS; ++i) | ||
3573 | if (common->luns[i]) | ||
3574 | nluns = i + 1; | ||
3575 | if (!nluns) | ||
3576 | pr_warn("No LUNS defined, continuing anyway\n"); | ||
3577 | else | ||
3578 | common->nluns = nluns; | ||
3579 | pr_info("Number of LUNs=%u\n", common->nluns); | ||
3580 | } | ||
3572 | opts->refcnt++; | 3581 | opts->refcnt++; |
3573 | mutex_unlock(&opts->lock); | 3582 | mutex_unlock(&opts->lock); |
3583 | |||
3574 | fsg->function.name = FSG_DRIVER_DESC; | 3584 | fsg->function.name = FSG_DRIVER_DESC; |
3575 | fsg->function.bind = fsg_bind; | 3585 | fsg->function.bind = fsg_bind; |
3576 | fsg->function.unbind = fsg_unbind; | 3586 | fsg->function.unbind = fsg_unbind; |
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index 6316aa5b1c49..ad50a67c1465 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c | |||
@@ -1145,7 +1145,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi) | |||
1145 | if (opts->id && !midi->id) { | 1145 | if (opts->id && !midi->id) { |
1146 | status = -ENOMEM; | 1146 | status = -ENOMEM; |
1147 | mutex_unlock(&opts->lock); | 1147 | mutex_unlock(&opts->lock); |
1148 | goto kstrdup_fail; | 1148 | goto setup_fail; |
1149 | } | 1149 | } |
1150 | midi->in_ports = opts->in_ports; | 1150 | midi->in_ports = opts->in_ports; |
1151 | midi->out_ports = opts->out_ports; | 1151 | midi->out_ports = opts->out_ports; |
@@ -1164,8 +1164,6 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi) | |||
1164 | 1164 | ||
1165 | return &midi->func; | 1165 | return &midi->func; |
1166 | 1166 | ||
1167 | kstrdup_fail: | ||
1168 | f_midi_unregister_card(midi); | ||
1169 | setup_fail: | 1167 | setup_fail: |
1170 | for (--i; i >= 0; i--) | 1168 | for (--i; i >= 0; i--) |
1171 | kfree(midi->in_port[i]); | 1169 | kfree(midi->in_port[i]); |
diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index e547ea7f56b1..1137e3384218 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c | |||
@@ -1171,7 +1171,7 @@ static int fotg210_udc_probe(struct platform_device *pdev) | |||
1171 | udc_name, fotg210); | 1171 | udc_name, fotg210); |
1172 | if (ret < 0) { | 1172 | if (ret < 0) { |
1173 | pr_err("request_irq error (%d)\n", ret); | 1173 | pr_err("request_irq error (%d)\n", ret); |
1174 | goto err_irq; | 1174 | goto err_req; |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | ret = usb_add_gadget_udc(&pdev->dev, &fotg210->gadget); | 1177 | ret = usb_add_gadget_udc(&pdev->dev, &fotg210->gadget); |
@@ -1183,7 +1183,6 @@ static int fotg210_udc_probe(struct platform_device *pdev) | |||
1183 | return 0; | 1183 | return 0; |
1184 | 1184 | ||
1185 | err_add_udc: | 1185 | err_add_udc: |
1186 | err_irq: | ||
1187 | free_irq(ires->start, fotg210); | 1186 | free_irq(ires->start, fotg210); |
1188 | 1187 | ||
1189 | err_req: | 1188 | err_req: |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 30842bc195f5..92d5f718659b 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -275,9 +275,7 @@ static int musb_has_gadget(struct musb *musb) | |||
275 | #ifdef CONFIG_USB_MUSB_HOST | 275 | #ifdef CONFIG_USB_MUSB_HOST |
276 | return 1; | 276 | return 1; |
277 | #else | 277 | #else |
278 | if (musb->port_mode == MUSB_PORT_MODE_HOST) | 278 | return musb->port_mode == MUSB_PORT_MODE_HOST; |
279 | return 1; | ||
280 | return musb->g.dev.driver != NULL; | ||
281 | #endif | 279 | #endif |
282 | } | 280 | } |
283 | 281 | ||
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 8f7cb068d29b..3fcc0483a081 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c | |||
@@ -217,6 +217,9 @@ static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy) | |||
217 | { | 217 | { |
218 | unsigned int vbus_value; | 218 | unsigned int vbus_value; |
219 | 219 | ||
220 | if (!mxs_phy->regmap_anatop) | ||
221 | return false; | ||
222 | |||
220 | if (mxs_phy->port_id == 0) | 223 | if (mxs_phy->port_id == 0) |
221 | regmap_read(mxs_phy->regmap_anatop, | 224 | regmap_read(mxs_phy->regmap_anatop, |
222 | ANADIG_USB1_VBUS_DET_STAT, | 225 | ANADIG_USB1_VBUS_DET_STAT, |