On Tue, 27 Feb 2007, Ajay Jain wrote: > Hi, > > I have these questions regarding the peripheral controller driver. > > 1. When the gadget driver queues a request for the EP0, how does one > get to know whether it is an "IN" request or an "OUT" request. I was > looking at a few implementations and I came across the following code: > > if (ep_is_in(ep)) { > dev->ep0state = DATA_STATE_XMIT; > lh7a40x_ep0_in(dev, csr); > } else { > dev->ep0state = DATA_STATE_RECV; > lh7a40x_ep0_out(dev, csr); > } > > where, #define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN)==USB_DIR_IN) > > For the EP0, (which is bidirectional), this condition would always > evaluate to a single value. In my opinion this piece of code is wrong. > Am I missing something here.
You are missing this code from lh7a40x_ep0_setup(): /* Set direction of EP0 */ if (likely(ctrl.bRequestType & USB_DIR_IN)) { ep->bEndpointAddress |= USB_DIR_IN; is_in = 1; } else { ep->bEndpointAddress &= ~USB_DIR_IN; is_in = 0; } As you can see, ep_is_in() does not always evaluate to the same value. > 2. How does the gadget driver know about the endpoint functions? > I understand that the peripheral driver submits all the eps to the > gadget's queue. But the only parameters that we fill in are the > maxpacketsize, name and the ep functions. Since the peripheral driver fills in the ep functions, the gadget driver knows what the functions are. > Suppose that the upper layer > wants to queue the packets to a particular ep. So how does it identify > that end point. Does it iterate through the whole list, and is it the > responsibility of peripheral driver to choose the right EP ? The gadget driver _does_ iterate through the whole list. It does this just once, it its bind() routine, and it selects which endpoints it will use. After that it always knows which is the right endpoint. It is not the peripheral driver's responsibility to choose endpoints. > I may have 'n' endpoints in my hardware, of which not all can be > configured as the desired one. So who will ensure this ? If the > peripheral controller driver rejects such an "enable" request, will > the gadget driver try and enable this on some other endpoint ? Look at ep_matches() and usb_ep_autoconfig() in epautoconf.c. That's where all this logic is. Gadget drivers use those routines. Alan Stern ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel