Merge remote-tracking branch 'usb-chipidea-next/ci-for-usb-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Sep 2016 02:45:57 +0000 (12:45 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Sep 2016 02:45:57 +0000 (12:45 +1000)
1  2 
drivers/usb/chipidea/udc.c

index b93356834bb5660bb451f712c7ef6f13018bc5d3,0f692fcda638bea1d9bd4a1f159b55efea30f42c..c1eea62ab998c607aa05ccd0fcc3825f7a93f01b
@@@ -59,7 -59,7 +59,7 @@@ ctrl_endpt_in_desc = 
   */
  static inline int hw_ep_bit(int num, int dir)
  {
-       return num + (dir ? 16 : 0);
+       return num + ((dir == TX) ? 16 : 0);
  }
  
  static inline int ep_to_bit(struct ci_hdrc *ci, int n)
@@@ -121,9 -121,8 +121,8 @@@ static int hw_ep_flush(struct ci_hdrc *
   */
  static int hw_ep_disable(struct ci_hdrc *ci, int num, int dir)
  {
-       hw_ep_flush(ci, num, dir);
        hw_write(ci, OP_ENDPTCTRL + num,
-                dir ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0);
+                (dir == TX) ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0);
        return 0;
  }
  
@@@ -139,7 -138,7 +138,7 @@@ static int hw_ep_enable(struct ci_hdrc 
  {
        u32 mask, data;
  
-       if (dir) {
+       if (dir == TX) {
                mask  = ENDPTCTRL_TXT;  /* type    */
                data  = type << __ffs(mask);
  
   */
  static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir)
  {
-       u32 mask = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
+       u32 mask = (dir == TX) ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
  
        return hw_read(ci, OP_ENDPTCTRL + num, mask) ? 1 : 0;
  }
@@@ -188,6 -187,9 +187,9 @@@ static int hw_ep_prime(struct ci_hdrc *
  {
        int n = hw_ep_bit(num, dir);
  
+       /* Synchronize before ep prime */
+       wmb();
        if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num)))
                return -EAGAIN;
  
@@@ -218,8 -220,8 +220,8 @@@ static int hw_ep_set_halt(struct ci_hdr
  
        do {
                enum ci_hw_regs reg = OP_ENDPTCTRL + num;
-               u32 mask_xs = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
-               u32 mask_xr = dir ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
+               u32 mask_xs = (dir == TX) ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
+               u32 mask_xr = (dir == TX) ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
  
                /* data toggle - reserved for EP0 but it's in ESS */
                hw_write(ci, reg, mask_xs|mask_xr,
@@@ -506,8 -508,6 +508,6 @@@ static int _hardware_enqueue(struct ci_
                hwep->qh.ptr->cap |= mul << __ffs(QH_MULT);
        }
  
-       wmb();   /* synchronize before ep prime */
        ret = hw_ep_prime(ci, hwep->num, hwep->dir,
                           hwep->type == USB_ENDPOINT_XFER_CONTROL);
  done:
@@@ -534,9 -534,6 +534,6 @@@ static int reprime_dtd(struct ci_hdrc *
        hwep->qh.ptr->td.token &=
                cpu_to_le32(~(TD_STATUS_HALTED | TD_STATUS_ACTIVE));
  
-       /* Synchronize before ep prime */
-       wmb();
        return hw_ep_prime(ci, hwep->num, hwep->dir,
                                hwep->type == USB_ENDPOINT_XFER_CONTROL);
  }
@@@ -590,7 -587,7 +587,7 @@@ static int _hardware_dequeue(struct ci_
                }
  
                if (remaining_length) {
-                       if (hwep->dir) {
+                       if (hwep->dir == TX) {
                                hwreq->req.status = -EPROTO;
                                break;
                        }
@@@ -949,15 -946,6 +946,15 @@@ static int isr_setup_status_phase(struc
        int retval;
        struct ci_hw_ep *hwep;
  
 +      /*
 +       * Unexpected USB controller behavior, caused by bad signal integrity
 +       * or ground reference problems, can lead to isr_setup_status_phase
 +       * being called with ci->status equal to NULL.
 +       * If this situation occurs, you should review your USB hardware design.
 +       */
 +      if (WARN_ON_ONCE(!ci->status))
 +              return -EPIPE;
 +
        hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in;
        ci->status->context = ci;
        ci->status->complete = isr_setup_status_complete;
@@@ -1051,9 -1039,9 +1048,9 @@@ __acquires(ci->lock
                        if (req.wLength != 0)
                                break;
                        num  = le16_to_cpu(req.wIndex);
-                       dir = num & USB_ENDPOINT_DIR_MASK;
+                       dir = (num & USB_ENDPOINT_DIR_MASK) ? TX : RX;
                        num &= USB_ENDPOINT_NUMBER_MASK;
-                       if (dir) /* TX */
+                       if (dir == TX)
                                num += ci->hw_ep_max / 2;
                        if (!ci->ci_hw_ep[num].wedge) {
                                spin_unlock(&ci->lock);
                        if (req.wLength != 0)
                                break;
                        num  = le16_to_cpu(req.wIndex);
-                       dir = num & USB_ENDPOINT_DIR_MASK;
+                       dir = (num & USB_ENDPOINT_DIR_MASK) ? TX : RX;
                        num &= USB_ENDPOINT_NUMBER_MASK;
-                       if (dir) /* TX */
+                       if (dir == TX)
                                num += ci->hw_ep_max / 2;
  
                        spin_unlock(&ci->lock);
This page took 0.031779 seconds and 5 git commands to generate.