usb: coverity fix [1/1]
authorYue Wang <yue.wang@amlogic.com>
Thu, 12 Sep 2019 05:39:48 +0000 (13:39 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 16 Sep 2019 06:17:05 +0000 (23:17 -0700)
PD#SWPL-14009

Problem:
Coverity defect cleanup - usb.

Solution:
Coverity defect cleanup - usb.

Verify:
sm1

Change-Id: Ib194a82e54f819e4ab59eab944b446683c894f15
Signed-off-by: Yue Wang <yue.wang@amlogic.com>
drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.c
drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil_intr.c
drivers/amlogic/usb/dwc_otg/310/dwc_otg_hcd_ddma.c

index f0e4e5c..c01c78c 100644 (file)
@@ -789,7 +789,7 @@ int dwc_otg_save_global_regs(dwc_otg_core_if_t *core_if)
        gr->pcgcctl_local = DWC_READ_REG32(core_if->pcgcctl);
        gr->gdfifocfg_local =
            DWC_READ_REG32(&core_if->core_global_regs->gdfifocfg);
-       for (i = 0; i < MAX_EPS_CHANNELS; i++) {
+       for (i = 0; i < MAX_EPS_CHANNELS - 1; i++) {
                gr->dtxfsiz_local[i] =
                    DWC_READ_REG32(&(core_if->core_global_regs->dtxfsiz[i]));
        }
@@ -948,7 +948,7 @@ int dwc_otg_restore_global_regs(dwc_otg_core_if_t *core_if)
                        gr->hptxfsiz_local);
        DWC_WRITE_REG32(&core_if->core_global_regs->gdfifocfg,
                        gr->gdfifocfg_local);
-       for (i = 0; i < MAX_EPS_CHANNELS; i++)
+       for (i = 0; i < MAX_EPS_CHANNELS - 1; i++)
                DWC_WRITE_REG32(&core_if->core_global_regs->dtxfsiz[i],
                                gr->dtxfsiz_local[i]);
 
@@ -1070,7 +1070,7 @@ int restore_essential_regs(dwc_otg_core_if_t *core_if, int rmode, int is_host)
                dwc_udelay(10);
 
                /* Load restore values for [31:14] bits and set EssRegRestored bit */
-               pcgcctl.d32 = ((gr->pcgcctl_local | 0xffffc000) & 0xffffc000);
+               pcgcctl.d32 = 0xffffc000;
                pcgcctl.b.ess_reg_restored = 1;
                if (rmode)
                        pcgcctl.b.restoremode = 1;
index 760c793..68f55ef 100644 (file)
@@ -397,7 +397,8 @@ void w_conn_id_status_change(void *p)
                        if (++count > 10000)
                                break;
                }
-               DWC_ASSERT(++count < 10000,
+               ++count;
+               DWC_ASSERT(count < 10000,
                           "Connection id status change timed out");
                core_if->op_state = B_PERIPHERAL;
                DWC_PRINTF("DEVICE mode\n");
@@ -418,7 +419,8 @@ host:
                        if (++count > 10000)
                                break;
                }
-               DWC_ASSERT(++count < 10000,
+               ++count;
+               DWC_ASSERT(count < 10000,
                           "Connection id status change timed out");
                core_if->op_state = A_HOST;
                DWC_PRINTF("HOST mode\n");
index 75269e4..378fdbb 100644 (file)
@@ -1012,10 +1012,8 @@ stop_scan:
                 */
                if (halt_status == DWC_OTG_HC_XFER_STALL)
                        qh->data_toggle = DWC_OTG_HC_PID_DATA0;
-               else {
-                       if (qtd)
-                               dwc_otg_hcd_save_data_toggle(hc, hc_regs, qtd);
-               }
+               else
+                       dwc_otg_hcd_save_data_toggle(hc, hc_regs, qtd);
        }
 
        if (halt_status == DWC_OTG_HC_XFER_COMPLETE) {