Greg KH wrote:

Can you send this in 'diff -u' format so that I can apply it (or at
least determine where it should go in the driver?


Lets try it.
A diff of iowarrior.c and iowarrior.h from your kernel tree.
I renamed packet_size to report_size to make clear what is used in the driver. The driver handles HID reports.
--- gregkh.orig/iowarrior.c     2007-02-21 09:40:53.000000000 +0100
+++ iowarrior.c 2007-02-21 09:43:27.000000000 +0100
@@ -48,7 +48,7 @@
 /*
    maximum number of urbs that are submitted for writes at the same time,
    this applies to the IOWarrior56 only!
-   IOWarrior24 and IOWarrior40 use synchronus usb_control_msg calls.
+   IOWarrior24 and IOWarrior40 use synchronous usb_control_msg calls.
 */
 #define MAX_WRITES_IN_FLIGHT 4
 
@@ -93,7 +93,7 @@
        int present;                    /* this is 1 as long as the device is 
connected */
        int opened;                     /* this is 1 if the device is currently 
open */
        char chip_serial[9];            /* the serial number string of the chip 
connected */
-       int packet_size;                /* number of bytes in a report */
+       int report_size;                /* number of bytes in a report */
        u16 product_id;
 };
 
@@ -185,10 +185,10 @@
        if ((intr_idx != read_idx)
            && (dev->interface->cur_altsetting->desc.bInterfaceNumber == 0)) {
                /* + 1 for serial number */
-               offset = aux_idx * (dev->packet_size + 1);
+               offset = aux_idx * (dev->report_size + 1);
                if (!memcmp
                    (dev->read_queue + offset, urb->transfer_buffer,
-                    dev->packet_size)) {
+                    dev->report_size)) {
                        /* equal values on interface 0 will be ignored */
                        spin_unlock(&dev->intr_idx_lock);
                        goto exit;
@@ -205,10 +205,10 @@
        }
 
        /* +1 for serial number */
-       offset = intr_idx * (dev->packet_size + 1);
+       offset = intr_idx * (dev->report_size + 1);
        memcpy(dev->read_queue + offset, urb->transfer_buffer,
-              dev->packet_size);
-       *(dev->read_queue + offset + (dev->packet_size)) = dev->serial_number++;
+              dev->report_size);
+       *(dev->read_queue + offset + (dev->report_size)) = dev->serial_number++;
 
        atomic_set(&dev->intr_idx, aux_idx);
        spin_unlock(&dev->intr_idx_lock);
@@ -290,8 +290,8 @@
        dbg("%s - minor %d, count = %zd", __func__, dev->minor, count);
 
        /* read count must be packet size (+ time stamp) */
-       if ((count != dev->packet_size)
-           && (count != (dev->packet_size + 1)))
+       if ((count != dev->report_size)
+           && (count != (dev->report_size + 1)))
                return -EINVAL;
 
        /* repeat until no buffer overrun in callback handler occur */
@@ -324,7 +324,7 @@
                        }
                }
 
-               offset = read_idx * (dev->packet_size + 1);
+               offset = read_idx * (dev->report_size + 1);
                if (copy_to_user(buffer, dev->read_queue + offset, count)) {
                        return -EFAULT;
                }
@@ -361,7 +361,7 @@
                goto exit;
        }
        /* We only accept full reports */
-       if (count != dev->packet_size) {
+       if (count != dev->report_size) {
                retval = -EINVAL;
                goto exit;
        }
@@ -369,7 +369,7 @@
            dev->product_id == USB_DEVICE_ID_CODEMERCS_IOWPV1 ||
            dev->product_id == USB_DEVICE_ID_CODEMERCS_IOWPV2 ||
            dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW40) {
-               /* IOW24 and IOW40 use a synchronus call */
+               /* IOW24 and IOW40 use a synchronous call */
                buf = kmalloc(8, GFP_KERNEL);   /* 8 bytes are enough for both 
products */
                if (!buf) {
                        retval = -ENOMEM;
@@ -385,7 +385,7 @@
                kfree(buf);
                goto exit;
        } else if (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) {
-               /* The IOW56 uses asynchronus IO and more urbs */
+               /* The IOW56 uses asynchronous IO and more urbs */
                if (atomic_read(&dev->write_busy) == MAX_WRITES_IN_FLIGHT) {
                        /* Wait until we are below the limit for submitted urbs 
*/
                        if (file->f_flags & O_NONBLOCK) {
@@ -424,7 +424,7 @@
                        dbg("%s Unable to allocate urb ", __func__);
                        goto error;
                }
-               buf = usb_buffer_alloc(dev->udev, dev->packet_size,
+               buf = usb_buffer_alloc(dev->udev, dev->report_size,
                                       GFP_KERNEL, &int_out_urb->transfer_dma);
                if (!buf) {
                        retval = -ENOMEM;
@@ -435,7 +435,7 @@
                                 usb_sndintpipe(dev->udev,
                                                dev->int_out_endpoint->
                                                bEndpointAddress), buf,
-                                dev->packet_size, iowarrior_write_callback,
+                                dev->report_size, iowarrior_write_callback,
                                 dev, dev->int_out_endpoint->bInterval);
                int_out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
                if (copy_from_user(buf, user_buffer, count)) {
@@ -460,7 +460,7 @@
                goto exit;
        }
 error:
-       usb_buffer_free(dev->udev, dev->packet_size, buf,
+       usb_buffer_free(dev->udev, dev->report_size, buf,
                        int_out_urb->transfer_dma);
        usb_free_urb(int_out_urb);
        atomic_dec(&dev->write_busy);
@@ -510,13 +510,13 @@
                    dev->product_id == USB_DEVICE_ID_CODEMERCS_IOWPV2 ||
                    dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW40) {
                        io_res = copy_from_user(buffer, user_buffer,
-                                               dev->packet_size);
+                                               dev->report_size);
                        if (io_res) {
                                retval = -EFAULT;
                        } else {
                                io_res = usb_set_report(dev->interface, 2, 0,
                                                        buffer,
-                                                       dev->packet_size);
+                                                       dev->report_size);
                                if (io_res < 0)
                                        retval = io_res;
                        }
@@ -528,11 +528,11 @@
        case IOW_READ:
                io_res = usb_get_report(dev->udev,
                                        dev->interface->cur_altsetting, 1, 0,
-                                       buffer, dev->packet_size);
+                                       buffer, dev->report_size);
                if (io_res < 0)
                        retval = io_res;
                else {
-                       io_res = copy_to_user(user_buffer, buffer, 
dev->packet_size);
+                       io_res = copy_to_user(user_buffer, buffer, 
dev->report_size);
                        if (io_res < 0)
                                retval = -EFAULT;
                }
@@ -549,7 +549,7 @@
                        info.revision = 
le16_to_cpu(dev->udev->descriptor.bcdDevice);
                        info.speed = le16_to_cpu(dev->udev->speed);     /* 
0==UNKNOWN, 1==LOW(usb1.1) ,2=FULL(usb1.1), 3=HIGH(usb2.0) */
                        info.if_num = 
dev->interface->cur_altsetting->desc.bInterfaceNumber;
-                       info.packet_size = dev->packet_size;
+                       info.report_size = dev->report_size;
                        /* serial number string has been read earlier 8 chars 
or empty string */
                        memcpy(info.serial, dev->chip_serial,
                               sizeof(dev->chip_serial));
@@ -777,15 +777,20 @@
                        /* this one will match for the IOWarrior56 only */
                        dev->int_out_endpoint = endpoint;
        }
-       /* we have to check the packet_size often, so remember it in the 
endianess suitable for our machine */
-       dev->packet_size = le16_to_cpu(dev->int_in_endpoint->wMaxPacketSize);
+       /* we have to check the report_size often, so remember it in the 
endianess suitable for our machine */
+       dev->report_size = le16_to_cpu(dev->int_in_endpoint->wMaxPacketSize);
+       if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0)
+           && (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56))
+               /* IOWarrior56 has wMaxPacketSize different from report size */
+               dev->report_size = 7;
+
        /* create the urb and buffer for reading */
        dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!dev->int_in_urb) {
                dev_err(&interface->dev, "Couldn't allocate 
interrupt_in_urb\n");
                goto error;
        }
-       dev->int_in_buffer = kmalloc(dev->packet_size, GFP_KERNEL);
+       dev->int_in_buffer = kmalloc(dev->report_size, GFP_KERNEL);
        if (!dev->int_in_buffer) {
                dev_err(&interface->dev, "Couldn't allocate int_in_buffer\n");
                goto error;
@@ -793,12 +798,12 @@
        usb_fill_int_urb(dev->int_in_urb, dev->udev,
                         usb_rcvintpipe(dev->udev,
                                        dev->int_in_endpoint->bEndpointAddress),
-                        dev->int_in_buffer, dev->packet_size,
+                        dev->int_in_buffer, dev->report_size,
                         iowarrior_callback, dev,
                         dev->int_in_endpoint->bInterval);
        /* create an internal buffer for interrupt data from the device */
        dev->read_queue =
-           kmalloc(((dev->packet_size + 1) * MAX_INTERRUPT_BUFFER),
+           kmalloc(((dev->report_size + 1) * MAX_INTERRUPT_BUFFER),
                    GFP_KERNEL);
        if (!dev->read_queue) {
                dev_err(&interface->dev, "Couldn't allocate read_queue\n");
--- gregkh.orig/iowarrior.h     2007-02-21 09:40:42.000000000 +0100
+++ iowarrior.h 2007-02-21 09:38:51.000000000 +0100
@@ -19,7 +19,7 @@
        __u32 speed;            /* USB-speed of the device (0=UNKNOWN, 1=LOW, 
2=FULL 3=HIGH) */
        __u32 power;            /* power consumption of the device in mA */
        __u32 if_num;           /* the number of the endpoint */
-       __u32 packet_size;      /* size of the data-packets on this interface */
+       __u32 report_size;      /* max report size on this interface */
 };
 
 /*
-------------------------------------------------------------------------
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
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to