set_fifo_bytecount (ep, u.r.wLength); writel (status, &dev->epregs [0].ep_data); 
set_fifo_bytecount (ep, w_length); writel ((__force u32)status, &dev->epregs [0].ep_data); 
static void handle_stat0_irqs (struct net2280 *dev, u32 stat){	struct net2280_ep	*ep;	u32			num, scratch;	/* most of these don't need individual acks */	stat &= ~(1 << INTA_ASSERTED);	if (!stat)		return;	// DEBUG (dev, "irqstat0 %04x\n", stat);	/* starting a control request? */	if (unlikely (stat & (1 << SETUP_PACKET_INTERRUPT))) {		union {			u32			raw [2];			struct usb_ctrlrequest	r;		} u;		int				tmp = 0;		struct net2280_request		*req;		if (dev->gadget.speed == USB_SPEED_UNKNOWN) {			if (readl (&dev->usb->usbstat) & (1 << HIGH_SPEED))				dev->gadget.speed = USB_SPEED_HIGH;			else				dev->gadget.speed = USB_SPEED_FULL;			net2280_led_speed (dev, dev->gadget.speed);			DEBUG (dev, "%s speed\n",				(dev->gadget.speed == USB_SPEED_HIGH)					? "high" : "full");		}		ep = &dev->ep [0];		ep->irqs++;		/* make sure any leftover request state is cleared */		stat &= ~(1 << ENDPOINT_0_INTERRUPT);		while (!list_empty (&ep->queue)) {			req = list_entry (ep->queue.next,					struct net2280_request, queue);			done (ep, req, (req->req.actual == req->req.length)						? 0 : -EPROTO);		}		ep->stopped = 0;		dev->protocol_stall = 0;		writel (  (1 << TIMEOUT)			| (1 << USB_STALL_SENT)			| (1 << USB_IN_NAK_SENT)			| (1 << USB_IN_ACK_RCVD)			| (1 << USB_OUT_PING_NAK_SENT)			| (1 << USB_OUT_ACK_SENT)			| (1 << FIFO_OVERFLOW)			| (1 << FIFO_UNDERFLOW)			| (1 << SHORT_PACKET_OUT_DONE_INTERRUPT)			| (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT)			| (1 << DATA_PACKET_RECEIVED_INTERRUPT)			| (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)			| (1 << DATA_OUT_PING_TOKEN_INTERRUPT)			| (1 << DATA_IN_TOKEN_INTERRUPT)			, &ep->regs->ep_stat);		u.raw [0] = readl (&dev->usb->setup0123);		u.raw [1] = readl (&dev->usb->setup4567);				cpu_to_le32s (&u.raw [0]);		cpu_to_le32s (&u.raw [1]);		le16_to_cpus (&u.r.wValue);		le16_to_cpus (&u.r.wIndex);		le16_to_cpus (&u.r.wLength);		/* ack the irq */		writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0);		stat ^= (1 << SETUP_PACKET_INTERRUPT);		/* watch control traffic at the token level, and force		 * synchronization before letting the status stage happen.		 * FIXME ignore tokens we'll NAK, until driver responds.		 * that'll mean a lot less irqs for some drivers.		 */		ep->is_in = (u.r.bRequestType & USB_DIR_IN) != 0;		if (ep->is_in) {			scratch = (1 << DATA_PACKET_TRANSMITTED_INTERRUPT)				| (1 << DATA_OUT_PING_TOKEN_INTERRUPT)				| (1 << DATA_IN_TOKEN_INTERRUPT);			stop_out_naking (ep);		} else			scratch = (1 << DATA_PACKET_RECEIVED_INTERRUPT)				| (1 << DATA_OUT_PING_TOKEN_INTERRUPT)				| (1 << DATA_IN_TOKEN_INTERRUPT);		writel (scratch, &dev->epregs [0].ep_irqenb);		/* we made the hardware handle most lowlevel requests;		 * everything else goes uplevel to the gadget code.		 */		switch (u.r.bRequest) {		case USB_REQ_GET_STATUS: {			struct net2280_ep	*e;			u16			status;			/* hw handles device and interface status */			if (u.r.bRequestType != (USB_DIR_IN|USB_RECIP_ENDPOINT))				goto delegate;			if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0					|| u.r.wLength > 2)				goto do_stall;			if (readl (&e->regs->ep_rsp)					& (1 << SET_ENDPOINT_HALT))				status = __constant_cpu_to_le16 (1);			else				status = __constant_cpu_to_le16 (0);			/* don't bother with a request object! */			writel (0, &dev->epregs [0].ep_irqenb);			set_fifo_bytecount (ep, u.r.wLength);			writel (status, &dev->epregs [0].ep_data);			allow_status (ep);			VDEBUG (dev, "%s stat %02x\n", ep->ep.name, status);			goto next_endpoints;			}			break;		case USB_REQ_CLEAR_FEATURE: {			struct net2280_ep	*e;			/* hw handles device features */			if (u.r.bRequestType != USB_RECIP_ENDPOINT)				goto delegate;			if (u.r.wValue != USB_ENDPOINT_HALT					|| u.r.wLength != 0)				goto do_stall;			if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0)				goto do_stall;			clear_halt (e);			allow_status (ep);			VDEBUG (dev, "%s clear halt\n", ep->ep.name);			goto next_endpoints;			}			break;		case USB_REQ_SET_FEATURE: {			struct net2280_ep	*e;			/* hw handles device features */			if (u.r.bRequestType != USB_RECIP_ENDPOINT)				goto delegate;			if (u.r.wValue != USB_ENDPOINT_HALT					|| u.r.wLength != 0)				goto do_stall;			if ((e = get_ep_by_addr (dev, u.r.wIndex)) == 0)				goto do_stall;			set_halt (e);			allow_status (ep);			VDEBUG (dev, "%s set halt\n", ep->ep.name);			goto next_endpoints;			}			break;		default:delegate:			VDEBUG (dev, "setup %02x.%02x v%04x i%04x "				"ep_cfg %08x\n",				u.r.bRequestType, u.r.bRequest,				u.r.wValue, u.r.wIndex,				readl (&ep->regs->ep_cfg));			spin_unlock (&dev->lock);			tmp = dev->driver->setup (&dev->gadget, &u.r);			spin_lock (&dev->lock);		}		/* stall ep0 on error */		if (tmp < 0) {do_stall:			VDEBUG (dev, "req %02x.%02x protocol STALL; stat %d\n",					u.r.bRequestType, u.r.bRequest, tmp);			dev->protocol_stall = 1;		}		/* some in/out token irq should follow; maybe stall then.		 * driver must queue a request (even zlp) or halt ep0		 * before the host times out.		 */	}next_endpoints:	/* endpoint data irq ? */	scratch = stat & 0x7f;	stat &= ~0x7f;	for (num = 0; scratch; num++) {		u32		t;		/* do this endpoint's FIFO and queue need tending? */		t = 1 << num;		if ((scratch & t) == 0)			continue;		scratch ^= t;		ep = &dev->ep [num];		handle_ep_small (ep);	}	if (stat)		DEBUG (dev, "unhandled irqstat0 %08x\n", stat);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/320f34595c3cf37d180a087a935c050e4ac0e4d5/net2280.c/clean/drivers/usb/gadget/net2280.c