Dave:

I ran into some difficulties with gadgetfs and your sample usermode driver 
program recently.  Easy part first -- here is a patch you might want to 
add to the driver program.  Simple changes.


Index: gadget/usb.c
===================================================================
--- gadget.orig/usb.c
+++ gadget/usb.c
@@ -1,5 +1,5 @@
 /* cc -Wall -g -Ikernel2x/include -o usb usb.c usbstring.c -lpthread */
-/* optionally with "-DAIO" with a recent 2.6 gadgetfs */
+/* optionally with "-DAIO -laio" with a recent 2.6 gadgetfs */
 
 /*
  * this is an example pthreaded USER MODE driver implementing a
@@ -243,8 +243,9 @@ static int autoconfig ()
 {
        struct stat     statb;
 
-       /* NetChip 2280 PCI device, high/full speed */
-       if (stat (DEVNAME = "net2280", &statb) == 0) {
+       /* NetChip 2280 PCI device or dummy_hcd, high/full speed */
+       if (stat (DEVNAME = "net2280", &statb) == 0 ||
+                       stat (DEVNAME = "dummy_udc", &statb) == 0) {
                HIGHSPEED = 1;
                device_desc.bcdDevice = __constant_cpu_to_le16 (0x0100),
 
@@ -378,8 +379,9 @@ static int iso_autoconfig ()
         */
        device_desc.idProduct = __constant_cpu_to_le16(DRIVER_ISO_PRODUCT_NUM);
 
-       /* NetChip 2280 PCI device, high/full speed */
-       if (stat (DEVNAME = "net2280", &statb) == 0) {
+       /* NetChip 2280 PCI device or dummy_hcd, high/full speed */
+       if (stat (DEVNAME = "net2280", &statb) == 0 ||
+                       stat (DEVNAME = "dummy_udc", &statb) == 0) {
                unsigned        bInterval, wMaxPacketSize;
 
                HIGHSPEED = 1;
@@ -549,7 +551,7 @@ static void close_fd (void *fd_ptr)
  * whether or not the host is connected
  */
 static int
-ep_config (char *name, char *label,
+ep_config (char *name, const char *label,
        struct usb_endpoint_descriptor *fs,
        struct usb_endpoint_descriptor *hs
 )


The main issue with gadgetfs is that it never terminates short control 
responses with a zero-length packet.  This shows up clearly with the user 
driver since the serial-number string is 31 characters, which becomes 62 
bytes in Unicode plus the 2-byte descriptor header.  The host asks for a 
255-byte transfer, it receives the 64-byte response in a single packet, 
and then the request times out.  Below is a patch to fix the problem; I 
don't know if this is the best way but it seems to work.

That is, it seems to work when using dummy_hcd.  It doesn't work with
net2280, and I can only conclude that the net2280 code does not support
req->zero on ep0!  (I haven't tried other endpoints.)  Too bad there's no
way to check this out using usbtest.  Do you have any idea what could be
going on?

Alan Stern



Change gadgetfs to add a zero-length packet when needed for a short
response on ep0.  Also allow support for high-speed operation by default.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>

---

Index: usb-2.6/drivers/usb/gadget/inode.c
===================================================================
--- usb-2.6.orig/drivers/usb/gadget/inode.c
+++ usb-2.6/drivers/usb/gadget/inode.c
@@ -22,6 +22,7 @@
 
 // #define     DEBUG                   /* data to help fault diagnosis */
 // #define     VERBOSE         /* extra debug messages (success too) */
+#define        HIGHSPEED
 
 #include <linux/init.h>
 #include <linux/module.h>
@@ -135,6 +136,7 @@ struct dev_data {
                                        setup_out_ready : 1,
                                        setup_out_error : 1,
                                        setup_abort : 1;
+       unsigned                        setup_wLength;
 
        /* the rest is basically write-once */
        struct usb_config_descriptor    *config, *hs_config;
@@ -942,6 +944,7 @@ static int setup_req (struct usb_ep *ep,
        }
        req->complete = ep0_complete;
        req->length = len;
+       req->zero = 0;
        return 0;
 }
 
@@ -1161,10 +1164,13 @@ ep0_write (struct file *fd, const char _
                                spin_unlock_irq (&dev->lock);
                                if (copy_from_user (dev->req->buf, buf, len))
                                        retval = -EFAULT;
-                               else
+                               else {
+                                       if (len < dev->setup_wLength)
+                                               dev->req->zero = 1;
                                        retval = usb_ep_queue (
                                                dev->gadget->ep0, dev->req,
                                                GFP_KERNEL);
+                               }
                                if (retval < 0) {
                                        spin_lock_irq (&dev->lock);
                                        clean_req (dev->gadget->ep0, dev->req);
@@ -1483,6 +1489,7 @@ unrecognized:
 delegate:
                        dev->setup_in = (ctrl->bRequestType & USB_DIR_IN)
                                                ? 1 : 0;
+                       dev->setup_wLength = w_length;
                        dev->setup_out_ready = 0;
                        dev->setup_out_error = 0;
                        value = 0;



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to