net2280_queue (struct usb_ep *_ep, struct usb_request *_req, int gfp_flags)
net2280_queue (struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
net2280_queue (struct usb_ep *_ep, struct usb_request *_req, int gfp_flags){	struct net2280_request	*req;	struct net2280_ep	*ep;	struct net2280		*dev;	unsigned long		flags;	/* we always require a cpu-view buffer, so that we can	 * always use pio (as fallback or whatever).	 */	req = container_of (_req, struct net2280_request, req);	if (!_req || !_req->complete || !_req->buf			|| !list_empty (&req->queue))		return -EINVAL;	if (_req->length > (~0 & DMA_BYTE_COUNT_MASK))		return -EDOM;	ep = container_of (_ep, struct net2280_ep, ep);	if (!_ep || (!ep->desc && ep->num != 0))		return -EINVAL;	dev = ep->dev;	if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)		return -ESHUTDOWN;	/* FIXME implement PIO fallback for ZLPs with DMA */	if (ep->dma && _req->length == 0)		return -EOPNOTSUPP;	/* set up dma mapping in case the caller didn't */	if (ep->dma && _req->dma == DMA_ADDR_INVALID) {		_req->dma = pci_map_single (dev->pdev, _req->buf, _req->length,			ep->is_in ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);		req->mapped = 1;	}#if 0	VDEBUG (dev, "%s queue req %p, len %d buf %p\n",			_ep->name, _req, _req->length, _req->buf);#endif	spin_lock_irqsave (&dev->lock, flags);	_req->status = -EINPROGRESS;	_req->actual = 0;	/* kickstart this i/o queue? */	if (list_empty (&ep->queue) && !ep->stopped) {		/* use DMA if the endpoint supports it, else pio */		if (ep->dma)			start_dma (ep, req);		else {			/* maybe there's no control data, just status ack */			if (ep->num == 0 && _req->length == 0) {				allow_status (ep);				done (ep, req, 0);				VDEBUG (dev, "%s status ack\n", ep->ep.name);				goto done;			}			/* PIO ... stuff the fifo, or unblock it.  */			if (ep->is_in)				write_fifo (ep, _req);			else if (list_empty (&ep->queue)) {				u32	s;				/* OUT FIFO might have packet(s) buffered */				s = readl (&ep->regs->ep_stat);				if ((s & (1 << FIFO_EMPTY)) == 0) {					/* note:  _req->short_not_ok is					 * ignored here since PIO _always_					 * stops queue advance here, and					 * _req->status doesn't change for					 * short reads (only _req->actual)					 */					if (read_fifo (ep, req)) {						done (ep, req, 0);						if (ep->num == 0)							allow_status (ep);						/* don't queue it */						req = NULL;					} else						s = readl (&ep->regs->ep_stat);				}				/* don't NAK, let the fifo fill */				if (req && (s & (1 << NAK_OUT_PACKETS)))					writel ((1 << CLEAR_NAK_OUT_PACKETS),							&ep->regs->ep_rsp);			}		}	} else if (ep->dma) {		int	valid = 1;		if (ep->is_in) {			int	expect;			/* preventing magic zlps is per-engine state, not			 * per-transfer; irq logic must recover hiccups.			 */			expect = likely (req->req.zero				|| (req->req.length % ep->ep.maxpacket) != 0);			if (expect != ep->in_fifo_validate)				valid = 0;		}		queue_dma (ep, req, valid);	} /* else the irq handler advances the queue. */	if (req)		list_add_tail (&req->queue, &ep->queue);done:	spin_unlock_irqrestore (&dev->lock, flags);	/* pci writes may still be posted */	return 0;}