usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable()
[pandora-kernel.git] / drivers / usb / renesas_usbhs / mod_gadget.c
index aa0d183..eb46562 100644 (file)
@@ -472,6 +472,9 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
        struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
        struct usbhs_pipe *pipe;
        int ret = -EIO;
+       unsigned long flags;
+
+       usbhs_lock(priv, flags);
 
        /*
         * if it already have pipe,
@@ -480,7 +483,8 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
        if (uep->pipe) {
                usbhs_pipe_clear(uep->pipe);
                usbhs_pipe_sequence_data0(uep->pipe);
-               return 0;
+               ret = 0;
+               goto usbhsg_ep_enable_end;
        }
 
        pipe = usbhs_pipe_malloc(priv,
@@ -508,12 +512,19 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
                ret = 0;
        }
 
+usbhsg_ep_enable_end:
+       usbhs_unlock(priv, flags);
+
        return ret;
 }
 
 static int usbhsg_ep_disable(struct usb_ep *ep)
 {
        struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
+       struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
+
+       if (!pipe)
+               return -EINVAL;
 
        return usbhsg_pipe_disable(uep);
 }