int mem_flags) 
unsigned mem_flags) 
static int isp116x_urb_enqueue(struct usb_hcd *hcd,			       struct usb_host_endpoint *hep, struct urb *urb,			       int mem_flags){	struct isp116x *isp116x = hcd_to_isp116x(hcd);	struct usb_device *udev = urb->dev;	unsigned int pipe = urb->pipe;	int is_out = !usb_pipein(pipe);	int type = usb_pipetype(pipe);	int epnum = usb_pipeendpoint(pipe);	struct isp116x_ep *ep = NULL;	unsigned long flags;	int i;	int ret = 0;	urb_dbg(urb, "Enqueue");	if (type == PIPE_ISOCHRONOUS) {		ERR("Isochronous transfers not supported\n");		urb_dbg(urb, "Refused to enqueue");		return -ENXIO;	}	/* avoid all allocations within spinlocks: request or endpoint */	if (!hep->hcpriv) {		ep = kcalloc(1, sizeof *ep, (__force unsigned)mem_flags);		if (!ep)			return -ENOMEM;	}	spin_lock_irqsave(&isp116x->lock, flags);	if (!HC_IS_RUNNING(hcd->state)) {		ret = -ENODEV;		goto fail;	}	if (hep->hcpriv)		ep = hep->hcpriv;	else {		INIT_LIST_HEAD(&ep->schedule);		ep->udev = usb_get_dev(udev);		ep->epnum = epnum;		ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out);		usb_settoggle(udev, epnum, is_out, 0);		if (type == PIPE_CONTROL) {			ep->nextpid = USB_PID_SETUP;		} else if (is_out) {			ep->nextpid = USB_PID_OUT;		} else {			ep->nextpid = USB_PID_IN;		}		if (urb->interval) {			/*			   With INT URBs submitted, the driver works with SOF			   interrupt enabled and ATL interrupt disabled. After			   the PTDs are written to fifo ram, the chip starts			   fifo processing and usb transfers after the next			   SOF and continues until the transfers are finished			   (succeeded or failed) or the frame ends. Therefore,			   the transfers occur only in every second frame,			   while fifo reading/writing and data processing			   occur in every other second frame. */			if (urb->interval < 2)				urb->interval = 2;			if (urb->interval > 2 * PERIODIC_SIZE)				urb->interval = 2 * PERIODIC_SIZE;			ep->period = urb->interval >> 1;			ep->branch = PERIODIC_SIZE;			ep->load = usb_calc_bus_time(udev->speed,						     !is_out,						     (type == PIPE_ISOCHRONOUS),						     usb_maxpacket(udev, pipe,								   is_out)) /			    1000;		}		hep->hcpriv = ep;		ep->hep = hep;	}	/* maybe put endpoint into schedule */	switch (type) {	case PIPE_CONTROL:	case PIPE_BULK:		if (list_empty(&ep->schedule))			list_add_tail(&ep->schedule, &isp116x->async);		break;	case PIPE_INTERRUPT:		urb->interval = ep->period;		ep->length = min((int)ep->maxpacket,				 urb->transfer_buffer_length);		/* urb submitted for already existing endpoint */		if (ep->branch < PERIODIC_SIZE)			break;		ret = ep->branch = balance(isp116x, ep->period, ep->load);		if (ret < 0)			goto fail;		ret = 0;		urb->start_frame = (isp116x->fmindex & (PERIODIC_SIZE - 1))		    + ep->branch;		/* sort each schedule branch by period (slow before fast)		   to share the faster parts of the tree without needing		   dummy/placeholder nodes */		DBG("schedule qh%d/%p branch %d\n", ep->period, ep, ep->branch);		for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) {			struct isp116x_ep **prev = &isp116x->periodic[i];			struct isp116x_ep *here = *prev;			while (here && ep != here) {				if (ep->period > here->period)					break;				prev = &here->next;				here = *prev;			}			if (ep != here) {				ep->next = here;				*prev = ep;			}			isp116x->load[i] += ep->load;		}		hcd->self.bandwidth_allocated += ep->load / ep->period;		/* switch over to SOFint */		if (!isp116x->periodic_count++) {			isp116x->irqenb &= ~HCuPINT_ATL;			isp116x->irqenb |= HCuPINT_SOF;			isp116x_write_reg16(isp116x, HCuPINTENB,					    isp116x->irqenb);		}	}	/* in case of unlink-during-submit */	spin_lock(&urb->lock);	if (urb->status != -EINPROGRESS) {		spin_unlock(&urb->lock);		finish_request(isp116x, ep, urb, NULL);		ret = 0;		goto fail;	}	urb->hcpriv = hep;	spin_unlock(&urb->lock);	start_atl_transfers(isp116x);      fail:	spin_unlock_irqrestore(&isp116x->lock, flags);	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/5db539e49fc7471e23bf3c94ca304f008cb7b7f3/isp116x-hcd.c/buggy/drivers/usb/host/isp116x-hcd.c