/* Return 0 if no error, -EINVAL or -ECONNRESET otherwise  */
static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
/* Return 0 if no error, -EINVAL or -ECONNRESET otherwise  */
static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{
	struct pxa_ep		*ep;
	struct udc_usb_ep	*udc_usb_ep;
	struct pxa27x_request	*req;
	unsigned long		flags;
	int			rc = -EINVAL;
	if (!_ep)
		return rc;
	udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep);
	ep = udc_usb_ep->pxa_ep;
	if (!ep || is_ep0(ep))
		return rc;
	spin_lock_irqsave(&ep->lock, flags);
	list_for_each_entry(req, &ep->queue, queue) {
		if (&req->req == _req) {
			req_done(ep, req, -ECONNRESET);
			rc = 0;
			break;
		}
	}
	spin_unlock_irqrestore(&ep->lock, flags);
	return rc;
}