usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable()
[pandora-kernel.git] / drivers / usb / renesas_usbhs / mod_gadget.c
index 7f4e803..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);
 }
@@ -816,6 +827,11 @@ static int usbhsg_stop(struct usbhs_priv *priv)
        return usbhsg_try_stop(priv, USBHSG_STATUS_STARTED);
 }
 
+static void usbhs_mod_gadget_release(struct device *pdev)
+{
+       /* do nothing */
+}
+
 int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
 {
        struct usbhsg_gpriv *gpriv;
@@ -864,6 +880,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
         */
        dev_set_name(&gpriv->gadget.dev, "gadget");
        gpriv->gadget.dev.parent        = dev;
+       gpriv->gadget.dev.release       = usbhs_mod_gadget_release;
        gpriv->gadget.name              = "renesas_usbhs_udc";
        gpriv->gadget.ops               = &usbhsg_gadget_ops;
        gpriv->gadget.is_dualspeed      = 1;