const struct usb_endpoint_descriptor *desc)
 {
        struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep);
-       struct lpc32xx_udc *udc = ep->udc;
+       struct lpc32xx_udc *udc;
        u16 maxpacket;
        u32 tmp;
        unsigned long flags;
 
        /* Verify EP data */
        if ((!_ep) || (!ep) || (!desc) ||
-           (desc->bDescriptorType != USB_DT_ENDPOINT)) {
-               dev_dbg(udc->dev, "bad ep or descriptor\n");
+           (desc->bDescriptorType != USB_DT_ENDPOINT))
                return -EINVAL;
-       }
+
+       udc = ep->udc;
        maxpacket = usb_endpoint_maxp(desc);
        if ((maxpacket == 0) || (maxpacket > ep->maxpacket)) {
                dev_dbg(udc->dev, "bad ep descriptor's packet size\n");
 static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value)
 {
        struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep);
-       struct lpc32xx_udc *udc = ep->udc;
+       struct lpc32xx_udc *udc;
        unsigned long flags;
 
        if ((!ep) || (ep->hwep_num <= 1))
        if (ep->is_in)
                return -EAGAIN;
 
+       udc = ep->udc;
        spin_lock_irqsave(&udc->lock, flags);
 
        if (value == 1) {