ep = kcalloc(1, sizeof *ep, mem_flags); 
ep = kzalloc(sizeof *ep, mem_flags); 
static int sl811h_urb_enqueue(	struct usb_hcd		*hcd,	struct usb_host_endpoint *hep,	struct urb		*urb,	unsigned		mem_flags) {	struct sl811		*sl811 = hcd_to_sl811(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 sl811h_ep	*ep = NULL;	unsigned long		flags;	int			i;	int			retval = 0;#ifdef	DISABLE_ISO	if (type == PIPE_ISOCHRONOUS)		return -ENOSPC;#endif	/* avoid all allocations within spinlocks */	if (!hep->hcpriv)		ep = kcalloc(1, sizeof *ep, mem_flags);	spin_lock_irqsave(&sl811->lock, flags);	/* don't submit to a dead or disabled port */	if (!(sl811->port1 & (1 << USB_PORT_FEAT_ENABLE))			|| !HC_IS_RUNNING(hcd->state)) {		retval = -ENODEV;		goto fail;	}	if (hep->hcpriv) {		kfree(ep);		ep = hep->hcpriv;	} else if (!ep) {		retval = -ENOMEM;		goto fail;	} else {		INIT_LIST_HEAD(&ep->schedule);		ep->udev = usb_get_dev(udev);		ep->epnum = epnum;		ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out);		ep->defctrl = SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENABLE;		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 (ep->maxpacket > H_MAXPACKET) {			/* iso packets up to 240 bytes could work... */			DBG("dev %d ep%d maxpacket %d\n",				udev->devnum, epnum, ep->maxpacket);			retval = -EINVAL;			goto fail;		}		if (udev->speed == USB_SPEED_LOW) {			/* send preamble for external hub? */			if (!(sl811->ctrl1 & SL11H_CTL1MASK_LSPD))				ep->defctrl |= SL11H_HCTLMASK_PREAMBLE;		}		switch (type) {		case PIPE_ISOCHRONOUS:		case PIPE_INTERRUPT:			if (urb->interval > PERIODIC_SIZE)				urb->interval = PERIODIC_SIZE;			ep->period = urb->interval;			ep->branch = PERIODIC_SIZE;			if (type == PIPE_ISOCHRONOUS)				ep->defctrl |= SL11H_HCTLMASK_ISOCH;			ep->load = usb_calc_bus_time(udev->speed, !is_out,				(type == PIPE_ISOCHRONOUS),				usb_maxpacket(udev, pipe, is_out))					/ 1000;			break;		}		ep->hep = hep;		hep->hcpriv = ep;	}	/* maybe put endpoint into schedule */	switch (type) {	case PIPE_CONTROL:	case PIPE_BULK:		if (list_empty(&ep->schedule))			list_add_tail(&ep->schedule, &sl811->async);		break;	case PIPE_ISOCHRONOUS:	case PIPE_INTERRUPT:		urb->interval = ep->period;		if (ep->branch < PERIODIC_SIZE)			break;		retval = balance(sl811, ep->period, ep->load);		if (retval < 0)			goto fail;		ep->branch = retval;		retval = 0;		urb->start_frame = (sl811->frame & (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 sl811h_ep	**prev = &sl811->periodic[i];			struct sl811h_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;			}			sl811->load[i] += ep->load;		}		sl811->periodic_count++;		hcd->self.bandwidth_allocated += ep->load / ep->period;		sofirq_on(sl811);	}	/* in case of unlink-during-submit */	spin_lock(&urb->lock);	if (urb->status != -EINPROGRESS) {		spin_unlock(&urb->lock);		finish_request(sl811, ep, urb, NULL, 0);		retval = 0;		goto fail;	}	urb->hcpriv = hep;	spin_unlock(&urb->lock);	start_transfer(sl811);	sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);fail:	spin_unlock_irqrestore(&sl811->lock, flags);	return retval;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/7b842b6e3704f4b9606ff8a4ffe03579d9addf5e/sl811-hcd.c/clean/drivers/usb/host/sl811-hcd.c