switch (setup.wValue) { 
switch (w_value) { 
static void dummy_timer (unsigned long _dum){	struct dummy		*dum = (struct dummy *) _dum;	struct urbp		*urbp, *tmp;	unsigned long		flags;	int			limit, total;	int			i;	/* simplistic model for one frame's bandwidth */	switch (dum->gadget.speed) {	case USB_SPEED_LOW:		total = 8/*bytes*/ * 12/*packets*/;		break;	case USB_SPEED_FULL:		total = 64/*bytes*/ * 19/*packets*/;		break;	case USB_SPEED_HIGH:		total = 512/*bytes*/ * 13/*packets*/ * 8/*uframes*/;		break;	default:		dev_err (dummy_dev(dum), "bogus device speed\n");		return;	}	/* FIXME if HZ != 1000 this will probably misbehave ... */	/* look at each urb queued by the host side driver */	spin_lock_irqsave (&dum->lock, flags);	if (!dum->udev) {		dev_err (dummy_dev(dum),				"timer fired with no URBs pending?\n");		spin_unlock_irqrestore (&dum->lock, flags);		return;	}	for (i = 0; i < DUMMY_ENDPOINTS; i++) {		if (!ep_name [i])			break;		dum->ep [i].already_seen = 0;	}restart:	list_for_each_entry_safe (urbp, tmp, &dum->urbp_list, urbp_list) {		struct urb		*urb;		struct dummy_request	*req;		u8			address;		struct dummy_ep		*ep = NULL;		int			type;		urb = urbp->urb;		if (urb->status != -EINPROGRESS) {			/* likely it was just unlinked */			goto return_urb;		}		type = usb_pipetype (urb->pipe);		/* used up this frame's non-periodic bandwidth?		 * FIXME there's infinite bandwidth for control and		 * periodic transfers ... unrealistic.		 */		if (total <= 0 && type == PIPE_BULK)			continue;		/* find the gadget's ep for this request (if configured) */		address = usb_pipeendpoint (urb->pipe);		if (usb_pipein (urb->pipe))			address |= USB_DIR_IN;		ep = find_endpoint(dum, address);		if (!ep) {			/* set_configuration() disagreement */			dev_dbg (dummy_dev(dum),				"no ep configured for urb %p\n",				urb);			maybe_set_status (urb, -EPROTO);			goto return_urb;		}		if (ep->already_seen)			continue;		ep->already_seen = 1;		if (ep == &dum->ep [0] && urb->error_count) {			ep->setup_stage = 1;	/* a new urb */			urb->error_count = 0;		}		if (ep->halted && !ep->setup_stage) {			/* NOTE: must not be iso! */			dev_dbg (dummy_dev(dum), "ep %s halted, urb %p\n",					ep->ep.name, urb);			maybe_set_status (urb, -EPIPE);			goto return_urb;		}		/* FIXME make sure both ends agree on maxpacket */		/* handle control requests */		if (ep == &dum->ep [0] && ep->setup_stage) {			struct usb_ctrlrequest		setup;			int				value = 1;			struct dummy_ep			*ep2;			setup = *(struct usb_ctrlrequest*) urb->setup_packet;			if (setup.wLength != urb->transfer_buffer_length) {				maybe_set_status (urb, -EOVERFLOW);				goto return_urb;			}			/* paranoia, in case of stale queued data */			list_for_each_entry (req, &ep->queue, queue) {				list_del_init (&req->queue);				req->req.status = -EOVERFLOW;				dev_dbg (udc_dev(dum), "stale req = %p\n",						req);				spin_unlock (&dum->lock);				req->req.complete (&ep->ep, &req->req);				spin_lock (&dum->lock);				ep->already_seen = 0;				goto restart;			}			/* gadget driver never sees set_address or operations			 * on standard feature flags.  some hardware doesn't			 * even expose them.			 */			ep->last_io = jiffies;			ep->setup_stage = 0;			ep->halted = 0;			switch (setup.bRequest) {			case USB_REQ_SET_ADDRESS:				if (setup.bRequestType != Dev_Request)					break;				dum->address = setup.wValue;				maybe_set_status (urb, 0);				dev_dbg (udc_dev(dum), "set_address = %d\n",						setup.wValue);				value = 0;				break;			case USB_REQ_SET_FEATURE:				if (setup.bRequestType == Dev_Request) {					value = 0;					switch (setup.wValue) {					case USB_DEVICE_REMOTE_WAKEUP:						break;					case USB_DEVICE_B_HNP_ENABLE:						dum->gadget.b_hnp_enable = 1;						break;					case USB_DEVICE_A_HNP_SUPPORT:						dum->gadget.a_hnp_support = 1;						break;					case USB_DEVICE_A_ALT_HNP_SUPPORT:						dum->gadget.a_alt_hnp_support							= 1;						break;					default:						value = -EOPNOTSUPP;					}					if (value == 0) {						dum->devstatus |=							(1 << setup.wValue);						maybe_set_status (urb, 0);					}				} else if (setup.bRequestType == Ep_Request) {					// endpoint halt					ep2 = find_endpoint (dum,							setup.wIndex);					if (!ep2) {						value = -EOPNOTSUPP;						break;					}					ep2->halted = 1;					value = 0;					maybe_set_status (urb, 0);				}				break;			case USB_REQ_CLEAR_FEATURE:				if (setup.bRequestType == Dev_Request) {					switch (setup.wValue) {					case USB_DEVICE_REMOTE_WAKEUP:						dum->devstatus &= ~(1 <<							USB_DEVICE_REMOTE_WAKEUP);						value = 0;						maybe_set_status (urb, 0);						break;					default:						value = -EOPNOTSUPP;						break;					}				} else if (setup.bRequestType == Ep_Request) {					// endpoint halt					ep2 = find_endpoint (dum,							setup.wIndex);					if (!ep2) {						value = -EOPNOTSUPP;						break;					}					ep2->halted = 0;					value = 0;					maybe_set_status (urb, 0);				}				break;			case USB_REQ_GET_STATUS:				if (setup.bRequestType == Dev_InRequest						|| setup.bRequestType							== Intf_InRequest						|| setup.bRequestType							== Ep_InRequest						) {					char *buf;					// device: remote wakeup, selfpowered					// interface: nothing					// endpoint: halt					buf = (char *)urb->transfer_buffer;					if (urb->transfer_buffer_length > 0) {						if (setup.bRequestType ==								Ep_InRequest) {	ep2 = find_endpoint (dum, setup.wIndex);	if (!ep2) {		value = -EOPNOTSUPP;		break;	}	buf [0] = ep2->halted;						} else if (setup.bRequestType ==								Dev_InRequest) {							buf [0] = (u8)								dum->devstatus;						} else							buf [0] = 0;					}					if (urb->transfer_buffer_length > 1)						buf [1] = 0;					urb->actual_length = min (2,						urb->transfer_buffer_length);					value = 0;					maybe_set_status (urb, 0);				}				break;			}			/* gadget driver handles all other requests.  block			 * until setup() returns; no reentrancy issues etc.			 */			if (value > 0) {				spin_unlock (&dum->lock);				value = dum->driver->setup (&dum->gadget,						&setup);				spin_lock (&dum->lock);				if (value >= 0) {					/* no delays (max 64KB data stage) */					limit = 64*1024;					goto treat_control_like_bulk;				}				/* error, see below */			}			if (value < 0) {				if (value != -EOPNOTSUPP)					dev_dbg (udc_dev(dum),						"setup --> %d\n",						value);				maybe_set_status (urb, -EPIPE);				urb->actual_length = 0;			}			goto return_urb;		}		/* non-control requests */		limit = total;		switch (usb_pipetype (urb->pipe)) {		case PIPE_ISOCHRONOUS:			/* FIXME is it urb->interval since the last xfer?			 * use urb->iso_frame_desc[i].			 * complete whether or not ep has requests queued.			 * report random errors, to debug drivers.			 */			limit = max (limit, periodic_bytes (dum, ep));			maybe_set_status (urb, -ENOSYS);			break;		case PIPE_INTERRUPT:			/* FIXME is it urb->interval since the last xfer?			 * this almost certainly polls too fast.			 */			limit = max (limit, periodic_bytes (dum, ep));			/* FALLTHROUGH */		// case PIPE_BULK:  case PIPE_CONTROL:		default:		treat_control_like_bulk:			ep->last_io = jiffies;			total = transfer (dum, urb, ep, limit);			break;		}		/* incomplete transfer? */		if (urb->status == -EINPROGRESS)			continue;return_urb:		urb->hcpriv = NULL;		list_del (&urbp->urbp_list);		kfree (urbp);		if (ep)			ep->already_seen = ep->setup_stage = 0;		spin_unlock (&dum->lock);		usb_hcd_giveback_urb (dummy_to_hcd(dum), urb, NULL);		spin_lock (&dum->lock);		goto restart;	}	/* want a 1 msec delay here */	if (!list_empty (&dum->urbp_list))		mod_timer (&dum->timer, jiffies + msecs_to_jiffies(1));	else {		usb_put_dev (dum->udev);		dum->udev = NULL;	}	spin_unlock_irqrestore (&dum->lock, flags);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/cc095b0b5b653dca3e106710a72ba28b5bb7456b/dummy_hcd.c/buggy/drivers/usb/gadget/dummy_hcd.c