Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (22 commits)
USB: atmel_usba_udc fixes, mostly disconnect()
USB: pxa27x_udc: minor fixes
usbtest: comment on why this code "expects" negative and positive errnos
USB: remove PICDEM FS USB demo (04d8:000c) device from ldusb
USB: option: add new Dell 5520 HSDPA variant
USB: unusual_devs: Add support for GI 0401 SD-Card interface
USB: serial gadget: descriptor cleanup
USB: serial gadget: simplify endpoint handling
USB: serial gadget: remove needless data structure
USB: serial gadget: cleanup/reorg
usb: fix compile warning in isp1760
USB: do not handle device 1410:5010 in 'option' driver
USB: Fix unusual_devs.h ordering
USB: add Zoom Telephonics Model 3095F V.92 USB Mini External modem to cdc-acm
USB: Support for the ET502HS HDSPA modem in option driver
USB: Support for the ET502HS HDSPA modem
usb: fix integer as NULL pointer warnings found by sparse
USB: isp1760: fix printk format
USB: add Telstra NextG CDMA id to option driver
USB: add association.h
...

+780 -571
+3
drivers/usb/class/cdc-acm.c
··· 1248 1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ 1249 1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1250 1250 }, 1251 + { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */ 1252 + .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1253 + }, 1251 1254 1252 1255 /* control interfaces with various AT-command sets */ 1253 1256 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
+5 -6
drivers/usb/core/endpoint.c
··· 156 156 static struct attribute_group ep_dev_attr_grp = { 157 157 .attrs = ep_dev_attrs, 158 158 }; 159 + static struct attribute_group *ep_dev_groups[] = { 160 + &ep_dev_attr_grp, 161 + NULL 162 + }; 159 163 160 164 static int usb_endpoint_major_init(void) 161 165 { ··· 302 298 303 299 ep_dev->desc = &endpoint->desc; 304 300 ep_dev->udev = udev; 301 + ep_dev->dev.groups = ep_dev_groups; 305 302 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); 306 303 ep_dev->dev.class = ep_class->class; 307 304 ep_dev->dev.parent = parent; ··· 314 309 retval = device_register(&ep_dev->dev); 315 310 if (retval) 316 311 goto error_chrdev; 317 - retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 318 - if (retval) 319 - goto error_group; 320 312 321 313 /* create the symlink to the old-style "ep_XX" directory */ 322 314 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); ··· 324 322 return retval; 325 323 326 324 error_link: 327 - sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 328 - error_group: 329 325 device_unregister(&ep_dev->dev); 330 326 destroy_endpoint_class(); 331 327 return retval; ··· 348 348 349 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 350 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name); 351 - sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 352 351 device_unregister(&ep_dev->dev); 353 352 endpoint->ep_dev = NULL; 354 353 destroy_endpoint_class();
+1
drivers/usb/core/message.c
··· 1607 1607 intf->dev.driver = NULL; 1608 1608 intf->dev.bus = &usb_bus_type; 1609 1609 intf->dev.type = &usb_if_device_type; 1610 + intf->dev.groups = usb_interface_groups; 1610 1611 intf->dev.dma_mask = dev->dev.dma_mask; 1611 1612 device_initialize(&intf->dev); 1612 1613 mark_quiesced(intf);
+85 -52
drivers/usb/core/sysfs.c
··· 538 538 .attrs = dev_attrs, 539 539 }; 540 540 541 + /* When modifying this list, be sure to modify dev_string_attrs_are_visible() 542 + * accordingly. 543 + */ 544 + static struct attribute *dev_string_attrs[] = { 545 + &dev_attr_manufacturer.attr, 546 + &dev_attr_product.attr, 547 + &dev_attr_serial.attr, 548 + NULL 549 + }; 550 + 551 + static mode_t dev_string_attrs_are_visible(struct kobject *kobj, 552 + struct attribute *a, int n) 553 + { 554 + struct usb_device *udev = to_usb_device( 555 + container_of(kobj, struct device, kobj)); 556 + 557 + if (a == &dev_attr_manufacturer.attr) { 558 + if (udev->manufacturer == NULL) 559 + return 0; 560 + } else if (a == &dev_attr_product.attr) { 561 + if (udev->product == NULL) 562 + return 0; 563 + } else if (a == &dev_attr_serial.attr) { 564 + if (udev->serial == NULL) 565 + return 0; 566 + } 567 + return a->mode; 568 + } 569 + 570 + static struct attribute_group dev_string_attr_grp = { 571 + .attrs = dev_string_attrs, 572 + .is_visible = dev_string_attrs_are_visible, 573 + }; 574 + 575 + struct attribute_group *usb_device_groups[] = { 576 + &dev_attr_grp, 577 + &dev_string_attr_grp, 578 + NULL 579 + }; 580 + 541 581 /* Binary descriptors */ 542 582 543 583 static ssize_t ··· 631 591 struct device *dev = &udev->dev; 632 592 int retval; 633 593 634 - retval = sysfs_create_group(&dev->kobj, &dev_attr_grp); 635 - if (retval) 636 - return retval; 637 - 594 + /* Unforunately these attributes cannot be created before 595 + * the uevent is broadcast. 596 + */ 638 597 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); 639 598 if (retval) 640 599 goto error; ··· 646 607 if (retval) 647 608 goto error; 648 609 649 - if (udev->manufacturer) { 650 - retval = device_create_file(dev, &dev_attr_manufacturer); 651 - if (retval) 652 - goto error; 653 - } 654 - if (udev->product) { 655 - retval = device_create_file(dev, &dev_attr_product); 656 - if (retval) 657 - goto error; 658 - } 659 - if (udev->serial) { 660 - retval = device_create_file(dev, &dev_attr_serial); 661 - if (retval) 662 - goto error; 663 - } 664 610 retval = usb_create_ep_files(dev, &udev->ep0, udev); 665 611 if (retval) 666 612 goto error; ··· 660 636 struct device *dev = &udev->dev; 661 637 662 638 usb_remove_ep_files(&udev->ep0); 663 - device_remove_file(dev, &dev_attr_manufacturer); 664 - device_remove_file(dev, &dev_attr_product); 665 - device_remove_file(dev, &dev_attr_serial); 666 639 remove_power_attributes(dev); 667 640 remove_persist_attributes(dev); 668 641 device_remove_bin_file(dev, &dev_bin_attr_descriptors); 669 - sysfs_remove_group(&dev->kobj, &dev_attr_grp); 670 642 } 671 643 672 644 /* Interface Accociation Descriptor fields */ ··· 708 688 struct device_attribute *attr, char *buf) 709 689 { 710 690 struct usb_interface *intf; 711 - struct usb_device *udev; 712 - int len; 691 + char *string; 713 692 714 693 intf = to_usb_interface(dev); 715 - udev = interface_to_usbdev(intf); 716 - len = snprintf(buf, 256, "%s", intf->cur_altsetting->string); 717 - if (len < 0) 694 + string = intf->cur_altsetting->string; 695 + barrier(); /* The altsetting might change! */ 696 + 697 + if (!string) 718 698 return 0; 719 - buf[len] = '\n'; 720 - buf[len+1] = 0; 721 - return len+1; 699 + return sprintf(buf, "%s\n", string); 722 700 } 723 701 static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 724 702 ··· 745 727 } 746 728 static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 747 729 748 - static struct attribute *intf_assoc_attrs[] = { 749 - &dev_attr_iad_bFirstInterface.attr, 750 - &dev_attr_iad_bInterfaceCount.attr, 751 - &dev_attr_iad_bFunctionClass.attr, 752 - &dev_attr_iad_bFunctionSubClass.attr, 753 - &dev_attr_iad_bFunctionProtocol.attr, 754 - NULL, 755 - }; 756 - static struct attribute_group intf_assoc_attr_grp = { 757 - .attrs = intf_assoc_attrs, 758 - }; 759 - 760 730 static struct attribute *intf_attrs[] = { 761 731 &dev_attr_bInterfaceNumber.attr, 762 732 &dev_attr_bAlternateSetting.attr, ··· 757 751 }; 758 752 static struct attribute_group intf_attr_grp = { 759 753 .attrs = intf_attrs, 754 + }; 755 + 756 + static struct attribute *intf_assoc_attrs[] = { 757 + &dev_attr_iad_bFirstInterface.attr, 758 + &dev_attr_iad_bInterfaceCount.attr, 759 + &dev_attr_iad_bFunctionClass.attr, 760 + &dev_attr_iad_bFunctionSubClass.attr, 761 + &dev_attr_iad_bFunctionProtocol.attr, 762 + NULL, 763 + }; 764 + 765 + static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj, 766 + struct attribute *a, int n) 767 + { 768 + struct usb_interface *intf = to_usb_interface( 769 + container_of(kobj, struct device, kobj)); 770 + 771 + if (intf->intf_assoc == NULL) 772 + return 0; 773 + return a->mode; 774 + } 775 + 776 + static struct attribute_group intf_assoc_attr_grp = { 777 + .attrs = intf_assoc_attrs, 778 + .is_visible = intf_assoc_attrs_are_visible, 779 + }; 780 + 781 + struct attribute_group *usb_interface_groups[] = { 782 + &intf_attr_grp, 783 + &intf_assoc_attr_grp, 784 + NULL 760 785 }; 761 786 762 787 static inline void usb_create_intf_ep_files(struct usb_interface *intf, ··· 814 777 815 778 int usb_create_sysfs_intf_files(struct usb_interface *intf) 816 779 { 817 - struct device *dev = &intf->dev; 818 780 struct usb_device *udev = interface_to_usbdev(intf); 819 781 struct usb_host_interface *alt = intf->cur_altsetting; 820 782 int retval; 821 783 822 784 if (intf->sysfs_files_created) 823 785 return 0; 824 - retval = sysfs_create_group(&dev->kobj, &intf_attr_grp); 825 - if (retval) 826 - return retval; 827 786 787 + /* The interface string may be present in some altsettings 788 + * and missing in others. Hence its attribute cannot be created 789 + * before the uevent is broadcast. 790 + */ 828 791 if (alt->string == NULL) 829 792 alt->string = usb_cache_string(udev, alt->desc.iInterface); 830 793 if (alt->string) 831 - retval = device_create_file(dev, &dev_attr_interface); 832 - if (intf->intf_assoc) 833 - retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp); 794 + retval = device_create_file(&intf->dev, &dev_attr_interface); 834 795 usb_create_intf_ep_files(intf, udev); 835 796 intf->sysfs_files_created = 1; 836 797 return 0; ··· 842 807 return; 843 808 usb_remove_intf_ep_files(intf); 844 809 device_remove_file(dev, &dev_attr_interface); 845 - sysfs_remove_group(&dev->kobj, &intf_attr_grp); 846 - sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp); 847 810 intf->sysfs_files_created = 0; 848 811 }
+1
drivers/usb/core/usb.c
··· 291 291 device_initialize(&dev->dev); 292 292 dev->dev.bus = &usb_bus_type; 293 293 dev->dev.type = &usb_device_type; 294 + dev->dev.groups = usb_device_groups; 294 295 dev->dev.dma_mask = bus->controller->dma_mask; 295 296 set_dev_node(&dev->dev, dev_to_node(bus->controller)); 296 297 dev->state = USB_STATE_ATTACHED;
+4
drivers/usb/core/usb.h
··· 130 130 /* for labeling diagnostics */ 131 131 extern const char *usbcore_name; 132 132 133 + /* sysfs stuff */ 134 + extern struct attribute_group *usb_device_groups[]; 135 + extern struct attribute_group *usb_interface_groups[]; 136 + 133 137 /* usbfs stuff */ 134 138 extern struct mutex usbfs_mutex; 135 139 extern struct usb_driver usbfs_driver;
+5 -5
drivers/usb/gadget/amd5536udc.c
··· 3251 3251 /* pci setup */ 3252 3252 if (pci_enable_device(pdev) < 0) { 3253 3253 kfree(dev); 3254 - dev = 0; 3254 + dev = NULL; 3255 3255 retval = -ENODEV; 3256 3256 goto finished; 3257 3257 } ··· 3264 3264 if (!request_mem_region(resource, len, name)) { 3265 3265 dev_dbg(&pdev->dev, "pci device used already\n"); 3266 3266 kfree(dev); 3267 - dev = 0; 3267 + dev = NULL; 3268 3268 retval = -EBUSY; 3269 3269 goto finished; 3270 3270 } ··· 3274 3274 if (dev->virt_addr == NULL) { 3275 3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n"); 3276 3276 kfree(dev); 3277 - dev = 0; 3277 + dev = NULL; 3278 3278 retval = -EFAULT; 3279 3279 goto finished; 3280 3280 } ··· 3282 3282 if (!pdev->irq) { 3283 3283 dev_err(&dev->pdev->dev, "irq not set\n"); 3284 3284 kfree(dev); 3285 - dev = 0; 3285 + dev = NULL; 3286 3286 retval = -ENODEV; 3287 3287 goto finished; 3288 3288 } ··· 3290 3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { 3291 3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); 3292 3292 kfree(dev); 3293 - dev = 0; 3293 + dev = NULL; 3294 3294 retval = -EBUSY; 3295 3295 goto finished; 3296 3296 }
+38 -10
drivers/usb/gadget/atmel_usba_udc.c
··· 649 649 650 650 if (!ep->desc) { 651 651 spin_unlock_irqrestore(&udc->lock, flags); 652 - DBG(DBG_ERR, "ep_disable: %s not enabled\n", ep->ep.name); 652 + /* REVISIT because this driver disables endpoints in 653 + * reset_all_endpoints() before calling disconnect(), 654 + * most gadget drivers would trigger this non-error ... 655 + */ 656 + if (udc->gadget.speed != USB_SPEED_UNKNOWN) 657 + DBG(DBG_ERR, "ep_disable: %s not enabled\n", 658 + ep->ep.name); 653 659 return -EINVAL; 654 660 } 655 661 ep->desc = NULL; ··· 1038 1032 .release = nop_release, 1039 1033 }, 1040 1034 }, 1041 - 1042 - .lock = SPIN_LOCK_UNLOCKED, 1043 1035 }; 1044 1036 1045 1037 /* ··· 1056 1052 request_complete(ep, req, -ECONNRESET); 1057 1053 } 1058 1054 1055 + /* NOTE: normally, the next call to the gadget driver is in 1056 + * charge of disabling endpoints... usually disconnect(). 1057 + * The exception would be entering a high speed test mode. 1058 + * 1059 + * FIXME remove this code ... and retest thoroughly. 1060 + */ 1059 1061 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { 1060 1062 if (ep->desc) { 1061 1063 spin_unlock(&udc->lock); ··· 1229 1219 static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, 1230 1220 struct usb_ctrlrequest *crq) 1231 1221 { 1232 - int retval = 0;; 1222 + int retval = 0; 1233 1223 1234 1224 switch (crq->bRequest) { 1235 1225 case USB_REQ_GET_STATUS: { ··· 1703 1693 usba_writel(udc, INT_CLR, USBA_END_OF_RESET); 1704 1694 reset_all_endpoints(udc); 1705 1695 1696 + if (udc->gadget.speed != USB_SPEED_UNKNOWN 1697 + && udc->driver->disconnect) { 1698 + udc->gadget.speed = USB_SPEED_UNKNOWN; 1699 + spin_unlock(&udc->lock); 1700 + udc->driver->disconnect(&udc->gadget); 1701 + spin_lock(&udc->lock); 1702 + } 1703 + 1706 1704 if (status & USBA_HIGH_SPEED) { 1707 1705 DBG(DBG_BUS, "High-speed bus reset detected\n"); 1708 1706 udc->gadget.speed = USB_SPEED_HIGH; ··· 1734 1716 | USBA_DET_SUSPEND 1735 1717 | USBA_END_OF_RESUME)); 1736 1718 1719 + /* 1720 + * Unclear why we hit this irregularly, e.g. in usbtest, 1721 + * but it's clearly harmless... 1722 + */ 1737 1723 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED)) 1738 - dev_warn(&udc->pdev->dev, 1739 - "WARNING: EP0 configuration is invalid!\n"); 1724 + dev_dbg(&udc->pdev->dev, 1725 + "ODD: EP0 configuration is invalid!\n"); 1740 1726 } 1741 1727 1742 1728 spin_unlock(&udc->lock); ··· 1773 1751 reset_all_endpoints(udc); 1774 1752 toggle_bias(0); 1775 1753 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1776 - spin_unlock(&udc->lock); 1777 - udc->driver->disconnect(&udc->gadget); 1778 - spin_lock(&udc->lock); 1754 + if (udc->driver->disconnect) { 1755 + spin_unlock(&udc->lock); 1756 + udc->driver->disconnect(&udc->gadget); 1757 + spin_lock(&udc->lock); 1758 + } 1779 1759 } 1780 1760 udc->vbus_prev = vbus; 1781 1761 } ··· 1849 1825 1850 1826 if (!udc->pdev) 1851 1827 return -ENODEV; 1852 - if (driver != udc->driver) 1828 + if (driver != udc->driver || !driver->unbind) 1853 1829 return -EINVAL; 1854 1830 1855 1831 if (udc->vbus_pin != -1) ··· 1863 1839 /* This will also disable the DP pullup */ 1864 1840 toggle_bias(0); 1865 1841 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1842 + 1843 + if (udc->driver->disconnect) 1844 + udc->driver->disconnect(&udc->gadget); 1866 1845 1867 1846 driver->unbind(&udc->gadget); 1868 1847 udc->gadget.dev.driver = NULL; ··· 1906 1879 goto err_get_hclk; 1907 1880 } 1908 1881 1882 + spin_lock_init(&udc->lock); 1909 1883 udc->pdev = pdev; 1910 1884 udc->pclk = pclk; 1911 1885 udc->hclk = hclk;
+8 -9
drivers/usb/gadget/pxa27x_udc.c
··· 1546 1546 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); 1547 1547 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; 1548 1548 ep0_idle(dev); 1549 - strcpy(dev->dev->bus_id, ""); 1550 1549 1551 1550 /* PXA endpoints init */ 1552 1551 for (i = 0; i < NR_PXA_ENDPOINTS; i++) { ··· 1745 1746 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); 1746 1747 } 1747 1748 1748 - le16_to_cpus(&u.r.wValue); 1749 - le16_to_cpus(&u.r.wIndex); 1750 - le16_to_cpus(&u.r.wLength); 1751 - 1752 1749 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", 1753 1750 u.r.bRequestType, u.r.bRequest, 1754 - u.r.wValue, u.r.wIndex, u.r.wLength); 1751 + le16_to_cpu(u.r.wValue), le16_to_cpu(u.r.wIndex), 1752 + le16_to_cpu(u.r.wLength)); 1755 1753 if (unlikely(have_extrabytes)) 1756 1754 goto stall; 1757 1755 ··· 2292 2296 { 2293 2297 struct pxa_udc *udc = platform_get_drvdata(_dev); 2294 2298 2295 - udc_disable(udc); 2299 + if (udc_readl(udc, UDCCR) & UDCCR_UDE) 2300 + udc_disable(udc); 2296 2301 } 2297 2302 2298 2303 #ifdef CONFIG_PM ··· 2358 2361 * Upon exit from sleep mode and before clearing OTGPH, 2359 2362 * Software must configure the USB OTG pad, UDC, and UHC 2360 2363 * to the state they were in before entering sleep mode. 2361 - * 2362 - * Should be : PSSR |= PSSR_OTGPH; 2363 2364 */ 2365 + PSSR |= PSSR_OTGPH; 2364 2366 2365 2367 return 0; 2366 2368 } ··· 2383 2387 2384 2388 static int __init udc_init(void) 2385 2389 { 2390 + if (!cpu_is_pxa27x()) 2391 + return -ENODEV; 2392 + 2386 2393 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2387 2394 return platform_driver_probe(&udc_driver, pxa_udc_probe); 2388 2395 }
+8
drivers/usb/gadget/pxa27x_udc.h
··· 484 484 #define ep_warn(ep, fmt, arg...) \ 485 485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) 486 486 487 + /* 488 + * Cannot include pxa-regs.h, as register names are similar. 489 + * So PSSR is redefined here. This should be removed once UDC registers will 490 + * be gone from pxa-regs.h. 491 + */ 492 + #define PSSR __REG(0x40F00004) /* Power Manager Sleep Status */ 493 + #define PSSR_OTGPH (1 << 6) /* OTG Peripheral Hold */ 494 + 487 495 #endif /* __LINUX_USB_GADGET_PXA27X_H */
+332 -452
drivers/usb/gadget/serial.c
··· 14 14 * This software is distributed under the terms of the GNU General 15 15 * Public License ("GPL") as published by the Free Software Foundation, 16 16 * either version 2 of that License or (at your option) any later version. 17 - * 18 17 */ 19 18 20 19 #include <linux/kernel.h> ··· 32 33 /* Defines */ 33 34 34 35 #define GS_VERSION_STR "v2.2" 35 - #define GS_VERSION_NUM 0x0202 36 + #define GS_VERSION_NUM 0x2200 36 37 37 38 #define GS_LONG_NAME "Gadget Serial" 38 39 #define GS_SHORT_NAME "g_serial" ··· 40 41 #define GS_MAJOR 127 41 42 #define GS_MINOR_START 0 42 43 43 - #define GS_NUM_PORTS 16 44 + /* REVISIT only one port is supported for now; 45 + * see gs_{send,recv}_packet() ... no multiplexing, 46 + * and no support for multiple ACM devices. 47 + */ 48 + #define GS_NUM_PORTS 1 44 49 45 50 #define GS_NUM_CONFIGS 1 46 51 #define GS_NO_CONFIG_ID 0 ··· 68 65 69 66 #define GS_DEFAULT_USE_ACM 0 70 67 68 + /* 9600-8-N-1 ... matches init_termios.c_cflag and defaults 69 + * expected by "usbser.sys" on MS-Windows. 70 + */ 71 71 #define GS_DEFAULT_DTE_RATE 9600 72 72 #define GS_DEFAULT_DATA_BITS 8 73 73 #define GS_DEFAULT_PARITY USB_CDC_NO_PARITY ··· 113 107 #define GS_NOTIFY_MAXPACKET 8 114 108 115 109 116 - /* Structures */ 117 - 118 - struct gs_dev; 119 - 120 110 /* circular buffer */ 121 111 struct gs_buf { 122 112 unsigned int buf_size; 123 113 char *buf_buf; 124 114 char *buf_get; 125 115 char *buf_put; 126 - }; 127 - 128 - /* list of requests */ 129 - struct gs_req_entry { 130 - struct list_head re_entry; 131 - struct usb_request *re_req; 132 116 }; 133 117 134 118 /* the port structure holds info for each port, one for each minor number */ ··· 160 164 161 165 /* Functions */ 162 166 163 - /* module */ 164 - static int __init gs_module_init(void); 165 - static void __exit gs_module_exit(void); 166 - 167 - /* tty driver */ 168 - static int gs_open(struct tty_struct *tty, struct file *file); 169 - static void gs_close(struct tty_struct *tty, struct file *file); 170 - static int gs_write(struct tty_struct *tty, 171 - const unsigned char *buf, int count); 172 - static int gs_put_char(struct tty_struct *tty, unsigned char ch); 173 - static void gs_flush_chars(struct tty_struct *tty); 174 - static int gs_write_room(struct tty_struct *tty); 175 - static int gs_chars_in_buffer(struct tty_struct *tty); 176 - static void gs_throttle(struct tty_struct * tty); 177 - static void gs_unthrottle(struct tty_struct * tty); 178 - static void gs_break(struct tty_struct *tty, int break_state); 179 - static int gs_ioctl(struct tty_struct *tty, struct file *file, 180 - unsigned int cmd, unsigned long arg); 181 - static void gs_set_termios(struct tty_struct *tty, struct ktermios *old); 182 - 167 + /* tty driver internals */ 183 168 static int gs_send(struct gs_dev *dev); 184 169 static int gs_send_packet(struct gs_dev *dev, char *packet, 185 170 unsigned int size); ··· 169 192 static void gs_read_complete(struct usb_ep *ep, struct usb_request *req); 170 193 static void gs_write_complete(struct usb_ep *ep, struct usb_request *req); 171 194 172 - /* gadget driver */ 173 - static int gs_bind(struct usb_gadget *gadget); 174 - static void gs_unbind(struct usb_gadget *gadget); 175 - static int gs_setup(struct usb_gadget *gadget, 176 - const struct usb_ctrlrequest *ctrl); 177 - static int gs_setup_standard(struct usb_gadget *gadget, 178 - const struct usb_ctrlrequest *ctrl); 179 - static int gs_setup_class(struct usb_gadget *gadget, 180 - const struct usb_ctrlrequest *ctrl); 181 - static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req); 182 - static void gs_setup_complete_set_line_coding(struct usb_ep *ep, 183 - struct usb_request *req); 184 - static void gs_disconnect(struct usb_gadget *gadget); 195 + /* gadget driver internals */ 185 196 static int gs_set_config(struct gs_dev *dev, unsigned config); 186 197 static void gs_reset_config(struct gs_dev *dev); 187 198 static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, ··· 178 213 static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, 179 214 gfp_t kmalloc_flags); 180 215 static void gs_free_req(struct usb_ep *ep, struct usb_request *req); 181 - 182 - static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, 183 - gfp_t kmalloc_flags); 184 - static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); 185 216 186 217 static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); 187 218 static void gs_free_ports(struct gs_dev *dev); ··· 193 232 static unsigned int gs_buf_get(struct gs_buf *gb, char *buf, 194 233 unsigned int count); 195 234 196 - /* external functions */ 197 - extern int net2280_set_fifo_mode(struct usb_gadget *gadget, int mode); 198 - 199 235 200 236 /* Globals */ 201 237 202 238 static struct gs_dev *gs_device; 203 239 204 - static const char *EP_IN_NAME; 205 - static const char *EP_OUT_NAME; 206 - static const char *EP_NOTIFY_NAME; 207 - 208 240 static struct mutex gs_open_close_lock[GS_NUM_PORTS]; 209 241 210 - static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE; 211 - static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE; 212 242 213 - static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE; 214 - 215 - static unsigned int use_acm = GS_DEFAULT_USE_ACM; 216 - 217 - 218 - /* tty driver struct */ 219 - static const struct tty_operations gs_tty_ops = { 220 - .open = gs_open, 221 - .close = gs_close, 222 - .write = gs_write, 223 - .put_char = gs_put_char, 224 - .flush_chars = gs_flush_chars, 225 - .write_room = gs_write_room, 226 - .ioctl = gs_ioctl, 227 - .set_termios = gs_set_termios, 228 - .throttle = gs_throttle, 229 - .unthrottle = gs_unthrottle, 230 - .break_ctl = gs_break, 231 - .chars_in_buffer = gs_chars_in_buffer, 232 - }; 233 - static struct tty_driver *gs_tty_driver; 234 - 235 - /* gadget driver struct */ 236 - static struct usb_gadget_driver gs_gadget_driver = { 237 - #ifdef CONFIG_USB_GADGET_DUALSPEED 238 - .speed = USB_SPEED_HIGH, 239 - #else 240 - .speed = USB_SPEED_FULL, 241 - #endif /* CONFIG_USB_GADGET_DUALSPEED */ 242 - .function = GS_LONG_NAME, 243 - .bind = gs_bind, 244 - .unbind = gs_unbind, 245 - .setup = gs_setup, 246 - .disconnect = gs_disconnect, 247 - .driver = { 248 - .name = GS_SHORT_NAME, 249 - }, 250 - }; 251 - 243 + /*-------------------------------------------------------------------------*/ 252 244 253 245 /* USB descriptors */ 254 246 ··· 218 304 static struct usb_string gs_strings[] = { 219 305 { GS_MANUFACTURER_STR_ID, manufacturer }, 220 306 { GS_PRODUCT_STR_ID, GS_LONG_NAME }, 221 - { GS_SERIAL_STR_ID, "0" }, 222 307 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" }, 223 308 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" }, 224 309 { GS_CONTROL_STR_ID, "Gadget Serial Control" }, ··· 240 327 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID), 241 328 .iManufacturer = GS_MANUFACTURER_STR_ID, 242 329 .iProduct = GS_PRODUCT_STR_ID, 243 - .iSerialNumber = GS_SERIAL_STR_ID, 244 330 .bNumConfigurations = GS_NUM_CONFIGS, 245 331 }; 246 332 ··· 276 364 .bDescriptorType = USB_DT_INTERFACE, 277 365 .bInterfaceNumber = GS_BULK_INTERFACE_ID, 278 366 .bNumEndpoints = 2, 279 - .bInterfaceClass = USB_CLASS_CDC_DATA, 367 + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, 280 368 .bInterfaceSubClass = 0, 281 369 .bInterfaceProtocol = 0, 282 370 .iInterface = GS_DATA_STR_ID, ··· 433 521 }; 434 522 435 523 524 + /*-------------------------------------------------------------------------*/ 525 + 436 526 /* Module */ 437 527 MODULE_DESCRIPTION(GS_LONG_NAME); 438 528 MODULE_AUTHOR("Al Borchers"); ··· 445 531 MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on"); 446 532 #endif 447 533 534 + static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE; 448 535 module_param(read_q_size, uint, S_IRUGO); 449 536 MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32"); 450 537 538 + static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE; 451 539 module_param(write_q_size, uint, S_IRUGO); 452 540 MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32"); 453 541 542 + static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE; 454 543 module_param(write_buf_size, uint, S_IRUGO); 455 544 MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192"); 456 545 546 + static unsigned int use_acm = GS_DEFAULT_USE_ACM; 457 547 module_param(use_acm, uint, S_IRUGO); 458 548 MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no"); 459 549 460 - module_init(gs_module_init); 461 - module_exit(gs_module_exit); 462 - 463 - /* 464 - * gs_module_init 465 - * 466 - * Register as a USB gadget driver and a tty driver. 467 - */ 468 - static int __init gs_module_init(void) 469 - { 470 - int i; 471 - int retval; 472 - 473 - retval = usb_gadget_register_driver(&gs_gadget_driver); 474 - if (retval) { 475 - pr_err("gs_module_init: cannot register gadget driver, " 476 - "ret=%d\n", retval); 477 - return retval; 478 - } 479 - 480 - gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS); 481 - if (!gs_tty_driver) 482 - return -ENOMEM; 483 - gs_tty_driver->owner = THIS_MODULE; 484 - gs_tty_driver->driver_name = GS_SHORT_NAME; 485 - gs_tty_driver->name = "ttygs"; 486 - gs_tty_driver->major = GS_MAJOR; 487 - gs_tty_driver->minor_start = GS_MINOR_START; 488 - gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 489 - gs_tty_driver->subtype = SERIAL_TYPE_NORMAL; 490 - gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 491 - gs_tty_driver->init_termios = tty_std_termios; 492 - gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 493 - tty_set_operations(gs_tty_driver, &gs_tty_ops); 494 - 495 - for (i=0; i < GS_NUM_PORTS; i++) 496 - mutex_init(&gs_open_close_lock[i]); 497 - 498 - retval = tty_register_driver(gs_tty_driver); 499 - if (retval) { 500 - usb_gadget_unregister_driver(&gs_gadget_driver); 501 - put_tty_driver(gs_tty_driver); 502 - pr_err("gs_module_init: cannot register tty driver, " 503 - "ret=%d\n", retval); 504 - return retval; 505 - } 506 - 507 - pr_info("gs_module_init: %s %s loaded\n", 508 - GS_LONG_NAME, GS_VERSION_STR); 509 - return 0; 510 - } 511 - 512 - /* 513 - * gs_module_exit 514 - * 515 - * Unregister as a tty driver and a USB gadget driver. 516 - */ 517 - static void __exit gs_module_exit(void) 518 - { 519 - tty_unregister_driver(gs_tty_driver); 520 - put_tty_driver(gs_tty_driver); 521 - usb_gadget_unregister_driver(&gs_gadget_driver); 522 - 523 - pr_info("gs_module_exit: %s %s unloaded\n", 524 - GS_LONG_NAME, GS_VERSION_STR); 525 - } 550 + /*-------------------------------------------------------------------------*/ 526 551 527 552 /* TTY Driver */ 528 553 ··· 606 753 * gs_close 607 754 */ 608 755 609 - #define GS_WRITE_FINISHED_EVENT_SAFELY(p) \ 610 - ({ \ 611 - int cond; \ 612 - \ 613 - spin_lock_irq(&(p)->port_lock); \ 614 - cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); \ 615 - spin_unlock_irq(&(p)->port_lock); \ 616 - cond; \ 617 - }) 756 + static int gs_write_finished_event_safely(struct gs_port *p) 757 + { 758 + int cond; 759 + 760 + spin_lock_irq(&(p)->port_lock); 761 + cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); 762 + spin_unlock_irq(&(p)->port_lock); 763 + return cond; 764 + } 618 765 619 766 static void gs_close(struct tty_struct *tty, struct file *file) 620 767 { ··· 660 807 if (gs_buf_data_avail(port->port_write_buf) > 0) { 661 808 spin_unlock_irq(&port->port_lock); 662 809 wait_event_interruptible_timeout(port->port_write_wait, 663 - GS_WRITE_FINISHED_EVENT_SAFELY(port), 810 + gs_write_finished_event_safely(port), 664 811 GS_CLOSE_TIMEOUT * HZ); 665 812 spin_lock_irq(&port->port_lock); 666 813 } ··· 918 1065 { 919 1066 } 920 1067 1068 + static const struct tty_operations gs_tty_ops = { 1069 + .open = gs_open, 1070 + .close = gs_close, 1071 + .write = gs_write, 1072 + .put_char = gs_put_char, 1073 + .flush_chars = gs_flush_chars, 1074 + .write_room = gs_write_room, 1075 + .ioctl = gs_ioctl, 1076 + .set_termios = gs_set_termios, 1077 + .throttle = gs_throttle, 1078 + .unthrottle = gs_unthrottle, 1079 + .break_ctl = gs_break, 1080 + .chars_in_buffer = gs_chars_in_buffer, 1081 + }; 1082 + 1083 + /*-------------------------------------------------------------------------*/ 1084 + 921 1085 /* 922 1086 * gs_send 923 1087 * ··· 950 1080 unsigned long flags; 951 1081 struct usb_ep *ep; 952 1082 struct usb_request *req; 953 - struct gs_req_entry *req_entry; 954 1083 955 1084 if (dev == NULL) { 956 1085 pr_err("gs_send: NULL device pointer\n"); ··· 962 1093 963 1094 while(!list_empty(&dev->dev_req_list)) { 964 1095 965 - req_entry = list_entry(dev->dev_req_list.next, 966 - struct gs_req_entry, re_entry); 967 - 968 - req = req_entry->re_req; 1096 + req = list_entry(dev->dev_req_list.next, 1097 + struct usb_request, list); 969 1098 970 1099 len = gs_send_packet(dev, req->buf, ep->maxpacket); 971 1100 ··· 973 1106 *((unsigned char *)req->buf), 974 1107 *((unsigned char *)req->buf+1), 975 1108 *((unsigned char *)req->buf+2)); 976 - list_del(&req_entry->re_entry); 1109 + list_del(&req->list); 977 1110 req->length = len; 978 1111 spin_unlock_irqrestore(&dev->dev_lock, flags); 979 1112 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { ··· 1156 1289 static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) 1157 1290 { 1158 1291 struct gs_dev *dev = ep->driver_data; 1159 - struct gs_req_entry *gs_req = req->context; 1160 1292 1161 1293 if (dev == NULL) { 1162 1294 pr_err("gs_write_complete: NULL device pointer\n"); ··· 1166 1300 case 0: 1167 1301 /* normal completion */ 1168 1302 requeue: 1169 - if (gs_req == NULL) { 1170 - pr_err("gs_write_complete: NULL request pointer\n"); 1171 - return; 1172 - } 1173 - 1174 1303 spin_lock(&dev->dev_lock); 1175 - list_add(&gs_req->re_entry, &dev->dev_req_list); 1304 + list_add(&req->list, &dev->dev_req_list); 1176 1305 spin_unlock(&dev->dev_lock); 1177 1306 1178 1307 gs_send(dev); ··· 1189 1328 } 1190 1329 } 1191 1330 1331 + /*-------------------------------------------------------------------------*/ 1332 + 1192 1333 /* Gadget Driver */ 1334 + 1335 + /* 1336 + * gs_unbind 1337 + * 1338 + * Called on module unload. Frees the control request and device 1339 + * structure. 1340 + */ 1341 + static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget) 1342 + { 1343 + struct gs_dev *dev = get_gadget_data(gadget); 1344 + 1345 + gs_device = NULL; 1346 + 1347 + /* read/write requests already freed, only control request remains */ 1348 + if (dev != NULL) { 1349 + if (dev->dev_ctrl_req != NULL) { 1350 + gs_free_req(gadget->ep0, dev->dev_ctrl_req); 1351 + dev->dev_ctrl_req = NULL; 1352 + } 1353 + gs_reset_config(dev); 1354 + gs_free_ports(dev); 1355 + kfree(dev); 1356 + set_gadget_data(gadget, NULL); 1357 + } 1358 + 1359 + pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME, 1360 + GS_VERSION_STR); 1361 + } 1193 1362 1194 1363 /* 1195 1364 * gs_bind ··· 1253 1362 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099); 1254 1363 } 1255 1364 1365 + dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); 1366 + if (dev == NULL) 1367 + return -ENOMEM; 1368 + 1256 1369 usb_ep_autoconfig_reset(gadget); 1257 1370 1258 1371 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc); 1259 1372 if (!ep) 1260 1373 goto autoconf_fail; 1261 - EP_IN_NAME = ep->name; 1262 - ep->driver_data = ep; /* claim the endpoint */ 1374 + dev->dev_in_ep = ep; 1375 + ep->driver_data = dev; /* claim the endpoint */ 1263 1376 1264 1377 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc); 1265 1378 if (!ep) 1266 1379 goto autoconf_fail; 1267 - EP_OUT_NAME = ep->name; 1268 - ep->driver_data = ep; /* claim the endpoint */ 1380 + dev->dev_out_ep = ep; 1381 + ep->driver_data = dev; /* claim the endpoint */ 1269 1382 1270 1383 if (use_acm) { 1271 1384 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); ··· 1279 1384 } 1280 1385 gs_device_desc.idProduct = __constant_cpu_to_le16( 1281 1386 GS_CDC_PRODUCT_ID), 1282 - EP_NOTIFY_NAME = ep->name; 1283 - ep->driver_data = ep; /* claim the endpoint */ 1387 + dev->dev_notify_ep = ep; 1388 + ep->driver_data = dev; /* claim the endpoint */ 1284 1389 } 1285 1390 1286 1391 gs_device_desc.bDeviceClass = use_acm ··· 1310 1415 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1311 1416 } 1312 1417 1313 - gs_device = dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); 1314 - if (dev == NULL) 1315 - return -ENOMEM; 1418 + gs_device = dev; 1316 1419 1317 1420 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", 1318 1421 init_utsname()->sysname, init_utsname()->release, ··· 1334 1441 gs_unbind(gadget); 1335 1442 return -ENOMEM; 1336 1443 } 1337 - dev->dev_ctrl_req->complete = gs_setup_complete; 1338 - 1339 1444 gadget->ep0->driver_data = dev; 1340 1445 1341 1446 pr_info("gs_bind: %s %s bound\n", ··· 1342 1451 return 0; 1343 1452 1344 1453 autoconf_fail: 1454 + kfree(dev); 1345 1455 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); 1346 1456 return -ENODEV; 1347 - } 1348 - 1349 - /* 1350 - * gs_unbind 1351 - * 1352 - * Called on module unload. Frees the control request and device 1353 - * structure. 1354 - */ 1355 - static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget) 1356 - { 1357 - struct gs_dev *dev = get_gadget_data(gadget); 1358 - 1359 - gs_device = NULL; 1360 - 1361 - /* read/write requests already freed, only control request remains */ 1362 - if (dev != NULL) { 1363 - if (dev->dev_ctrl_req != NULL) { 1364 - gs_free_req(gadget->ep0, dev->dev_ctrl_req); 1365 - dev->dev_ctrl_req = NULL; 1366 - } 1367 - gs_free_ports(dev); 1368 - if (dev->dev_notify_ep) 1369 - usb_ep_disable(dev->dev_notify_ep); 1370 - if (dev->dev_in_ep) 1371 - usb_ep_disable(dev->dev_in_ep); 1372 - if (dev->dev_out_ep) 1373 - usb_ep_disable(dev->dev_out_ep); 1374 - kfree(dev); 1375 - set_gadget_data(gadget, NULL); 1376 - } 1377 - 1378 - pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME, 1379 - GS_VERSION_STR); 1380 - } 1381 - 1382 - /* 1383 - * gs_setup 1384 - * 1385 - * Implements all the control endpoint functionality that's not 1386 - * handled in hardware or the hardware driver. 1387 - * 1388 - * Returns the size of the data sent to the host, or a negative 1389 - * error number. 1390 - */ 1391 - static int gs_setup(struct usb_gadget *gadget, 1392 - const struct usb_ctrlrequest *ctrl) 1393 - { 1394 - int ret = -EOPNOTSUPP; 1395 - struct gs_dev *dev = get_gadget_data(gadget); 1396 - struct usb_request *req = dev->dev_ctrl_req; 1397 - u16 wIndex = le16_to_cpu(ctrl->wIndex); 1398 - u16 wValue = le16_to_cpu(ctrl->wValue); 1399 - u16 wLength = le16_to_cpu(ctrl->wLength); 1400 - 1401 - req->complete = gs_setup_complete; 1402 - 1403 - switch (ctrl->bRequestType & USB_TYPE_MASK) { 1404 - case USB_TYPE_STANDARD: 1405 - ret = gs_setup_standard(gadget,ctrl); 1406 - break; 1407 - 1408 - case USB_TYPE_CLASS: 1409 - ret = gs_setup_class(gadget,ctrl); 1410 - break; 1411 - 1412 - default: 1413 - pr_err("gs_setup: unknown request, type=%02x, request=%02x, " 1414 - "value=%04x, index=%04x, length=%d\n", 1415 - ctrl->bRequestType, ctrl->bRequest, 1416 - wValue, wIndex, wLength); 1417 - break; 1418 - } 1419 - 1420 - /* respond with data transfer before status phase? */ 1421 - if (ret >= 0) { 1422 - req->length = ret; 1423 - req->zero = ret < wLength 1424 - && (ret % gadget->ep0->maxpacket) == 0; 1425 - ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); 1426 - if (ret < 0) { 1427 - pr_err("gs_setup: cannot queue response, ret=%d\n", 1428 - ret); 1429 - req->status = 0; 1430 - gs_setup_complete(gadget->ep0, req); 1431 - } 1432 - } 1433 - 1434 - /* device either stalls (ret < 0) or reports success */ 1435 - return ret; 1436 1457 } 1437 1458 1438 1459 static int gs_setup_standard(struct usb_gadget *gadget, ··· 1476 1673 return ret; 1477 1674 } 1478 1675 1676 + static void gs_setup_complete_set_line_coding(struct usb_ep *ep, 1677 + struct usb_request *req) 1678 + { 1679 + struct gs_dev *dev = ep->driver_data; 1680 + struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ 1681 + 1682 + switch (req->status) { 1683 + case 0: 1684 + /* normal completion */ 1685 + if (req->actual != sizeof(port->port_line_coding)) 1686 + usb_ep_set_halt(ep); 1687 + else if (port) { 1688 + struct usb_cdc_line_coding *value = req->buf; 1689 + 1690 + /* REVISIT: we currently just remember this data. 1691 + * If we change that, (a) validate it first, then 1692 + * (b) update whatever hardware needs updating. 1693 + */ 1694 + spin_lock(&port->port_lock); 1695 + port->port_line_coding = *value; 1696 + spin_unlock(&port->port_lock); 1697 + } 1698 + break; 1699 + 1700 + case -ESHUTDOWN: 1701 + /* disconnect */ 1702 + gs_free_req(ep, req); 1703 + break; 1704 + 1705 + default: 1706 + /* unexpected */ 1707 + break; 1708 + } 1709 + return; 1710 + } 1711 + 1479 1712 static int gs_setup_class(struct usb_gadget *gadget, 1480 1713 const struct usb_ctrlrequest *ctrl) 1481 1714 { ··· 1573 1734 return ret; 1574 1735 } 1575 1736 1576 - static void gs_setup_complete_set_line_coding(struct usb_ep *ep, 1577 - struct usb_request *req) 1578 - { 1579 - struct gs_dev *dev = ep->driver_data; 1580 - struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ 1581 - 1582 - switch (req->status) { 1583 - case 0: 1584 - /* normal completion */ 1585 - if (req->actual != sizeof(port->port_line_coding)) 1586 - usb_ep_set_halt(ep); 1587 - else if (port) { 1588 - struct usb_cdc_line_coding *value = req->buf; 1589 - 1590 - /* REVISIT: we currently just remember this data. 1591 - * If we change that, (a) validate it first, then 1592 - * (b) update whatever hardware needs updating. 1593 - */ 1594 - spin_lock(&port->port_lock); 1595 - port->port_line_coding = *value; 1596 - spin_unlock(&port->port_lock); 1597 - } 1598 - break; 1599 - 1600 - case -ESHUTDOWN: 1601 - /* disconnect */ 1602 - gs_free_req(ep, req); 1603 - break; 1604 - 1605 - default: 1606 - /* unexpected */ 1607 - break; 1608 - } 1609 - return; 1610 - } 1611 - 1612 1737 /* 1613 1738 * gs_setup_complete 1614 1739 */ ··· 1583 1780 "actual=%d, length=%d\n", 1584 1781 req->status, req->actual, req->length); 1585 1782 } 1783 + } 1784 + 1785 + /* 1786 + * gs_setup 1787 + * 1788 + * Implements all the control endpoint functionality that's not 1789 + * handled in hardware or the hardware driver. 1790 + * 1791 + * Returns the size of the data sent to the host, or a negative 1792 + * error number. 1793 + */ 1794 + static int gs_setup(struct usb_gadget *gadget, 1795 + const struct usb_ctrlrequest *ctrl) 1796 + { 1797 + int ret = -EOPNOTSUPP; 1798 + struct gs_dev *dev = get_gadget_data(gadget); 1799 + struct usb_request *req = dev->dev_ctrl_req; 1800 + u16 wIndex = le16_to_cpu(ctrl->wIndex); 1801 + u16 wValue = le16_to_cpu(ctrl->wValue); 1802 + u16 wLength = le16_to_cpu(ctrl->wLength); 1803 + 1804 + req->complete = gs_setup_complete; 1805 + 1806 + switch (ctrl->bRequestType & USB_TYPE_MASK) { 1807 + case USB_TYPE_STANDARD: 1808 + ret = gs_setup_standard(gadget, ctrl); 1809 + break; 1810 + 1811 + case USB_TYPE_CLASS: 1812 + ret = gs_setup_class(gadget, ctrl); 1813 + break; 1814 + 1815 + default: 1816 + pr_err("gs_setup: unknown request, type=%02x, request=%02x, " 1817 + "value=%04x, index=%04x, length=%d\n", 1818 + ctrl->bRequestType, ctrl->bRequest, 1819 + wValue, wIndex, wLength); 1820 + break; 1821 + } 1822 + 1823 + /* respond with data transfer before status phase? */ 1824 + if (ret >= 0) { 1825 + req->length = ret; 1826 + req->zero = ret < wLength 1827 + && (ret % gadget->ep0->maxpacket) == 0; 1828 + ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC); 1829 + if (ret < 0) { 1830 + pr_err("gs_setup: cannot queue response, ret=%d\n", 1831 + ret); 1832 + req->status = 0; 1833 + gs_setup_complete(gadget->ep0, req); 1834 + } 1835 + } 1836 + 1837 + /* device either stalls (ret < 0) or reports success */ 1838 + return ret; 1586 1839 } 1587 1840 1588 1841 /* ··· 1670 1811 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); 1671 1812 } 1672 1813 1814 + static struct usb_gadget_driver gs_gadget_driver = { 1815 + #ifdef CONFIG_USB_GADGET_DUALSPEED 1816 + .speed = USB_SPEED_HIGH, 1817 + #else 1818 + .speed = USB_SPEED_FULL, 1819 + #endif /* CONFIG_USB_GADGET_DUALSPEED */ 1820 + .function = GS_LONG_NAME, 1821 + .bind = gs_bind, 1822 + .unbind = gs_unbind, 1823 + .setup = gs_setup, 1824 + .disconnect = gs_disconnect, 1825 + .driver = { 1826 + .name = GS_SHORT_NAME, 1827 + .owner = THIS_MODULE, 1828 + }, 1829 + }; 1830 + 1673 1831 /* 1674 1832 * gs_set_config 1675 1833 * ··· 1702 1826 int ret = 0; 1703 1827 struct usb_gadget *gadget = dev->dev_gadget; 1704 1828 struct usb_ep *ep; 1705 - struct usb_endpoint_descriptor *ep_desc; 1829 + struct usb_endpoint_descriptor *out, *in, *notify; 1706 1830 struct usb_request *req; 1707 - struct gs_req_entry *req_entry; 1708 1831 1709 1832 if (dev == NULL) { 1710 1833 pr_err("gs_set_config: NULL device pointer\n"); ··· 1721 1846 case GS_BULK_CONFIG_ID: 1722 1847 if (use_acm) 1723 1848 return -EINVAL; 1724 - /* device specific optimizations */ 1725 - if (gadget_is_net2280(gadget)) 1726 - net2280_set_fifo_mode(gadget, 1); 1727 1849 break; 1728 1850 case GS_ACM_CONFIG_ID: 1729 1851 if (!use_acm) 1730 1852 return -EINVAL; 1731 - /* device specific optimizations */ 1732 - if (gadget_is_net2280(gadget)) 1733 - net2280_set_fifo_mode(gadget, 1); 1734 1853 break; 1735 1854 default: 1736 1855 return -EINVAL; 1737 1856 } 1738 1857 1739 - dev->dev_config = config; 1740 - 1741 - gadget_for_each_ep(ep, gadget) { 1742 - 1743 - if (EP_NOTIFY_NAME 1744 - && strcmp(ep->name, EP_NOTIFY_NAME) == 0) { 1745 - ep_desc = choose_ep_desc(gadget, 1858 + in = choose_ep_desc(gadget, 1859 + &gs_highspeed_in_desc, 1860 + &gs_fullspeed_in_desc); 1861 + out = choose_ep_desc(gadget, 1862 + &gs_highspeed_out_desc, 1863 + &gs_fullspeed_out_desc); 1864 + notify = dev->dev_notify_ep 1865 + ? choose_ep_desc(gadget, 1746 1866 &gs_highspeed_notify_desc, 1747 - &gs_fullspeed_notify_desc); 1748 - ret = usb_ep_enable(ep,ep_desc); 1749 - if (ret == 0) { 1750 - ep->driver_data = dev; 1751 - dev->dev_notify_ep = ep; 1752 - dev->dev_notify_ep_desc = ep_desc; 1753 - } else { 1754 - pr_err("gs_set_config: cannot enable NOTIFY " 1755 - "endpoint %s, ret=%d\n", 1756 - ep->name, ret); 1757 - goto exit_reset_config; 1758 - } 1759 - } 1867 + &gs_fullspeed_notify_desc) 1868 + : NULL; 1760 1869 1761 - else if (strcmp(ep->name, EP_IN_NAME) == 0) { 1762 - ep_desc = choose_ep_desc(gadget, 1763 - &gs_highspeed_in_desc, 1764 - &gs_fullspeed_in_desc); 1765 - ret = usb_ep_enable(ep,ep_desc); 1766 - if (ret == 0) { 1767 - ep->driver_data = dev; 1768 - dev->dev_in_ep = ep; 1769 - dev->dev_in_ep_desc = ep_desc; 1770 - } else { 1771 - pr_err("gs_set_config: cannot enable IN " 1772 - "endpoint %s, ret=%d\n", 1773 - ep->name, ret); 1774 - goto exit_reset_config; 1775 - } 1776 - } 1777 - 1778 - else if (strcmp(ep->name, EP_OUT_NAME) == 0) { 1779 - ep_desc = choose_ep_desc(gadget, 1780 - &gs_highspeed_out_desc, 1781 - &gs_fullspeed_out_desc); 1782 - ret = usb_ep_enable(ep,ep_desc); 1783 - if (ret == 0) { 1784 - ep->driver_data = dev; 1785 - dev->dev_out_ep = ep; 1786 - dev->dev_out_ep_desc = ep_desc; 1787 - } else { 1788 - pr_err("gs_set_config: cannot enable OUT " 1789 - "endpoint %s, ret=%d\n", 1790 - ep->name, ret); 1791 - goto exit_reset_config; 1792 - } 1793 - } 1794 - 1870 + ret = usb_ep_enable(dev->dev_in_ep, in); 1871 + if (ret == 0) { 1872 + dev->dev_in_ep_desc = in; 1873 + } else { 1874 + pr_debug("%s: cannot enable %s %s, ret=%d\n", 1875 + __func__, "IN", dev->dev_in_ep->name, ret); 1876 + return ret; 1795 1877 } 1796 1878 1797 - if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL 1798 - || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { 1799 - pr_err("gs_set_config: cannot find endpoints\n"); 1800 - ret = -ENODEV; 1801 - goto exit_reset_config; 1879 + ret = usb_ep_enable(dev->dev_out_ep, out); 1880 + if (ret == 0) { 1881 + dev->dev_out_ep_desc = out; 1882 + } else { 1883 + pr_debug("%s: cannot enable %s %s, ret=%d\n", 1884 + __func__, "OUT", dev->dev_out_ep->name, ret); 1885 + fail0: 1886 + usb_ep_disable(dev->dev_in_ep); 1887 + return ret; 1802 1888 } 1889 + 1890 + if (notify) { 1891 + ret = usb_ep_enable(dev->dev_notify_ep, notify); 1892 + if (ret == 0) { 1893 + dev->dev_notify_ep_desc = notify; 1894 + } else { 1895 + pr_debug("%s: cannot enable %s %s, ret=%d\n", 1896 + __func__, "NOTIFY", 1897 + dev->dev_notify_ep->name, ret); 1898 + usb_ep_disable(dev->dev_out_ep); 1899 + goto fail0; 1900 + } 1901 + } 1902 + 1903 + dev->dev_config = config; 1803 1904 1804 1905 /* allocate and queue read requests */ 1805 1906 ep = dev->dev_out_ep; ··· 1797 1946 /* allocate write requests, and put on free list */ 1798 1947 ep = dev->dev_in_ep; 1799 1948 for (i=0; i<write_q_size; i++) { 1800 - if ((req_entry=gs_alloc_req_entry(ep, ep->maxpacket, GFP_ATOMIC))) { 1801 - req_entry->re_req->complete = gs_write_complete; 1802 - list_add(&req_entry->re_entry, &dev->dev_req_list); 1949 + req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC); 1950 + if (req) { 1951 + req->complete = gs_write_complete; 1952 + list_add(&req->list, &dev->dev_req_list); 1803 1953 } else { 1804 1954 pr_err("gs_set_config: cannot allocate " 1805 1955 "write requests\n"); ··· 1838 1986 */ 1839 1987 static void gs_reset_config(struct gs_dev *dev) 1840 1988 { 1841 - struct gs_req_entry *req_entry; 1989 + struct usb_request *req; 1842 1990 1843 1991 if (dev == NULL) { 1844 1992 pr_err("gs_reset_config: NULL device pointer\n"); ··· 1852 2000 1853 2001 /* free write requests on the free list */ 1854 2002 while(!list_empty(&dev->dev_req_list)) { 1855 - req_entry = list_entry(dev->dev_req_list.next, 1856 - struct gs_req_entry, re_entry); 1857 - list_del(&req_entry->re_entry); 1858 - gs_free_req_entry(dev->dev_in_ep, req_entry); 2003 + req = list_entry(dev->dev_req_list.next, 2004 + struct usb_request, list); 2005 + list_del(&req->list); 2006 + gs_free_req(dev->dev_in_ep, req); 1859 2007 } 1860 2008 1861 2009 /* disable endpoints, forcing completion of pending i/o; */ 1862 2010 /* completion handlers free their requests in this case */ 1863 - if (dev->dev_notify_ep) { 2011 + if (dev->dev_notify_ep) 1864 2012 usb_ep_disable(dev->dev_notify_ep); 1865 - dev->dev_notify_ep = NULL; 1866 - } 1867 - if (dev->dev_in_ep) { 1868 - usb_ep_disable(dev->dev_in_ep); 1869 - dev->dev_in_ep = NULL; 1870 - } 1871 - if (dev->dev_out_ep) { 1872 - usb_ep_disable(dev->dev_out_ep); 1873 - dev->dev_out_ep = NULL; 1874 - } 2013 + usb_ep_disable(dev->dev_in_ep); 2014 + usb_ep_disable(dev->dev_out_ep); 1875 2015 } 1876 2016 1877 2017 /* ··· 1957 2113 } 1958 2114 1959 2115 /* 1960 - * gs_alloc_req_entry 1961 - * 1962 - * Allocates a request and its buffer, using the given 1963 - * endpoint, buffer len, and kmalloc flags. 1964 - */ 1965 - static struct gs_req_entry * 1966 - gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags) 1967 - { 1968 - struct gs_req_entry *req; 1969 - 1970 - req = kmalloc(sizeof(struct gs_req_entry), kmalloc_flags); 1971 - if (req == NULL) 1972 - return NULL; 1973 - 1974 - req->re_req = gs_alloc_req(ep, len, kmalloc_flags); 1975 - if (req->re_req == NULL) { 1976 - kfree(req); 1977 - return NULL; 1978 - } 1979 - 1980 - req->re_req->context = req; 1981 - 1982 - return req; 1983 - } 1984 - 1985 - /* 1986 - * gs_free_req_entry 1987 - * 1988 - * Frees a request and its buffer. 1989 - */ 1990 - static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req) 1991 - { 1992 - if (ep != NULL && req != NULL) { 1993 - if (req->re_req != NULL) 1994 - gs_free_req(ep, req->re_req); 1995 - kfree(req); 1996 - } 1997 - } 1998 - 1999 - /* 2000 2116 * gs_alloc_ports 2001 2117 * 2002 2118 * Allocate all ports and set the gs_dev struct to point to them. ··· 2036 2232 } 2037 2233 } 2038 2234 } 2235 + 2236 + /*-------------------------------------------------------------------------*/ 2039 2237 2040 2238 /* Circular Buffer */ 2041 2239 ··· 2199 2393 2200 2394 return count; 2201 2395 } 2396 + 2397 + /*-------------------------------------------------------------------------*/ 2398 + 2399 + static struct tty_driver *gs_tty_driver; 2400 + 2401 + /* 2402 + * gs_module_init 2403 + * 2404 + * Register as a USB gadget driver and a tty driver. 2405 + */ 2406 + static int __init gs_module_init(void) 2407 + { 2408 + int i; 2409 + int retval; 2410 + 2411 + retval = usb_gadget_register_driver(&gs_gadget_driver); 2412 + if (retval) { 2413 + pr_err("gs_module_init: cannot register gadget driver, " 2414 + "ret=%d\n", retval); 2415 + return retval; 2416 + } 2417 + 2418 + gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS); 2419 + if (!gs_tty_driver) 2420 + return -ENOMEM; 2421 + gs_tty_driver->owner = THIS_MODULE; 2422 + gs_tty_driver->driver_name = GS_SHORT_NAME; 2423 + gs_tty_driver->name = "ttygs"; 2424 + gs_tty_driver->major = GS_MAJOR; 2425 + gs_tty_driver->minor_start = GS_MINOR_START; 2426 + gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 2427 + gs_tty_driver->subtype = SERIAL_TYPE_NORMAL; 2428 + gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 2429 + gs_tty_driver->init_termios = tty_std_termios; 2430 + /* must match GS_DEFAULT_DTE_RATE and friends */ 2431 + gs_tty_driver->init_termios.c_cflag = 2432 + B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2433 + gs_tty_driver->init_termios.c_ispeed = GS_DEFAULT_DTE_RATE; 2434 + gs_tty_driver->init_termios.c_ospeed = GS_DEFAULT_DTE_RATE; 2435 + tty_set_operations(gs_tty_driver, &gs_tty_ops); 2436 + 2437 + for (i = 0; i < GS_NUM_PORTS; i++) 2438 + mutex_init(&gs_open_close_lock[i]); 2439 + 2440 + retval = tty_register_driver(gs_tty_driver); 2441 + if (retval) { 2442 + usb_gadget_unregister_driver(&gs_gadget_driver); 2443 + put_tty_driver(gs_tty_driver); 2444 + pr_err("gs_module_init: cannot register tty driver, " 2445 + "ret=%d\n", retval); 2446 + return retval; 2447 + } 2448 + 2449 + pr_info("gs_module_init: %s %s loaded\n", 2450 + GS_LONG_NAME, GS_VERSION_STR); 2451 + return 0; 2452 + } 2453 + module_init(gs_module_init); 2454 + 2455 + /* 2456 + * gs_module_exit 2457 + * 2458 + * Unregister as a tty driver and a USB gadget driver. 2459 + */ 2460 + static void __exit gs_module_exit(void) 2461 + { 2462 + tty_unregister_driver(gs_tty_driver); 2463 + put_tty_driver(gs_tty_driver); 2464 + usb_gadget_unregister_driver(&gs_gadget_driver); 2465 + 2466 + pr_info("gs_module_exit: %s %s unloaded\n", 2467 + GS_LONG_NAME, GS_VERSION_STR); 2468 + } 2469 + module_exit(gs_module_exit);
+2 -2
drivers/usb/host/isp1760-hcd.c
··· 988 988 * This did not trigger for a long time now. 989 989 */ 990 990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " 991 - "%d of %d done: %08x cur: %08x\n", qtd, 991 + "%d of %zu done: %08x cur: %08x\n", qtd, 992 992 urb, qh, PTD_XFERRED_LENGTH(dw3), 993 993 qtd->length, done_map, 994 994 (1 << queue_entry)); ··· 1088 1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { 1089 1089 /* short BULK received */ 1090 1090 1091 - printk(KERN_ERR "short bulk, %d instead %d\n", length, 1091 + printk(KERN_ERR "short bulk, %d instead %zu\n", length, 1092 1092 qtd->length); 1093 1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) { 1094 1094 urb->status = -EREMOTEIO;
+1 -1
drivers/usb/host/isp1760-if.c
··· 256 256 257 257 static int __init isp1760_init(void) 258 258 { 259 - int ret; 259 + int ret = -ENODEV; 260 260 261 261 init_kmem_once(); 262 262
+1 -1
drivers/usb/host/ohci-sm501.c
··· 90 90 struct device *dev = &pdev->dev; 91 91 struct resource *res, *mem; 92 92 int retval, irq; 93 - struct usb_hcd *hcd = 0; 93 + struct usb_hcd *hcd = NULL; 94 94 95 95 irq = retval = platform_get_irq(pdev, 0); 96 96 if (retval < 0)
-4
drivers/usb/misc/ldusb.c
··· 63 63 #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 64 64 #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 65 65 66 - #define USB_VENDOR_ID_MICROCHIP 0x04d8 67 - #define USB_DEVICE_ID_PICDEM 0x000c 68 - 69 66 #ifdef CONFIG_USB_DYNAMIC_MINORS 70 67 #define USB_LD_MINOR_BASE 0 71 68 #else ··· 89 92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 90 93 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 91 94 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 92 - { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) }, 93 95 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 94 96 { } /* Terminating entry */ 95 97 };
+5
drivers/usb/misc/usbtest.c
··· 856 856 struct urb *u; 857 857 struct usb_ctrlrequest req; 858 858 struct subcase *reqp; 859 + 860 + /* sign of this variable means: 861 + * -: tested code must return this (negative) error code 862 + * +: tested code may return this (negative too) error code 863 + */ 859 864 int expected = 0; 860 865 861 866 /* requests here are mostly expected to succeed on any
+9
drivers/usb/serial/Kconfig
··· 447 447 To compile this driver as a module, choose M here: the 448 448 module will be called mos7840. If unsure, choose N. 449 449 450 + config USB_SERIAL_MOTOROLA 451 + tristate "USB Motorola Phone modem driver" 452 + ---help--- 453 + Say Y here if you want to use a Motorola phone with a USB 454 + connector as a modem link. 455 + 456 + To compile this driver as a module, choose M here: the 457 + module will be called moto_modem. If unsure, choose N. 458 + 450 459 config USB_SERIAL_NAVMAN 451 460 tristate "USB Navman GPS device" 452 461 help
+1
drivers/usb/serial/Makefile
··· 39 39 obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 40 40 obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o 41 41 obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 42 + obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o 42 43 obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 43 44 obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 44 45 obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
+70
drivers/usb/serial/moto_modem.c
··· 1 + /* 2 + * Motorola USB Phone driver 3 + * 4 + * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + * {sigh} 11 + * Mororola should be using the CDC ACM USB spec, but instead 12 + * they try to just "do their own thing"... This driver should handle a 13 + * few phones in which a basic "dumb serial connection" is needed to be 14 + * able to get a connection through to them. 15 + */ 16 + 17 + #include <linux/kernel.h> 18 + #include <linux/init.h> 19 + #include <linux/tty.h> 20 + #include <linux/module.h> 21 + #include <linux/usb.h> 22 + #include <linux/usb/serial.h> 23 + 24 + static struct usb_device_id id_table [] = { 25 + { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */ 26 + { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */ 27 + { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */ 28 + { }, 29 + }; 30 + MODULE_DEVICE_TABLE(usb, id_table); 31 + 32 + static struct usb_driver moto_driver = { 33 + .name = "moto-modem", 34 + .probe = usb_serial_probe, 35 + .disconnect = usb_serial_disconnect, 36 + .id_table = id_table, 37 + .no_dynamic_id = 1, 38 + }; 39 + 40 + static struct usb_serial_driver moto_device = { 41 + .driver = { 42 + .owner = THIS_MODULE, 43 + .name = "moto-modem", 44 + }, 45 + .id_table = id_table, 46 + .num_ports = 1, 47 + }; 48 + 49 + static int __init moto_init(void) 50 + { 51 + int retval; 52 + 53 + retval = usb_serial_register(&moto_device); 54 + if (retval) 55 + return retval; 56 + retval = usb_register(&moto_driver); 57 + if (retval) 58 + usb_serial_deregister(&moto_device); 59 + return retval; 60 + } 61 + 62 + static void __exit moto_exit(void) 63 + { 64 + usb_deregister(&moto_driver); 65 + usb_serial_deregister(&moto_device); 66 + } 67 + 68 + module_init(moto_init); 69 + module_exit(moto_exit); 70 + MODULE_LICENSE("GPL");
+6 -3
drivers/usb/serial/option.c
··· 154 154 #define NOVATELWIRELESS_PRODUCT_MC727 0x4100 155 155 #define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 156 156 157 - #define NOVATELWIRELESS_PRODUCT_U727 0x5010 158 - 159 157 /* FUTURE NOVATEL PRODUCTS */ 160 158 #define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 161 159 #define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 ··· 181 183 182 184 #define AXESSTEL_VENDOR_ID 0x1726 183 185 #define AXESSTEL_PRODUCT_MV110H 0x1000 186 + 187 + #define ONDA_VENDOR_ID 0x19d2 188 + #define ONDA_PRODUCT_ET502HS 0x0002 184 189 185 190 #define BANDRICH_VENDOR_ID 0x1A8D 186 191 #define BANDRICH_PRODUCT_C100_1 0x1002 ··· 270 269 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 271 270 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 272 271 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 273 - { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel U727 */ 274 272 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ 275 273 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ 276 274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ ··· 293 293 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 294 294 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 295 295 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 296 + { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ 296 297 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 297 298 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 298 299 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 300 + { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) }, 299 301 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 300 302 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 301 303 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 302 304 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 303 305 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 306 + { USB_DEVICE(0x19d2, 0x0001) }, /* Telstra NextG CDMA */ 304 307 { } /* Terminating entry */ 305 308 }; 306 309 MODULE_DEVICE_TABLE(usb, option_ids);
+45 -26
drivers/usb/storage/unusual_devs.h
··· 401 401 US_SC_DEVICE, US_PR_DEVICE, NULL, 402 402 US_FL_IGNORE_RESIDUE ), 403 403 404 + #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB 405 + UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, 406 + "Cypress", 407 + "Cypress AT2LP", 408 + US_SC_CYP_ATACB, US_PR_BULK, NULL, 409 + 0), 410 + #endif 411 + 404 412 /* Reported by Simon Levitt <simon@whattf.com> 405 413 * This entry needs Sub and Proto fields */ 406 414 UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, ··· 547 539 "CD-RW Device", 548 540 US_SC_8020, US_PR_CB, NULL, 0), 549 541 550 - /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 551 - * Device uses standards-violating 32-byte Bulk Command Block Wrappers and 552 - * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. 553 - */ 554 - 555 - UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, 556 - "Kobian Mercury", 557 - "Binocam DCB-132", 558 - US_SC_DEVICE, US_PR_DEVICE, NULL, 559 - US_FL_BULK32), 560 - 561 542 #ifdef CONFIG_USB_STORAGE_USBAT 562 543 UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 563 544 "Shuttle/SCM", ··· 561 564 "YP-U3", 562 565 US_SC_DEVICE, US_PR_DEVICE, NULL, 563 566 US_FL_MAX_SECTORS_64), 567 + 568 + /* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 569 + * Device uses standards-violating 32-byte Bulk Command Block Wrappers and 570 + * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011. 571 + */ 572 + UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, 573 + "Kobian Mercury", 574 + "Binocam DCB-132", 575 + US_SC_DEVICE, US_PR_DEVICE, NULL, 576 + US_FL_BULK32), 564 577 565 578 /* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ 566 579 UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, ··· 1311 1304 US_SC_DEVICE, US_PR_DEVICE, NULL, 1312 1305 US_FL_IGNORE_DEVICE ), 1313 1306 1307 + /* Reported by F. Aben <f.aben@option.com> 1308 + * This device (wrongly) has a vendor-specific device descriptor. 1309 + * The entry is needed so usb-storage can bind to it's mass-storage 1310 + * interface as an interface driver */ 1311 + UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000, 1312 + "Option", 1313 + "GI 0401 SD-Card", 1314 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1315 + 0 ), 1316 + 1314 1317 #ifdef CONFIG_USB_STORAGE_ISD200 1315 1318 UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1316 1319 "ATI", ··· 1377 1360 "MD 7425", 1378 1361 US_SC_DEVICE, US_PR_DEVICE, NULL, 1379 1362 US_FL_FIX_INQUIRY), 1380 - 1381 - /* Reported by Rohan Hart <rohan.hart17@gmail.com> */ 1382 - UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010, 1383 - "INTOVA", 1384 - "Pixtreme", 1385 - US_SC_DEVICE, US_PR_DEVICE, NULL, 1386 - US_FL_FIX_CAPACITY ), 1387 1363 1388 1364 /* 1389 1365 * Entry for Jenoptik JD 5200z3 ··· 1694 1684 US_SC_DEVICE, US_PR_DEVICE, NULL, 1695 1685 US_FL_IGNORE_RESIDUE ), 1696 1686 1687 + /* Reported by Mauro Andreolini <andreoli@weblab.ing.unimo.it> 1688 + * This entry is needed to bypass the ZeroCD mechanism 1689 + * and to properly load as a modem device. 1690 + */ 1691 + UNUSUAL_DEV( 0x19d2, 0x2000, 0x0000, 0x0000, 1692 + "Onda ET502HS", 1693 + "USB MMC Storage", 1694 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1695 + US_FL_IGNORE_DEVICE), 1696 + 1697 1697 /* patch submitted by Davide Perini <perini.davide@dpsoftware.org> 1698 1698 * and Renato Perini <rperini@email.it> 1699 1699 */ ··· 1741 1721 US_SC_DEVICE, US_PR_DEVICE, NULL, 1742 1722 US_FL_GO_SLOW ), 1743 1723 1724 + /* Reported by Rohan Hart <rohan.hart17@gmail.com> */ 1725 + UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010, 1726 + "INTOVA", 1727 + "Pixtreme", 1728 + US_SC_DEVICE, US_PR_DEVICE, NULL, 1729 + US_FL_FIX_CAPACITY ), 1730 + 1744 1731 /* 1745 1732 * David Härdeman <david@2gen.com> 1746 1733 * The key makes the SCSI stack print confusing (but harmless) messages ··· 1771 1744 "USB4500 FW1.04", 1772 1745 US_SC_DEVICE, US_PR_DEVICE, NULL, 1773 1746 US_FL_CAPACITY_HEURISTICS), 1774 - 1775 - #ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB 1776 - UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, 1777 - "Cypress", 1778 - "Cypress AT2LP", 1779 - US_SC_CYP_ATACB, US_PR_BULK, NULL, 1780 - 0), 1781 - #endif 1782 1747 1783 1748 /* Control/Bulk transport for all SubClass values */ 1784 1749 USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
+150
include/linux/usb/association.h
··· 1 + /* 2 + * Wireless USB - Cable Based Association 3 + * 4 + * Copyright (C) 2006 Intel Corporation 5 + * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License version 9 + * 2 as published by the Free Software Foundation. 10 + * 11 + */ 12 + #ifndef __LINUX_USB_ASSOCIATION_H 13 + #define __LINUX_USB_ASSOCIATION_H 14 + 15 + 16 + /* 17 + * Association attributes 18 + * 19 + * Association Models Supplement to WUSB 1.0 T[3-1] 20 + * 21 + * Each field in the structures has it's ID, it's length and then the 22 + * value. This is the actual definition of the field's ID and its 23 + * length. 24 + */ 25 + struct wusb_am_attr { 26 + __u8 id; 27 + __u8 len; 28 + }; 29 + 30 + /* Different fields defined by the spec */ 31 + #define WUSB_AR_AssociationTypeId { .id = 0x0000, .len = 2 } 32 + #define WUSB_AR_AssociationSubTypeId { .id = 0x0001, .len = 2 } 33 + #define WUSB_AR_Length { .id = 0x0002, .len = 4 } 34 + #define WUSB_AR_AssociationStatus { .id = 0x0004, .len = 4 } 35 + #define WUSB_AR_LangID { .id = 0x0008, .len = 2 } 36 + #define WUSB_AR_DeviceFriendlyName { .id = 0x000b, .len = 64 } /* max */ 37 + #define WUSB_AR_HostFriendlyName { .id = 0x000c, .len = 64 } /* max */ 38 + #define WUSB_AR_CHID { .id = 0x1000, .len = 16 } 39 + #define WUSB_AR_CDID { .id = 0x1001, .len = 16 } 40 + #define WUSB_AR_ConnectionContext { .id = 0x1002, .len = 48 } 41 + #define WUSB_AR_BandGroups { .id = 0x1004, .len = 2 } 42 + 43 + /* CBAF Control Requests (AMS1.0[T4-1] */ 44 + enum { 45 + CBAF_REQ_GET_ASSOCIATION_INFORMATION = 0x01, 46 + CBAF_REQ_GET_ASSOCIATION_REQUEST, 47 + CBAF_REQ_SET_ASSOCIATION_RESPONSE 48 + }; 49 + 50 + /* 51 + * CBAF USB-interface defitions 52 + * 53 + * No altsettings, one optional interrupt endpoint. 54 + */ 55 + enum { 56 + CBAF_IFACECLASS = 0xef, 57 + CBAF_IFACESUBCLASS = 0x03, 58 + CBAF_IFACEPROTOCOL = 0x01, 59 + }; 60 + 61 + /* Association Information (AMS1.0[T4-3]) */ 62 + struct wusb_cbaf_assoc_info { 63 + __le16 Length; 64 + __u8 NumAssociationRequests; 65 + __le16 Flags; 66 + __u8 AssociationRequestsArray[]; 67 + } __attribute__((packed)); 68 + 69 + /* Association Request (AMS1.0[T4-4]) */ 70 + struct wusb_cbaf_assoc_request { 71 + __u8 AssociationDataIndex; 72 + __u8 Reserved; 73 + __le16 AssociationTypeId; 74 + __le16 AssociationSubTypeId; 75 + __le32 AssociationTypeInfoSize; 76 + } __attribute__((packed)); 77 + 78 + enum { 79 + AR_TYPE_WUSB = 0x0001, 80 + AR_TYPE_WUSB_RETRIEVE_HOST_INFO = 0x0000, 81 + AR_TYPE_WUSB_ASSOCIATE = 0x0001, 82 + }; 83 + 84 + /* Association Attribute header (AMS1.0[3.8]) */ 85 + struct wusb_cbaf_attr_hdr { 86 + __le16 id; 87 + __le16 len; 88 + } __attribute__((packed)); 89 + 90 + /* Host Info (AMS1.0[T4-7]) (yeah, more headers and fields...) */ 91 + struct wusb_cbaf_host_info { 92 + struct wusb_cbaf_attr_hdr AssociationTypeId_hdr; 93 + __le16 AssociationTypeId; 94 + struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr; 95 + __le16 AssociationSubTypeId; 96 + struct wusb_cbaf_attr_hdr CHID_hdr; 97 + struct wusb_ckhdid CHID; 98 + struct wusb_cbaf_attr_hdr LangID_hdr; 99 + __le16 LangID; 100 + struct wusb_cbaf_attr_hdr HostFriendlyName_hdr; 101 + __u8 HostFriendlyName[]; 102 + } __attribute__((packed)); 103 + 104 + /* Device Info (AMS1.0[T4-8]) 105 + * 106 + * I still don't get this tag'n'header stuff for each goddamn 107 + * field... 108 + */ 109 + struct wusb_cbaf_device_info { 110 + struct wusb_cbaf_attr_hdr Length_hdr; 111 + __le32 Length; 112 + struct wusb_cbaf_attr_hdr CDID_hdr; 113 + struct wusb_ckhdid CDID; 114 + struct wusb_cbaf_attr_hdr BandGroups_hdr; 115 + __le16 BandGroups; 116 + struct wusb_cbaf_attr_hdr LangID_hdr; 117 + __le16 LangID; 118 + struct wusb_cbaf_attr_hdr DeviceFriendlyName_hdr; 119 + __u8 DeviceFriendlyName[]; 120 + } __attribute__((packed)); 121 + 122 + /* Connection Context; CC_DATA - Success case (AMS1.0[T4-9]) */ 123 + struct wusb_cbaf_cc_data { 124 + struct wusb_cbaf_attr_hdr AssociationTypeId_hdr; 125 + __le16 AssociationTypeId; 126 + struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr; 127 + __le16 AssociationSubTypeId; 128 + struct wusb_cbaf_attr_hdr Length_hdr; 129 + __le32 Length; 130 + struct wusb_cbaf_attr_hdr ConnectionContext_hdr; 131 + struct wusb_ckhdid CHID; 132 + struct wusb_ckhdid CDID; 133 + struct wusb_ckhdid CK; 134 + struct wusb_cbaf_attr_hdr BandGroups_hdr; 135 + __le16 BandGroups; 136 + } __attribute__((packed)); 137 + 138 + /* CC_DATA - Failure case (AMS1.0[T4-10]) */ 139 + struct wusb_cbaf_cc_data_fail { 140 + struct wusb_cbaf_attr_hdr AssociationTypeId_hdr; 141 + __le16 AssociationTypeId; 142 + struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr; 143 + __le16 AssociationSubTypeId; 144 + struct wusb_cbaf_attr_hdr Length_hdr; 145 + __le16 Length; 146 + struct wusb_cbaf_attr_hdr AssociationStatus_hdr; 147 + __u32 AssociationStatus; 148 + } __attribute__((packed)); 149 + 150 + #endif /* __LINUX_USB_ASSOCIATION_H */