forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/usb/gadget/udc/fsl_udc_core.c
....@@ -53,7 +53,6 @@
5353 #define DMA_ADDR_INVALID (~(dma_addr_t)0)
5454
5555 static const char driver_name[] = "fsl-usb2-udc";
56
-static const char driver_desc[] = DRIVER_DESC;
5756
5857 static struct usb_dr_device __iomem *dr_regs;
5958
....@@ -251,7 +250,7 @@
251250 break;
252251 case FSL_USB2_PHY_UTMI_WIDE:
253252 portctrl |= PORTSCX_PTW_16BIT;
254
- /* fall through */
253
+ fallthrough;
255254 case FSL_USB2_PHY_UTMI:
256255 case FSL_USB2_PHY_UTMI_DUAL:
257256 if (udc->pdata->have_sysif_regs) {
....@@ -1052,9 +1051,10 @@
10521051 u32 bitmask;
10531052 struct ep_queue_head *qh;
10541053
1055
- ep = container_of(_ep, struct fsl_ep, ep);
1056
- if (!_ep || (!ep->ep.desc && ep_index(ep) != 0))
1054
+ if (!_ep || !_ep->desc || !(_ep->desc->bEndpointAddress&0xF))
10571055 return -ENODEV;
1056
+
1057
+ ep = container_of(_ep, struct fsl_ep, ep);
10581058
10591059 udc = (struct fsl_udc *)ep->udc;
10601060
....@@ -1208,7 +1208,7 @@
12081208 }
12091209
12101210 /* Change Data+ pullup status
1211
- * this func is used by usb_gadget_connect/disconnet
1211
+ * this func is used by usb_gadget_connect/disconnect
12121212 */
12131213 static int fsl_pullup(struct usb_gadget *gadget, int is_on)
12141214 {
....@@ -1595,14 +1595,13 @@
15951595 struct fsl_req *curr_req)
15961596 {
15971597 struct ep_td_struct *curr_td;
1598
- int td_complete, actual, remaining_length, j, tmp;
1598
+ int actual, remaining_length, j, tmp;
15991599 int status = 0;
16001600 int errors = 0;
16011601 struct ep_queue_head *curr_qh = &udc->ep_qh[pipe];
16021602 int direction = pipe % 2;
16031603
16041604 curr_td = curr_req->head;
1605
- td_complete = 0;
16061605 actual = curr_req->req.length;
16071606
16081607 for (j = 0; j < curr_req->dtd_count; j++) {
....@@ -1647,11 +1646,9 @@
16471646 status = -EPROTO;
16481647 break;
16491648 } else {
1650
- td_complete++;
16511649 break;
16521650 }
16531651 } else {
1654
- td_complete++;
16551652 VDBG("dTD transmitted successful");
16561653 }
16571654
....@@ -2064,7 +2061,7 @@
20642061 "Sleep Enable: %d SOF Received Enable: %d "
20652062 "Reset Enable: %d\n"
20662063 "System Error Enable: %d "
2067
- "Port Change Dectected Enable: %d\n"
2064
+ "Port Change Detected Enable: %d\n"
20682065 "USB Error Intr Enable: %d USB Intr Enable: %d\n\n",
20692066 (tmp_reg & USB_INTR_DEVICE_SUSPEND) ? 1 : 0,
20702067 (tmp_reg & USB_INTR_SOF_EN) ? 1 : 0,
....@@ -2234,8 +2231,10 @@
22342231 Internal structure setup functions
22352232 *******************************************************************/
22362233 /*------------------------------------------------------------------
2237
- * init resource for globle controller
2238
- * Return the udc handle on success or NULL on failure
2234
+ * init resource for global controller called by fsl_udc_probe()
2235
+ * On success the udc handle is initialized, on failure it is
2236
+ * unchanged (reset).
2237
+ * Return 0 on success and -1 on allocation failure
22392238 ------------------------------------------------------------------*/
22402239 static int struct_udc_setup(struct fsl_udc *udc,
22412240 struct platform_device *pdev)
....@@ -2440,11 +2439,12 @@
24402439 /* DEN is bidirectional ep number, max_ep doubles the number */
24412440 udc_controller->max_ep = (dccparams & DCCPARAMS_DEN_MASK) * 2;
24422441
2443
- udc_controller->irq = platform_get_irq(pdev, 0);
2444
- if (!udc_controller->irq) {
2445
- ret = -ENODEV;
2442
+ ret = platform_get_irq(pdev, 0);
2443
+ if (ret <= 0) {
2444
+ ret = ret ? : -ENODEV;
24462445 goto err_iounmap;
24472446 }
2447
+ udc_controller->irq = ret;
24482448
24492449 ret = request_irq(udc_controller->irq, fsl_udc_irq, IRQF_SHARED,
24502450 driver_name, udc_controller);