ChangeSet 1.1083.2.7, 2003/08/28 11:05:57-07:00, [EMAIL PROTECTED]

[PATCH] USB: acm.c update for new devices

This support is already in 2.6


 drivers/usb/acm.c |  165 +++++++++++++++++++++++++++---------------------------
 1 files changed, 85 insertions(+), 80 deletions(-)


diff -Nru a/drivers/usb/acm.c b/drivers/usb/acm.c
--- a/drivers/usb/acm.c Thu Aug 28 14:49:49 2003
+++ b/drivers/usb/acm.c Thu Aug 28 14:49:49 2003
@@ -512,7 +512,7 @@
        struct usb_config_descriptor *cfacm;
        struct usb_interface_descriptor *ifcom, *ifdata;
        struct usb_endpoint_descriptor *epctrl, *epread, *epwrite;
-       int readsize, ctrlsize, minor, i;
+       int readsize, ctrlsize, minor, i, j;
        unsigned char *buf;
 
        for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
@@ -521,93 +521,98 @@
 
                dbg("probing config %d", cfacm->bConfigurationValue);
 
-               if (cfacm->bNumInterfaces != 2 ||
-                   usb_interface_claimed(cfacm->interface + 0) ||
-                   usb_interface_claimed(cfacm->interface + 1))
-                       continue;
-
-               ifcom = cfacm->interface[0].altsetting + 0;
-               ifdata = cfacm->interface[1].altsetting + 0;
-
-               if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints < 2) {
-                       ifcom = cfacm->interface[1].altsetting + 0;
-                       ifdata = cfacm->interface[0].altsetting + 0;
-                       if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints < 2)
-                               continue;
-               }
-
-               if (ifcom->bInterfaceClass != 2 || ifcom->bInterfaceSubClass != 2 ||
-                   ifcom->bInterfaceProtocol != 1 || ifcom->bNumEndpoints < 1)
-                       continue;
-
-               epctrl = ifcom->endpoint + 0;
-               epread = ifdata->endpoint + 0;
-               epwrite = ifdata->endpoint + 1;
-
-               if ((epctrl->bEndpointAddress & 0x80) != 0x80 || (epctrl->bmAttributes 
& 3) != 3 ||
-                  (epread->bmAttributes & 3) != 2 || (epwrite->bmAttributes & 3) != 2 
||
-                  ((epread->bEndpointAddress & 0x80) ^ (epwrite->bEndpointAddress & 
0x80)) != 0x80)
-                       continue;
-
-               if ((epread->bEndpointAddress & 0x80) != 0x80) {
-                       epread = ifdata->endpoint + 1;
-                       epwrite = ifdata->endpoint + 0;
-               }
+               for (j = 0; j < cfacm->bNumInterfaces - 1; j++) {
 
-               usb_set_configuration(dev, cfacm->bConfigurationValue);
-
-               for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++);
-               if (acm_table[minor]) {
-                       err("no more free acm devices");
-                       return NULL;
-               }
-
-               if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) {
-                       err("out of memory");
-                       return NULL;
-               }
-               memset(acm, 0, sizeof(struct acm));
-
-               ctrlsize = epctrl->wMaxPacketSize;
-               readsize = epread->wMaxPacketSize;
-               acm->writesize = epwrite->wMaxPacketSize;
-               acm->iface = cfacm->interface;
-               acm->minor = minor;
-               acm->dev = dev;
-
-               acm->tqueue.routine = acm_softint;
-               acm->tqueue.data = acm;
-
-               if (!(buf = kmalloc(ctrlsize + readsize + acm->writesize, 
GFP_KERNEL))) {
-                       err("out of memory");
-                       kfree(acm);
-                       return NULL;
-               }
-
-               FILL_INT_URB(&acm->ctrlurb, dev, usb_rcvintpipe(dev, 
epctrl->bEndpointAddress),
-                       buf, ctrlsize, acm_ctrl_irq, acm, epctrl->bInterval);
+                       if (usb_interface_claimed(cfacm->interface + j) ||
+                           usb_interface_claimed(cfacm->interface + j + 1))
+                               continue;
 
-               FILL_BULK_URB(&acm->readurb, dev, usb_rcvbulkpipe(dev, 
epread->bEndpointAddress),
-                       buf += ctrlsize, readsize, acm_read_bulk, acm);
-               acm->readurb.transfer_flags |= USB_NO_FSBR;
+                       ifcom = cfacm->interface[j].altsetting + 0;
+                       ifdata = cfacm->interface[j + 1].altsetting + 0;
 
-               FILL_BULK_URB(&acm->writeurb, dev, usb_sndbulkpipe(dev, 
epwrite->bEndpointAddress),
-                       buf += readsize, acm->writesize, acm_write_bulk, acm);
-               acm->writeurb.transfer_flags |= USB_NO_FSBR;
+                       if (ifdata->bInterfaceClass != 10 || ifdata->bNumEndpoints < 
2) {
+                               ifcom = cfacm->interface[j + 1].altsetting + 0;
+                               ifdata = cfacm->interface[j].altsetting + 0;
+                               if (ifdata->bInterfaceClass != 10 || 
ifdata->bNumEndpoints < 2)
+                                       continue;
+                       }
+
+                       if (ifcom->bInterfaceClass != 2 || ifcom->bInterfaceSubClass 
!= 2 ||
+                           ifcom->bInterfaceProtocol < 1 || ifcom->bInterfaceProtocol 
> 6 ||
+                           ifcom->bNumEndpoints < 1)
+                               continue;
 
-               printk(KERN_INFO "ttyACM%d: USB ACM device\n", minor);
+                       epctrl = ifcom->endpoint + 0;
+                       epread = ifdata->endpoint + 0;
+                       epwrite = ifdata->endpoint + 1;
+
+                       if ((epctrl->bEndpointAddress & 0x80) != 0x80 || 
(epctrl->bmAttributes & 3) != 3 ||
+                           (epread->bmAttributes & 3) != 2 || (epwrite->bmAttributes 
& 3) != 2 ||
+                           ((epread->bEndpointAddress & 0x80) ^ 
(epwrite->bEndpointAddress & 0x80)) != 0x80)
+                               continue;
 
-               acm_set_control(acm, acm->ctrlout);
+                       dbg("using interface %d\n", j);
 
-               acm->line.speed = cpu_to_le32(9600);
-               acm->line.databits = 8;
-               acm_set_line(acm, &acm->line);
+                       if ((epread->bEndpointAddress & 0x80) != 0x80) {
+                               epread = ifdata->endpoint + 1;
+                               epwrite = ifdata->endpoint + 0;
+                       }
+
+                       usb_set_configuration(dev, cfacm->bConfigurationValue);
+
+                       for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; 
minor++);
+                       if (acm_table[minor]) {
+                               err("no more free acm devices");
+                               return NULL;
+                       }
+
+                       if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) {
+                               err("out of memory");
+                               return NULL;
+                       }
+                       memset(acm, 0, sizeof(struct acm));
+
+                       ctrlsize = epctrl->wMaxPacketSize;
+                       readsize = epread->wMaxPacketSize;
+                       acm->writesize = epwrite->wMaxPacketSize;
+                       acm->iface = cfacm->interface + j;
+                       acm->minor = minor;
+                       acm->dev = dev;
+
+                       acm->tqueue.routine = acm_softint;
+                       acm->tqueue.data = acm;
+
+                       if (!(buf = kmalloc(ctrlsize + readsize + acm->writesize, 
GFP_KERNEL))) {
+                               err("out of memory");
+                               kfree(acm);
+                               return NULL;
+                       }
+
+                       FILL_INT_URB(&acm->ctrlurb, dev, usb_rcvintpipe(dev, 
epctrl->bEndpointAddress),
+                                    buf, ctrlsize, acm_ctrl_irq, acm, 
epctrl->bInterval);
+
+                       FILL_BULK_URB(&acm->readurb, dev, usb_rcvbulkpipe(dev, 
epread->bEndpointAddress),
+                                     buf += ctrlsize, readsize, acm_read_bulk, acm);
+                       acm->readurb.transfer_flags |= USB_NO_FSBR;
+
+                       FILL_BULK_URB(&acm->writeurb, dev, usb_sndbulkpipe(dev, 
epwrite->bEndpointAddress),
+                                     buf += readsize, acm->writesize, acm_write_bulk, 
acm);
+                       acm->writeurb.transfer_flags |= USB_NO_FSBR;
+
+                       printk(KERN_INFO "ttyACM%d: USB ACM device\n", minor);
+
+                       acm_set_control(acm, acm->ctrlout);
+
+                       acm->line.speed = cpu_to_le32(9600);
+                       acm->line.databits = 8;
+                       acm_set_line(acm, &acm->line);
 
-               usb_driver_claim_interface(&acm_driver, acm->iface + 0, acm);
-               usb_driver_claim_interface(&acm_driver, acm->iface + 1, acm);
+                       usb_driver_claim_interface(&acm_driver, acm->iface + 0, acm);
+                       usb_driver_claim_interface(&acm_driver, acm->iface + 1, acm);
 
-               tty_register_devfs(&acm_tty_driver, 0, minor);
-               return acm_table[minor] = acm;
+                       tty_register_devfs(&acm_tty_driver, 0, minor);
+                       return acm_table[minor] = acm;
+               }
        }
 
        return NULL;



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to