Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg Kroah-Hartman:
"Here are the USB patches against your 3.7-rc1 tree.

There are the usual UABI header file movements, and we finally are now
able to remove the dbg() macro that is over 15 years old (that had to
wait for after some other trees got merged into yours during the big
3.7-rc1 merge window.)

Other than that, nothing major, just a number of bugfixes and new
device ids. It turns out that almost all of the usb-serial drivers
had bugs in how they were handling their internal data, leaking
memory, hence all of those fixups.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"

* tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (42 commits)
USB: option: add more ZTE devices
USB: option: blacklist net interface on ZTE devices
usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP
USB: io_ti: fix sysfs-attribute creation
USB: iuu_phoenix: fix sysfs-attribute creation
USB: spcp8x5: fix port-data memory leak
USB: ssu100: fix port-data memory leak
USB: ti_usb_3410_5052: fix port-data memory leak
USB: oti6858: fix port-data memory leak
USB: iuu_phoenix: fix port-data memory leak
USB: kl5kusb105: fix port-data memory leak
USB: io_ti: fix port-data memory leak
USB: keyspan_pda: fix port-data memory leak
USB: f81232: fix port-data memory leak
USB: io_edgeport: fix port-data memory leak
USB: kobil_sct: fix port-data memory leak
USB: cypress_m8: fix port-data memory leak
usb: acm: fix the computation of the number of data bits
usb: Missing dma_mask in ehci-vt8500.c when probed from device-tree
usb: Missing dma_mask in uhci-platform.c when probed from device-tree
...

+2337 -2225
+7
MAINTAINERS
··· 7746 7746 S: Maintained 7747 7747 F: drivers/media/usb/uvc/ 7748 7748 7749 + USB WEBCAM GADGET 7750 + M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 7751 + L: linux-usb@vger.kernel.org 7752 + S: Maintained 7753 + F: drivers/usb/gadget/*uvc*.c 7754 + F: drivers/usb/gadget/webcam.c 7755 + 7749 7756 USB WIRELESS RNDIS DRIVER (rndis_wlan) 7750 7757 M: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> 7751 7758 L: linux-wireless@vger.kernel.org
+16 -6
drivers/usb/class/cdc-acm.c
··· 817 817 2500000, 3000000, 3500000, 4000000 818 818 }; 819 819 820 - static const __u8 acm_tty_size[] = { 821 - 5, 6, 7, 8 822 - }; 823 - 824 820 static void acm_tty_set_termios(struct tty_struct *tty, 825 821 struct ktermios *termios_old) 826 822 { ··· 830 834 newline.bParityType = termios->c_cflag & PARENB ? 831 835 (termios->c_cflag & PARODD ? 1 : 2) + 832 836 (termios->c_cflag & CMSPAR ? 2 : 0) : 0; 833 - newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4]; 837 + switch (termios->c_cflag & CSIZE) { 838 + case CS5: 839 + newline.bDataBits = 5; 840 + break; 841 + case CS6: 842 + newline.bDataBits = 6; 843 + break; 844 + case CS7: 845 + newline.bDataBits = 7; 846 + break; 847 + case CS8: 848 + default: 849 + newline.bDataBits = 8; 850 + break; 851 + } 834 852 /* FIXME: Needs to clear unsupported bits in the termios */ 835 853 acm->clocal = ((termios->c_cflag & CLOCAL) != 0); 836 854 ··· 1243 1233 1244 1234 if (usb_endpoint_xfer_int(epwrite)) 1245 1235 usb_fill_int_urb(snd->urb, usb_dev, 1246 - usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), 1236 + usb_sndintpipe(usb_dev, epwrite->bEndpointAddress), 1247 1237 NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval); 1248 1238 else 1249 1239 usb_fill_bulk_urb(snd->urb, usb_dev,
+1
drivers/usb/core/devio.c
··· 1348 1348 ret = -EFAULT; 1349 1349 goto error; 1350 1350 } 1351 + uurb->buffer += u; 1351 1352 } 1352 1353 totlen -= u; 1353 1354 }
+4
drivers/usb/core/driver.c
··· 367 367 intf->condition = USB_INTERFACE_UNBOUND; 368 368 usb_cancel_queued_reset(intf); 369 369 370 + /* If the LPM disable succeeded, balance the ref counts. */ 371 + if (!lpm_disable_error) 372 + usb_unlocked_enable_lpm(udev); 373 + 370 374 /* Unbound interfaces are always runtime-PM-disabled and -suspended */ 371 375 if (driver->supports_autosuspend) 372 376 pm_runtime_disable(dev);
+23 -13
drivers/usb/core/hub.c
··· 3241 3241 (state == USB3_LPM_U2 && 3242 3242 (u2_sel > USB3_LPM_MAX_U2_SEL_PEL || 3243 3243 u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) { 3244 - dev_dbg(&udev->dev, "Device-initiated %s disabled due " 3245 - "to long SEL %llu ms or PEL %llu ms\n", 3244 + dev_dbg(&udev->dev, "Device-initiated %s disabled due to long SEL %llu us or PEL %llu us\n", 3246 3245 usb3_lpm_names[state], u1_sel, u1_pel); 3247 3246 return -EINVAL; 3248 3247 } ··· 3318 3319 } 3319 3320 3320 3321 if (enable) { 3321 - /* 3322 - * First, let the device know about the exit latencies 3323 - * associated with the link state we're about to enable. 3324 - */ 3325 - ret = usb_req_set_sel(udev, state); 3326 - if (ret < 0) { 3327 - dev_warn(&udev->dev, "Set SEL for device-initiated " 3328 - "%s failed.\n", usb3_lpm_names[state]); 3329 - return -EBUSY; 3330 - } 3331 3322 /* 3332 3323 * Now send the control transfer to enable device-initiated LPM 3333 3324 * for either U1 or U2. ··· 3403 3414 static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, 3404 3415 enum usb3_link_state state) 3405 3416 { 3406 - int timeout; 3417 + int timeout, ret; 3418 + __u8 u1_mel = udev->bos->ss_cap->bU1devExitLat; 3419 + __le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat; 3420 + 3421 + /* If the device says it doesn't have *any* exit latency to come out of 3422 + * U1 or U2, it's probably lying. Assume it doesn't implement that link 3423 + * state. 3424 + */ 3425 + if ((state == USB3_LPM_U1 && u1_mel == 0) || 3426 + (state == USB3_LPM_U2 && u2_mel == 0)) 3427 + return; 3428 + 3429 + /* 3430 + * First, let the device know about the exit latencies 3431 + * associated with the link state we're about to enable. 3432 + */ 3433 + ret = usb_req_set_sel(udev, state); 3434 + if (ret < 0) { 3435 + dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n", 3436 + usb3_lpm_names[state]); 3437 + return; 3438 + } 3407 3439 3408 3440 /* We allow the host controller to set the U1/U2 timeout internally 3409 3441 * first, so that it can change its schedule to account for the
+4
drivers/usb/dwc3/core.c
··· 409 409 { 410 410 dwc3_event_buffers_cleanup(dwc); 411 411 dwc3_free_event_buffers(dwc); 412 + 413 + usb_phy_shutdown(dwc->usb2_phy); 414 + usb_phy_shutdown(dwc->usb3_phy); 415 + 412 416 } 413 417 414 418 #define DWC3_ALIGN_MASK (16 - 1)
+1 -1
drivers/usb/dwc3/gadget.c
··· 1904 1904 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params); 1905 1905 WARN_ON_ONCE(ret); 1906 1906 dep->resource_index = 0; 1907 - 1907 + dep->flags &= ~DWC3_EP_BUSY; 1908 1908 udelay(100); 1909 1909 } 1910 1910
+1
drivers/usb/gadget/Kconfig
··· 952 952 config USB_G_WEBCAM 953 953 tristate "USB Webcam Gadget" 954 954 depends on VIDEO_DEV 955 + select USB_LIBCOMPOSITE 955 956 help 956 957 The Webcam Gadget acts as a composite USB Audio and Video Class 957 958 device. It provides a userspace API to process UVC control requests
+2 -2
drivers/usb/gadget/lpc32xx_udc.c
··· 2930 2930 2931 2931 /* Get the VBUS status from the transceiver */ 2932 2932 value = i2c_smbus_read_byte_data(udc->isp1301_i2c_client, 2933 - ISP1301_I2C_OTG_CONTROL_2); 2933 + ISP1301_I2C_INTERRUPT_SOURCE); 2934 2934 2935 2935 /* VBUS on or off? */ 2936 - if (value & OTG_B_SESS_VLD) 2936 + if (value & INT_SESS_VLD) 2937 2937 udc->vbus = 1; 2938 2938 else 2939 2939 udc->vbus = 0;
+10
drivers/usb/host/ehci-vt8500.c
··· 85 85 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 86 86 }; 87 87 88 + static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32); 89 + 88 90 static int vt8500_ehci_drv_probe(struct platform_device *pdev) 89 91 { 90 92 struct usb_hcd *hcd; ··· 96 94 97 95 if (usb_disabled()) 98 96 return -ENODEV; 97 + 98 + /* 99 + * Right now device-tree probed devices don't get dma_mask set. 100 + * Since shared usb code relies on it, set it here for now. 101 + * Once we have dma capability bindings this can go away. 102 + */ 103 + if (!pdev->dev.dma_mask) 104 + pdev->dev.dma_mask = &vt8500_ehci_dma_mask; 99 105 100 106 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 101 107 pr_debug("resource[1] is not IORESOURCE_IRQ");
+9
drivers/usb/host/uhci-platform.c
··· 60 60 .hub_control = uhci_hub_control, 61 61 }; 62 62 63 + static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32); 63 64 64 65 static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) 65 66 { ··· 71 70 72 71 if (usb_disabled()) 73 72 return -ENODEV; 73 + 74 + /* 75 + * Right now device-tree probed devices don't get dma_mask set. 76 + * Since shared usb code relies on it, set it here for now. 77 + * Once we have dma capability bindings this can go away. 78 + */ 79 + if (!pdev->dev.dma_mask) 80 + pdev->dev.dma_mask = &platform_uhci_dma_mask; 74 81 75 82 hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev, 76 83 pdev->name);
+2 -1
drivers/usb/host/xhci.c
··· 479 479 480 480 if (strstr(dmi_product_name, "Z420") || 481 481 strstr(dmi_product_name, "Z620") || 482 - strstr(dmi_product_name, "Z820")) 482 + strstr(dmi_product_name, "Z820") || 483 + strstr(dmi_product_name, "Z1")) 483 484 return true; 484 485 485 486 return false;
+6
drivers/usb/musb/am35x.c
··· 305 305 ret = IRQ_HANDLED; 306 306 } 307 307 308 + /* Drop spurious RX and TX if device is disconnected */ 309 + if (musb->int_usb & MUSB_INTR_DISCONNECT) { 310 + musb->int_tx = 0; 311 + musb->int_rx = 0; 312 + } 313 + 308 314 if (musb->int_tx || musb->int_rx || musb->int_usb) 309 315 ret |= musb_interrupt(musb); 310 316
+3 -3
drivers/usb/renesas_usbhs/mod.c
··· 273 273 usbhs_write(priv, INTSTS0, ~irq_state.intsts0 & INTSTS0_MAGIC); 274 274 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); 275 275 276 - usbhs_write(priv, BRDYSTS, 0); 277 - usbhs_write(priv, NRDYSTS, 0); 278 - usbhs_write(priv, BEMPSTS, 0); 276 + usbhs_write(priv, BRDYSTS, ~irq_state.brdysts); 277 + usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts); 278 + usbhs_write(priv, BEMPSTS, ~irq_state.bempsts); 279 279 280 280 /* 281 281 * call irq callback functions
+1 -1
drivers/usb/renesas_usbhs/pipe.h
··· 54 54 * pipe list 55 55 */ 56 56 #define __usbhs_for_each_pipe(start, pos, info, i) \ 57 - for (i = start, pos = (info)->pipe; \ 57 + for (i = start, pos = (info)->pipe + i; \ 58 58 i < (info)->size; \ 59 59 i++, pos = (info)->pipe + i) 60 60
+14 -12
drivers/usb/serial/ark3116.c
··· 125 125 126 126 static int ark3116_attach(struct usb_serial *serial) 127 127 { 128 - struct usb_serial_port *port = serial->port[0]; 129 - struct ark3116_private *priv; 130 - 131 128 /* make sure we have our end-points */ 132 129 if ((serial->num_bulk_in == 0) || 133 130 (serial->num_bulk_out == 0) || ··· 139 142 return -EINVAL; 140 143 } 141 144 142 - priv = kzalloc(sizeof(struct ark3116_private), 143 - GFP_KERNEL); 145 + return 0; 146 + } 147 + 148 + static int ark3116_port_probe(struct usb_serial_port *port) 149 + { 150 + struct usb_serial *serial = port->serial; 151 + struct ark3116_private *priv; 152 + 153 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 144 154 if (!priv) 145 155 return -ENOMEM; 146 156 ··· 202 198 return 0; 203 199 } 204 200 205 - static void ark3116_release(struct usb_serial *serial) 201 + static int ark3116_port_remove(struct usb_serial_port *port) 206 202 { 207 - struct usb_serial_port *port = serial->port[0]; 208 203 struct ark3116_private *priv = usb_get_serial_port_data(port); 209 204 210 205 /* device is closed, so URBs and DMA should be down */ 211 - 212 - usb_set_serial_port_data(port, NULL); 213 - 214 206 mutex_destroy(&priv->hw_lock); 215 - 216 207 kfree(priv); 208 + 209 + return 0; 217 210 } 218 211 219 212 static void ark3116_init_termios(struct tty_struct *tty) ··· 724 723 .id_table = id_table, 725 724 .num_ports = 1, 726 725 .attach = ark3116_attach, 727 - .release = ark3116_release, 726 + .port_probe = ark3116_port_probe, 727 + .port_remove = ark3116_port_remove, 728 728 .set_termios = ark3116_set_termios, 729 729 .init_termios = ark3116_init_termios, 730 730 .ioctl = ark3116_ioctl,
+15 -16
drivers/usb/serial/belkin_sa.c
··· 45 45 #define DRIVER_DESC "USB Belkin Serial converter driver" 46 46 47 47 /* function prototypes for a Belkin USB Serial Adapter F5U103 */ 48 - static int belkin_sa_startup(struct usb_serial *serial); 49 - static void belkin_sa_release(struct usb_serial *serial); 48 + static int belkin_sa_port_probe(struct usb_serial_port *port); 49 + static int belkin_sa_port_remove(struct usb_serial_port *port); 50 50 static int belkin_sa_open(struct tty_struct *tty, 51 51 struct usb_serial_port *port); 52 52 static void belkin_sa_close(struct usb_serial_port *port); ··· 88 88 .break_ctl = belkin_sa_break_ctl, 89 89 .tiocmget = belkin_sa_tiocmget, 90 90 .tiocmset = belkin_sa_tiocmset, 91 - .attach = belkin_sa_startup, 92 - .release = belkin_sa_release, 91 + .port_probe = belkin_sa_port_probe, 92 + .port_remove = belkin_sa_port_remove, 93 93 }; 94 94 95 95 static struct usb_serial_driver * const serial_drivers[] = { ··· 118 118 (c), BELKIN_SA_SET_REQUEST_TYPE, \ 119 119 (v), 0, NULL, 0, WDR_TIMEOUT) 120 120 121 - /* do some startup allocations not currently performed by usb_serial_probe() */ 122 - static int belkin_sa_startup(struct usb_serial *serial) 121 + static int belkin_sa_port_probe(struct usb_serial_port *port) 123 122 { 124 - struct usb_device *dev = serial->dev; 123 + struct usb_device *dev = port->serial->dev; 125 124 struct belkin_sa_private *priv; 126 125 127 - /* allocate the private data structure */ 128 126 priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); 129 127 if (!priv) 130 - return -1; /* error */ 131 - /* set initial values for control structures */ 128 + return -ENOMEM; 129 + 132 130 spin_lock_init(&priv->lock); 133 131 priv->control_state = 0; 134 132 priv->last_lsr = 0; ··· 138 140 le16_to_cpu(dev->descriptor.bcdDevice), 139 141 priv->bad_flow_control); 140 142 141 - init_waitqueue_head(&serial->port[0]->write_wait); 142 - usb_set_serial_port_data(serial->port[0], priv); 143 + usb_set_serial_port_data(port, priv); 143 144 144 145 return 0; 145 146 } 146 147 147 - static void belkin_sa_release(struct usb_serial *serial) 148 + static int belkin_sa_port_remove(struct usb_serial_port *port) 148 149 { 149 - int i; 150 + struct belkin_sa_private *priv; 150 151 151 - for (i = 0; i < serial->num_ports; ++i) 152 - kfree(usb_get_serial_port_data(serial->port[i])); 152 + priv = usb_get_serial_port_data(port); 153 + kfree(priv); 154 + 155 + return 0; 153 156 } 154 157 155 158 static int belkin_sa_open(struct tty_struct *tty,
+17 -23
drivers/usb/serial/cp210x.c
··· 162 162 163 163 MODULE_DEVICE_TABLE(usb, id_table); 164 164 165 - struct cp210x_port_private { 165 + struct cp210x_serial_private { 166 166 __u8 bInterfaceNumber; 167 167 }; 168 168 ··· 276 276 unsigned int *data, int size) 277 277 { 278 278 struct usb_serial *serial = port->serial; 279 - struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 279 + struct cp210x_serial_private *spriv = usb_get_serial_data(serial); 280 280 __le32 *buf; 281 281 int result, i, length; 282 282 ··· 292 292 /* Issue the request, attempting to read 'size' bytes */ 293 293 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 294 294 request, REQTYPE_INTERFACE_TO_HOST, 0x0000, 295 - port_priv->bInterfaceNumber, buf, size, 295 + spriv->bInterfaceNumber, buf, size, 296 296 USB_CTRL_GET_TIMEOUT); 297 297 298 298 /* Convert data into an array of integers */ ··· 323 323 unsigned int *data, int size) 324 324 { 325 325 struct usb_serial *serial = port->serial; 326 - struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 326 + struct cp210x_serial_private *spriv = usb_get_serial_data(serial); 327 327 __le32 *buf; 328 328 int result, i, length; 329 329 ··· 345 345 result = usb_control_msg(serial->dev, 346 346 usb_sndctrlpipe(serial->dev, 0), 347 347 request, REQTYPE_HOST_TO_INTERFACE, 0x0000, 348 - port_priv->bInterfaceNumber, buf, size, 348 + spriv->bInterfaceNumber, buf, size, 349 349 USB_CTRL_SET_TIMEOUT); 350 350 } else { 351 351 result = usb_control_msg(serial->dev, 352 352 usb_sndctrlpipe(serial->dev, 0), 353 353 request, REQTYPE_HOST_TO_INTERFACE, data[0], 354 - port_priv->bInterfaceNumber, NULL, 0, 354 + spriv->bInterfaceNumber, NULL, 0, 355 355 USB_CTRL_SET_TIMEOUT); 356 356 } 357 357 ··· 845 845 846 846 static int cp210x_startup(struct usb_serial *serial) 847 847 { 848 - struct cp210x_port_private *port_priv; 849 - int i; 848 + struct usb_host_interface *cur_altsetting; 849 + struct cp210x_serial_private *spriv; 850 850 851 851 /* cp210x buffers behave strangely unless device is reset */ 852 852 usb_reset_device(serial->dev); 853 853 854 - for (i = 0; i < serial->num_ports; i++) { 855 - port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL); 856 - if (!port_priv) 857 - return -ENOMEM; 854 + spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 855 + if (!spriv) 856 + return -ENOMEM; 858 857 859 - port_priv->bInterfaceNumber = 860 - serial->interface->cur_altsetting->desc.bInterfaceNumber; 858 + cur_altsetting = serial->interface->cur_altsetting; 859 + spriv->bInterfaceNumber = cur_altsetting->desc.bInterfaceNumber; 861 860 862 - usb_set_serial_port_data(serial->port[i], port_priv); 863 - } 861 + usb_set_serial_data(serial, spriv); 864 862 865 863 return 0; 866 864 } 867 865 868 866 static void cp210x_release(struct usb_serial *serial) 869 867 { 870 - struct cp210x_port_private *port_priv; 871 - int i; 868 + struct cp210x_serial_private *spriv; 872 869 873 - for (i = 0; i < serial->num_ports; i++) { 874 - port_priv = usb_get_serial_port_data(serial->port[i]); 875 - kfree(port_priv); 876 - usb_set_serial_port_data(serial->port[i], NULL); 877 - } 870 + spriv = usb_get_serial_data(serial); 871 + kfree(spriv); 878 872 } 879 873 880 874 module_usb_serial_driver(serial_drivers, id_table);
+20 -31
drivers/usb/serial/cyberjack.c
··· 55 55 #define CYBERJACK_PRODUCT_ID 0x0100 56 56 57 57 /* Function prototypes */ 58 - static int cyberjack_startup(struct usb_serial *serial); 59 58 static void cyberjack_disconnect(struct usb_serial *serial); 60 - static void cyberjack_release(struct usb_serial *serial); 59 + static int cyberjack_port_probe(struct usb_serial_port *port); 60 + static int cyberjack_port_remove(struct usb_serial_port *port); 61 61 static int cyberjack_open(struct tty_struct *tty, 62 62 struct usb_serial_port *port); 63 63 static void cyberjack_close(struct usb_serial_port *port); ··· 83 83 .description = "Reiner SCT Cyberjack USB card reader", 84 84 .id_table = id_table, 85 85 .num_ports = 1, 86 - .attach = cyberjack_startup, 87 86 .disconnect = cyberjack_disconnect, 88 - .release = cyberjack_release, 87 + .port_probe = cyberjack_port_probe, 88 + .port_remove = cyberjack_port_remove, 89 89 .open = cyberjack_open, 90 90 .close = cyberjack_close, 91 91 .write = cyberjack_write, ··· 107 107 short wrsent; /* Data already sent */ 108 108 }; 109 109 110 - /* do some startup allocations not currently performed by usb_serial_probe() */ 111 - static int cyberjack_startup(struct usb_serial *serial) 110 + static int cyberjack_port_probe(struct usb_serial_port *port) 112 111 { 113 112 struct cyberjack_private *priv; 114 - int i; 113 + int result; 115 114 116 - /* allocate the private data structure */ 117 115 priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); 118 116 if (!priv) 119 117 return -ENOMEM; 120 118 121 - /* set initial values */ 122 119 spin_lock_init(&priv->lock); 123 120 priv->rdtodo = 0; 124 121 priv->wrfilled = 0; 125 122 priv->wrsent = 0; 126 - usb_set_serial_port_data(serial->port[0], priv); 127 123 128 - init_waitqueue_head(&serial->port[0]->write_wait); 124 + usb_set_serial_port_data(port, priv); 129 125 130 - for (i = 0; i < serial->num_ports; ++i) { 131 - int result; 132 - result = usb_submit_urb(serial->port[i]->interrupt_in_urb, 133 - GFP_KERNEL); 134 - if (result) 135 - dev_err(&serial->dev->dev, 136 - "usb_submit_urb(read int) failed\n"); 137 - dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n", 138 - __func__); 139 - } 126 + result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 127 + if (result) 128 + dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); 129 + 130 + return 0; 131 + } 132 + 133 + static int cyberjack_port_remove(struct usb_serial_port *port) 134 + { 135 + struct cyberjack_private *priv; 136 + 137 + priv = usb_get_serial_port_data(port); 138 + kfree(priv); 140 139 141 140 return 0; 142 141 } ··· 146 147 147 148 for (i = 0; i < serial->num_ports; ++i) 148 149 usb_kill_urb(serial->port[i]->interrupt_in_urb); 149 - } 150 - 151 - static void cyberjack_release(struct usb_serial *serial) 152 - { 153 - int i; 154 - 155 - for (i = 0; i < serial->num_ports; ++i) { 156 - /* My special items, the standard routines free my urbs */ 157 - kfree(usb_get_serial_port_data(serial->port[i])); 158 - } 159 150 } 160 151 161 152 static int cyberjack_open(struct tty_struct *tty,
+37 -38
drivers/usb/serial/cypress_m8.c
··· 123 123 }; 124 124 125 125 /* function prototypes for the Cypress USB to serial device */ 126 - static int cypress_earthmate_startup(struct usb_serial *serial); 127 - static int cypress_hidcom_startup(struct usb_serial *serial); 128 - static int cypress_ca42v2_startup(struct usb_serial *serial); 129 - static void cypress_release(struct usb_serial *serial); 126 + static int cypress_earthmate_port_probe(struct usb_serial_port *port); 127 + static int cypress_hidcom_port_probe(struct usb_serial_port *port); 128 + static int cypress_ca42v2_port_probe(struct usb_serial_port *port); 129 + static int cypress_port_remove(struct usb_serial_port *port); 130 130 static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port); 131 131 static void cypress_close(struct usb_serial_port *port); 132 132 static void cypress_dtr_rts(struct usb_serial_port *port, int on); ··· 156 156 .description = "DeLorme Earthmate USB", 157 157 .id_table = id_table_earthmate, 158 158 .num_ports = 1, 159 - .attach = cypress_earthmate_startup, 160 - .release = cypress_release, 159 + .port_probe = cypress_earthmate_port_probe, 160 + .port_remove = cypress_port_remove, 161 161 .open = cypress_open, 162 162 .close = cypress_close, 163 163 .dtr_rts = cypress_dtr_rts, ··· 182 182 .description = "HID->COM RS232 Adapter", 183 183 .id_table = id_table_cyphidcomrs232, 184 184 .num_ports = 1, 185 - .attach = cypress_hidcom_startup, 186 - .release = cypress_release, 185 + .port_probe = cypress_hidcom_port_probe, 186 + .port_remove = cypress_port_remove, 187 187 .open = cypress_open, 188 188 .close = cypress_close, 189 189 .dtr_rts = cypress_dtr_rts, ··· 208 208 .description = "Nokia CA-42 V2 Adapter", 209 209 .id_table = id_table_nokiaca42v2, 210 210 .num_ports = 1, 211 - .attach = cypress_ca42v2_startup, 212 - .release = cypress_release, 211 + .port_probe = cypress_ca42v2_port_probe, 212 + .port_remove = cypress_port_remove, 213 213 .open = cypress_open, 214 214 .close = cypress_close, 215 215 .dtr_rts = cypress_dtr_rts, ··· 438 438 *****************************************************************************/ 439 439 440 440 441 - static int generic_startup(struct usb_serial *serial) 441 + static int cypress_generic_port_probe(struct usb_serial_port *port) 442 442 { 443 + struct usb_serial *serial = port->serial; 443 444 struct cypress_private *priv; 444 - struct usb_serial_port *port = serial->port[0]; 445 445 446 446 priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL); 447 447 if (!priv) ··· 490 490 } 491 491 492 492 493 - static int cypress_earthmate_startup(struct usb_serial *serial) 493 + static int cypress_earthmate_port_probe(struct usb_serial_port *port) 494 494 { 495 + struct usb_serial *serial = port->serial; 495 496 struct cypress_private *priv; 496 - struct usb_serial_port *port = serial->port[0]; 497 + int ret; 497 498 498 - if (generic_startup(serial)) { 499 + ret = cypress_generic_port_probe(port); 500 + if (ret) { 499 501 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); 500 - return 1; 502 + return ret; 501 503 } 502 504 503 505 priv = usb_get_serial_port_data(port); ··· 520 518 } 521 519 522 520 return 0; 523 - } /* cypress_earthmate_startup */ 521 + } 524 522 525 - 526 - static int cypress_hidcom_startup(struct usb_serial *serial) 523 + static int cypress_hidcom_port_probe(struct usb_serial_port *port) 527 524 { 528 525 struct cypress_private *priv; 529 - struct usb_serial_port *port = serial->port[0]; 526 + int ret; 530 527 531 - if (generic_startup(serial)) { 528 + ret = cypress_generic_port_probe(port); 529 + if (ret) { 532 530 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); 533 - return 1; 531 + return ret; 534 532 } 535 533 536 534 priv = usb_get_serial_port_data(port); 537 535 priv->chiptype = CT_CYPHIDCOM; 538 536 539 537 return 0; 540 - } /* cypress_hidcom_startup */ 538 + } 541 539 542 - 543 - static int cypress_ca42v2_startup(struct usb_serial *serial) 540 + static int cypress_ca42v2_port_probe(struct usb_serial_port *port) 544 541 { 545 542 struct cypress_private *priv; 546 - struct usb_serial_port *port = serial->port[0]; 543 + int ret; 547 544 548 - if (generic_startup(serial)) { 545 + ret = cypress_generic_port_probe(port); 546 + if (ret) { 549 547 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); 550 - return 1; 548 + return ret; 551 549 } 552 550 553 551 priv = usb_get_serial_port_data(port); 554 552 priv->chiptype = CT_CA42V2; 555 553 556 554 return 0; 557 - } /* cypress_ca42v2_startup */ 555 + } 558 556 559 - 560 - static void cypress_release(struct usb_serial *serial) 557 + static int cypress_port_remove(struct usb_serial_port *port) 561 558 { 562 559 struct cypress_private *priv; 563 560 564 - /* all open ports are closed at this point */ 565 - priv = usb_get_serial_port_data(serial->port[0]); 561 + priv = usb_get_serial_port_data(port); 566 562 567 - if (priv) { 568 - kfifo_free(&priv->write_fifo); 569 - kfree(priv); 570 - } 563 + kfifo_free(&priv->write_fifo); 564 + kfree(priv); 565 + 566 + return 0; 571 567 } 572 - 573 568 574 569 static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port) 575 570 {
+17 -26
drivers/usb/serial/f81232.c
··· 318 318 return -ENOIOCTLCMD; 319 319 } 320 320 321 - static int f81232_startup(struct usb_serial *serial) 321 + static int f81232_port_probe(struct usb_serial_port *port) 322 322 { 323 323 struct f81232_private *priv; 324 - int i; 325 324 326 - for (i = 0; i < serial->num_ports; ++i) { 327 - priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL); 328 - if (!priv) 329 - goto cleanup; 330 - spin_lock_init(&priv->lock); 331 - init_waitqueue_head(&priv->delta_msr_wait); 332 - usb_set_serial_port_data(serial->port[i], priv); 333 - } 325 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 326 + if (!priv) 327 + return -ENOMEM; 328 + 329 + spin_lock_init(&priv->lock); 330 + init_waitqueue_head(&priv->delta_msr_wait); 331 + 332 + usb_set_serial_port_data(port, priv); 333 + 334 334 return 0; 335 - 336 - cleanup: 337 - for (--i; i >= 0; --i) { 338 - priv = usb_get_serial_port_data(serial->port[i]); 339 - kfree(priv); 340 - usb_set_serial_port_data(serial->port[i], NULL); 341 - } 342 - return -ENOMEM; 343 335 } 344 336 345 - static void f81232_release(struct usb_serial *serial) 337 + static int f81232_port_remove(struct usb_serial_port *port) 346 338 { 347 - int i; 348 339 struct f81232_private *priv; 349 340 350 - for (i = 0; i < serial->num_ports; ++i) { 351 - priv = usb_get_serial_port_data(serial->port[i]); 352 - kfree(priv); 353 - } 341 + priv = usb_get_serial_port_data(port); 342 + kfree(priv); 343 + 344 + return 0; 354 345 } 355 346 356 347 static struct usb_serial_driver f81232_device = { ··· 364 373 .tiocmset = f81232_tiocmset, 365 374 .process_read_urb = f81232_process_read_urb, 366 375 .read_int_callback = f81232_read_int_callback, 367 - .attach = f81232_startup, 368 - .release = f81232_release, 376 + .port_probe = f81232_port_probe, 377 + .port_remove = f81232_port_remove, 369 378 }; 370 379 371 380 static struct usb_serial_driver * const serial_drivers[] = {
+7 -17
drivers/usb/serial/garmin_gps.c
··· 1405 1405 1406 1406 1407 1407 1408 - static int garmin_attach(struct usb_serial *serial) 1408 + static int garmin_port_probe(struct usb_serial_port *port) 1409 1409 { 1410 - int status = 0; 1411 - struct usb_serial_port *port = serial->port[0]; 1412 - struct garmin_data *garmin_data_p = NULL; 1410 + int status; 1411 + struct garmin_data *garmin_data_p; 1413 1412 1414 1413 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); 1415 1414 if (garmin_data_p == NULL) { ··· 1433 1434 } 1434 1435 1435 1436 1436 - static void garmin_disconnect(struct usb_serial *serial) 1437 + static int garmin_port_remove(struct usb_serial_port *port) 1437 1438 { 1438 - struct usb_serial_port *port = serial->port[0]; 1439 1439 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1440 1440 1441 1441 usb_kill_urb(port->interrupt_in_urb); 1442 1442 del_timer_sync(&garmin_data_p->timer); 1443 - } 1444 - 1445 - 1446 - static void garmin_release(struct usb_serial *serial) 1447 - { 1448 - struct usb_serial_port *port = serial->port[0]; 1449 - struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1450 - 1451 1443 kfree(garmin_data_p); 1444 + return 0; 1452 1445 } 1453 1446 1454 1447 ··· 1457 1466 .close = garmin_close, 1458 1467 .throttle = garmin_throttle, 1459 1468 .unthrottle = garmin_unthrottle, 1460 - .attach = garmin_attach, 1461 - .disconnect = garmin_disconnect, 1462 - .release = garmin_release, 1469 + .port_probe = garmin_port_probe, 1470 + .port_remove = garmin_port_remove, 1463 1471 .write = garmin_write, 1464 1472 .write_room = garmin_write_room, 1465 1473 .write_bulk_callback = garmin_write_bulk_callback,
+29 -25
drivers/usb/serial/io_edgeport.c
··· 225 225 static int edge_startup(struct usb_serial *serial); 226 226 static void edge_disconnect(struct usb_serial *serial); 227 227 static void edge_release(struct usb_serial *serial); 228 + static int edge_port_probe(struct usb_serial_port *port); 229 + static int edge_port_remove(struct usb_serial_port *port); 228 230 229 231 #include "io_tables.h" /* all of the devices that this driver supports */ 230 232 ··· 2877 2875 static int edge_startup(struct usb_serial *serial) 2878 2876 { 2879 2877 struct edgeport_serial *edge_serial; 2880 - struct edgeport_port *edge_port; 2881 2878 struct usb_device *dev; 2882 2879 struct device *ddev = &serial->dev->dev; 2883 - int i, j; 2880 + int i; 2884 2881 int response; 2885 2882 bool interrupt_in_found; 2886 2883 bool bulk_in_found; ··· 2961 2960 2962 2961 /* we set up the pointers to the endpoints in the edge_open function, 2963 2962 * as the structures aren't created yet. */ 2964 - 2965 - /* set up our port private structures */ 2966 - for (i = 0; i < serial->num_ports; ++i) { 2967 - edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); 2968 - if (edge_port == NULL) { 2969 - dev_err(ddev, "%s - Out of memory\n", __func__); 2970 - for (j = 0; j < i; ++j) { 2971 - kfree(usb_get_serial_port_data(serial->port[j])); 2972 - usb_set_serial_port_data(serial->port[j], 2973 - NULL); 2974 - } 2975 - usb_set_serial_data(serial, NULL); 2976 - kfree(edge_serial); 2977 - return -ENOMEM; 2978 - } 2979 - spin_lock_init(&edge_port->ep_lock); 2980 - edge_port->port = serial->port[i]; 2981 - usb_set_serial_port_data(serial->port[i], edge_port); 2982 - } 2983 2963 2984 2964 response = 0; 2985 2965 ··· 3102 3120 static void edge_release(struct usb_serial *serial) 3103 3121 { 3104 3122 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); 3105 - int i; 3106 - 3107 - for (i = 0; i < serial->num_ports; ++i) 3108 - kfree(usb_get_serial_port_data(serial->port[i])); 3109 3123 3110 3124 kfree(edge_serial); 3125 + } 3126 + 3127 + static int edge_port_probe(struct usb_serial_port *port) 3128 + { 3129 + struct edgeport_port *edge_port; 3130 + 3131 + edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL); 3132 + if (!edge_port) 3133 + return -ENOMEM; 3134 + 3135 + spin_lock_init(&edge_port->ep_lock); 3136 + edge_port->port = port; 3137 + 3138 + usb_set_serial_port_data(port, edge_port); 3139 + 3140 + return 0; 3141 + } 3142 + 3143 + static int edge_port_remove(struct usb_serial_port *port) 3144 + { 3145 + struct edgeport_port *edge_port; 3146 + 3147 + edge_port = usb_get_serial_port_data(port); 3148 + kfree(edge_port); 3149 + 3150 + return 0; 3111 3151 } 3112 3152 3113 3153 module_usb_serial_driver(serial_drivers, id_table_combined);
+8
drivers/usb/serial/io_tables.h
··· 110 110 .attach = edge_startup, 111 111 .disconnect = edge_disconnect, 112 112 .release = edge_release, 113 + .port_probe = edge_port_probe, 114 + .port_remove = edge_port_remove, 113 115 .ioctl = edge_ioctl, 114 116 .set_termios = edge_set_termios, 115 117 .tiocmget = edge_tiocmget, ··· 141 139 .attach = edge_startup, 142 140 .disconnect = edge_disconnect, 143 141 .release = edge_release, 142 + .port_probe = edge_port_probe, 143 + .port_remove = edge_port_remove, 144 144 .ioctl = edge_ioctl, 145 145 .set_termios = edge_set_termios, 146 146 .tiocmget = edge_tiocmget, ··· 172 168 .attach = edge_startup, 173 169 .disconnect = edge_disconnect, 174 170 .release = edge_release, 171 + .port_probe = edge_port_probe, 172 + .port_remove = edge_port_remove, 175 173 .ioctl = edge_ioctl, 176 174 .set_termios = edge_set_termios, 177 175 .tiocmget = edge_tiocmget, ··· 203 197 .attach = edge_startup, 204 198 .disconnect = edge_disconnect, 205 199 .release = edge_release, 200 + .port_probe = edge_port_probe, 201 + .port_remove = edge_port_remove, 206 202 .ioctl = edge_ioctl, 207 203 .set_termios = edge_set_termios, 208 204 .tiocmget = edge_tiocmget,
+49 -50
drivers/usb/serial/io_ti.c
··· 2532 2532 static int edge_startup(struct usb_serial *serial) 2533 2533 { 2534 2534 struct edgeport_serial *edge_serial; 2535 - struct edgeport_port *edge_port; 2536 - struct usb_device *dev; 2537 2535 int status; 2538 - int i; 2539 - 2540 - dev = serial->dev; 2541 2536 2542 2537 /* create our private serial structure */ 2543 2538 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); ··· 2550 2555 return status; 2551 2556 } 2552 2557 2553 - /* set up our port private structures */ 2554 - for (i = 0; i < serial->num_ports; ++i) { 2555 - edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); 2556 - if (edge_port == NULL) { 2557 - dev_err(&serial->dev->dev, "%s - Out of memory\n", 2558 - __func__); 2559 - goto cleanup; 2560 - } 2561 - spin_lock_init(&edge_port->ep_lock); 2562 - if (kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE, 2563 - GFP_KERNEL)) { 2564 - dev_err(&serial->dev->dev, "%s - Out of memory\n", 2565 - __func__); 2566 - kfree(edge_port); 2567 - goto cleanup; 2568 - } 2569 - edge_port->port = serial->port[i]; 2570 - edge_port->edge_serial = edge_serial; 2571 - usb_set_serial_port_data(serial->port[i], edge_port); 2572 - edge_port->bUartMode = default_uart_mode; 2573 - } 2574 - 2575 2558 return 0; 2576 - 2577 - cleanup: 2578 - for (--i; i >= 0; --i) { 2579 - edge_port = usb_get_serial_port_data(serial->port[i]); 2580 - kfifo_free(&edge_port->write_fifo); 2581 - kfree(edge_port); 2582 - usb_set_serial_port_data(serial->port[i], NULL); 2583 - } 2584 - kfree(edge_serial); 2585 - usb_set_serial_data(serial, NULL); 2586 - return -ENOMEM; 2587 2559 } 2588 2560 2589 2561 static void edge_disconnect(struct usb_serial *serial) ··· 2559 2597 2560 2598 static void edge_release(struct usb_serial *serial) 2561 2599 { 2562 - int i; 2563 - struct edgeport_port *edge_port; 2564 - 2565 - for (i = 0; i < serial->num_ports; ++i) { 2566 - edge_port = usb_get_serial_port_data(serial->port[i]); 2567 - kfifo_free(&edge_port->write_fifo); 2568 - kfree(edge_port); 2569 - } 2570 2600 kfree(usb_get_serial_data(serial)); 2571 2601 } 2572 2602 2603 + static int edge_port_probe(struct usb_serial_port *port) 2604 + { 2605 + struct edgeport_port *edge_port; 2606 + int ret; 2607 + 2608 + edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL); 2609 + if (!edge_port) 2610 + return -ENOMEM; 2611 + 2612 + ret = kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE, 2613 + GFP_KERNEL); 2614 + if (ret) { 2615 + kfree(edge_port); 2616 + return -ENOMEM; 2617 + } 2618 + 2619 + spin_lock_init(&edge_port->ep_lock); 2620 + edge_port->port = port; 2621 + edge_port->edge_serial = usb_get_serial_data(port->serial); 2622 + edge_port->bUartMode = default_uart_mode; 2623 + 2624 + usb_set_serial_port_data(port, edge_port); 2625 + 2626 + ret = edge_create_sysfs_attrs(port); 2627 + if (ret) { 2628 + kfifo_free(&edge_port->write_fifo); 2629 + kfree(edge_port); 2630 + return ret; 2631 + } 2632 + 2633 + return 0; 2634 + } 2635 + 2636 + static int edge_port_remove(struct usb_serial_port *port) 2637 + { 2638 + struct edgeport_port *edge_port; 2639 + 2640 + edge_port = usb_get_serial_port_data(port); 2641 + 2642 + edge_remove_sysfs_attrs(port); 2643 + kfifo_free(&edge_port->write_fifo); 2644 + kfree(edge_port); 2645 + 2646 + return 0; 2647 + } 2573 2648 2574 2649 /* Sysfs Attributes */ 2575 2650 ··· 2666 2667 .attach = edge_startup, 2667 2668 .disconnect = edge_disconnect, 2668 2669 .release = edge_release, 2669 - .port_probe = edge_create_sysfs_attrs, 2670 - .port_remove = edge_remove_sysfs_attrs, 2670 + .port_probe = edge_port_probe, 2671 + .port_remove = edge_port_remove, 2671 2672 .ioctl = edge_ioctl, 2672 2673 .set_termios = edge_set_termios, 2673 2674 .tiocmget = edge_tiocmget, ··· 2697 2698 .attach = edge_startup, 2698 2699 .disconnect = edge_disconnect, 2699 2700 .release = edge_release, 2700 - .port_probe = edge_create_sysfs_attrs, 2701 - .port_remove = edge_remove_sysfs_attrs, 2701 + .port_probe = edge_port_probe, 2702 + .port_remove = edge_port_remove, 2702 2703 .ioctl = edge_ioctl, 2703 2704 .set_termios = edge_set_termios, 2704 2705 .tiocmget = edge_tiocmget,
+34 -42
drivers/usb/serial/iuu_phoenix.c
··· 53 53 static bool xmas; 54 54 static int vcc_default = 5; 55 55 56 + static int iuu_create_sysfs_attrs(struct usb_serial_port *port); 57 + static int iuu_remove_sysfs_attrs(struct usb_serial_port *port); 56 58 static void read_rxcmd_callback(struct urb *urb); 57 59 58 60 struct iuu_private { ··· 74 72 u32 clk; 75 73 }; 76 74 77 - 78 - static void iuu_free_buf(struct iuu_private *priv) 79 - { 80 - kfree(priv->buf); 81 - kfree(priv->writebuf); 82 - } 83 - 84 - static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv) 85 - { 86 - priv->buf = kzalloc(256, GFP_KERNEL); 87 - priv->writebuf = kzalloc(256, GFP_KERNEL); 88 - if (!priv->buf || !priv->writebuf) { 89 - iuu_free_buf(priv); 90 - dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__); 91 - return -ENOMEM; 92 - } 93 - dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__); 94 - return 0; 95 - } 96 - 97 - static int iuu_startup(struct usb_serial *serial) 75 + static int iuu_port_probe(struct usb_serial_port *port) 98 76 { 99 77 struct iuu_private *priv; 78 + int ret; 100 79 101 80 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); 102 - dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__); 103 81 if (!priv) 104 82 return -ENOMEM; 105 - if (iuu_alloc_buf(serial, priv)) { 83 + 84 + priv->buf = kzalloc(256, GFP_KERNEL); 85 + if (!priv->buf) { 106 86 kfree(priv); 107 87 return -ENOMEM; 108 88 } 89 + 90 + priv->writebuf = kzalloc(256, GFP_KERNEL); 91 + if (!priv->writebuf) { 92 + kfree(priv->buf); 93 + kfree(priv); 94 + return -ENOMEM; 95 + } 96 + 109 97 priv->vcc = vcc_default; 110 98 spin_lock_init(&priv->lock); 111 99 init_waitqueue_head(&priv->delta_msr_wait); 112 - usb_set_serial_port_data(serial->port[0], priv); 100 + 101 + usb_set_serial_port_data(port, priv); 102 + 103 + ret = iuu_create_sysfs_attrs(port); 104 + if (ret) { 105 + kfree(priv->writebuf); 106 + kfree(priv->buf); 107 + kfree(priv); 108 + return ret; 109 + } 110 + 113 111 return 0; 114 112 } 115 113 116 - /* Release function */ 117 - static void iuu_release(struct usb_serial *serial) 114 + static int iuu_port_remove(struct usb_serial_port *port) 118 115 { 119 - struct usb_serial_port *port = serial->port[0]; 120 116 struct iuu_private *priv = usb_get_serial_port_data(port); 121 - if (!port) 122 - return; 123 117 124 - if (priv) { 125 - iuu_free_buf(priv); 126 - dev_dbg(&port->dev, "%s - I will free all\n", __func__); 127 - usb_set_serial_port_data(port, NULL); 118 + iuu_remove_sysfs_attrs(port); 119 + kfree(priv->writebuf); 120 + kfree(priv->buf); 121 + kfree(priv); 128 122 129 - dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__); 130 - kfree(priv); 131 - 132 - dev_dbg(&port->dev, "%s priv is now kfree\n", __func__); 133 - } 123 + return 0; 134 124 } 135 125 136 126 static int iuu_tiocmset(struct tty_struct *tty, ··· 1209 1215 .num_ports = 1, 1210 1216 .bulk_in_size = 512, 1211 1217 .bulk_out_size = 512, 1212 - .port_probe = iuu_create_sysfs_attrs, 1213 - .port_remove = iuu_remove_sysfs_attrs, 1214 1218 .open = iuu_open, 1215 1219 .close = iuu_close, 1216 1220 .write = iuu_uart_write, ··· 1217 1225 .tiocmset = iuu_tiocmset, 1218 1226 .set_termios = iuu_set_termios, 1219 1227 .init_termios = iuu_init_termios, 1220 - .attach = iuu_startup, 1221 - .release = iuu_release, 1228 + .port_probe = iuu_port_probe, 1229 + .port_remove = iuu_port_remove, 1222 1230 }; 1223 1231 1224 1232 static struct usb_serial_driver * const serial_drivers[] = {
+17 -13
drivers/usb/serial/keyspan_pda.c
··· 713 713 MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 714 714 #endif 715 715 716 - static int keyspan_pda_startup(struct usb_serial *serial) 716 + static int keyspan_pda_port_probe(struct usb_serial_port *port) 717 717 { 718 718 719 719 struct keyspan_pda_private *priv; 720 720 721 - /* allocate the private data structures for all ports. Well, for all 722 - one ports. */ 723 - 724 721 priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); 725 722 if (!priv) 726 - return 1; /* error */ 727 - usb_set_serial_port_data(serial->port[0], priv); 728 - init_waitqueue_head(&serial->port[0]->write_wait); 723 + return -ENOMEM; 724 + 729 725 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); 730 726 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); 731 - priv->serial = serial; 732 - priv->port = serial->port[0]; 727 + priv->serial = port->serial; 728 + priv->port = port; 729 + 730 + usb_set_serial_port_data(port, priv); 731 + 733 732 return 0; 734 733 } 735 734 736 - static void keyspan_pda_release(struct usb_serial *serial) 735 + static int keyspan_pda_port_remove(struct usb_serial_port *port) 737 736 { 738 - kfree(usb_get_serial_port_data(serial->port[0])); 737 + struct keyspan_pda_private *priv; 738 + 739 + priv = usb_get_serial_port_data(port); 740 + kfree(priv); 741 + 742 + return 0; 739 743 } 740 744 741 745 #ifdef KEYSPAN ··· 790 786 .break_ctl = keyspan_pda_break_ctl, 791 787 .tiocmget = keyspan_pda_tiocmget, 792 788 .tiocmset = keyspan_pda_tiocmset, 793 - .attach = keyspan_pda_startup, 794 - .release = keyspan_pda_release, 789 + .port_probe = keyspan_pda_port_probe, 790 + .port_remove = keyspan_pda_port_remove, 795 791 }; 796 792 797 793 static struct usb_serial_driver * const serial_drivers[] = {
+24 -44
drivers/usb/serial/kl5kusb105.c
··· 60 60 /* 61 61 * Function prototypes 62 62 */ 63 - static int klsi_105_startup(struct usb_serial *serial); 64 - static void klsi_105_release(struct usb_serial *serial); 63 + static int klsi_105_port_probe(struct usb_serial_port *port); 64 + static int klsi_105_port_remove(struct usb_serial_port *port); 65 65 static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); 66 66 static void klsi_105_close(struct usb_serial_port *port); 67 67 static void klsi_105_set_termios(struct tty_struct *tty, ··· 99 99 /*.break_ctl = klsi_105_break_ctl,*/ 100 100 .tiocmget = klsi_105_tiocmget, 101 101 .tiocmset = klsi_105_tiocmset, 102 - .attach = klsi_105_startup, 103 - .release = klsi_105_release, 102 + .port_probe = klsi_105_port_probe, 103 + .port_remove = klsi_105_port_remove, 104 104 .throttle = usb_serial_generic_throttle, 105 105 .unthrottle = usb_serial_generic_unthrottle, 106 106 .process_read_urb = klsi_105_process_read_urb, ··· 223 223 * Driver's tty interface functions 224 224 */ 225 225 226 - static int klsi_105_startup(struct usb_serial *serial) 226 + static int klsi_105_port_probe(struct usb_serial_port *port) 227 227 { 228 228 struct klsi_105_private *priv; 229 - int i; 230 229 231 - /* check if we support the product id (see keyspan.c) 232 - * FIXME 233 - */ 230 + priv = kmalloc(sizeof(*priv), GFP_KERNEL); 231 + if (!priv) 232 + return -ENOMEM; 234 233 235 - /* allocate the private data structure */ 236 - for (i = 0; i < serial->num_ports; i++) { 237 - priv = kmalloc(sizeof(struct klsi_105_private), 238 - GFP_KERNEL); 239 - if (!priv) { 240 - dev_dbg(&serial->interface->dev, 241 - "%s - kmalloc for klsi_105_private failed.\n", 242 - __func__); 243 - i--; 244 - goto err_cleanup; 245 - } 246 - /* set initial values for control structures */ 247 - priv->cfg.pktlen = 5; 248 - priv->cfg.baudrate = kl5kusb105a_sio_b9600; 249 - priv->cfg.databits = kl5kusb105a_dtb_8; 250 - priv->cfg.unknown1 = 0; 251 - priv->cfg.unknown2 = 1; 234 + /* set initial values for control structures */ 235 + priv->cfg.pktlen = 5; 236 + priv->cfg.baudrate = kl5kusb105a_sio_b9600; 237 + priv->cfg.databits = kl5kusb105a_dtb_8; 238 + priv->cfg.unknown1 = 0; 239 + priv->cfg.unknown2 = 1; 252 240 253 - priv->line_state = 0; 241 + priv->line_state = 0; 254 242 255 - usb_set_serial_port_data(serial->port[i], priv); 243 + spin_lock_init(&priv->lock); 256 244 257 - spin_lock_init(&priv->lock); 245 + /* priv->termios is left uninitialized until port opening */ 258 246 259 - /* priv->termios is left uninitialized until port opening */ 260 - init_waitqueue_head(&serial->port[i]->write_wait); 261 - } 247 + usb_set_serial_port_data(port, priv); 262 248 263 249 return 0; 264 - 265 - err_cleanup: 266 - for (; i >= 0; i--) { 267 - priv = usb_get_serial_port_data(serial->port[i]); 268 - kfree(priv); 269 - usb_set_serial_port_data(serial->port[i], NULL); 270 - } 271 - return -ENOMEM; 272 250 } 273 251 274 - static void klsi_105_release(struct usb_serial *serial) 252 + static int klsi_105_port_remove(struct usb_serial_port *port) 275 253 { 276 - int i; 254 + struct klsi_105_private *priv; 277 255 278 - for (i = 0; i < serial->num_ports; ++i) 279 - kfree(usb_get_serial_port_data(serial->port[i])); 256 + priv = usb_get_serial_port_data(port); 257 + kfree(priv); 258 + 259 + return 0; 280 260 } 281 261 282 262 static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
+13 -10
drivers/usb/serial/kobil_sct.c
··· 54 54 55 55 56 56 /* Function prototypes */ 57 - static int kobil_startup(struct usb_serial *serial); 58 - static void kobil_release(struct usb_serial *serial); 57 + static int kobil_port_probe(struct usb_serial_port *probe); 58 + static int kobil_port_remove(struct usb_serial_port *probe); 59 59 static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); 60 60 static void kobil_close(struct usb_serial_port *port); 61 61 static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, ··· 89 89 .description = "KOBIL USB smart card terminal", 90 90 .id_table = id_table, 91 91 .num_ports = 1, 92 - .attach = kobil_startup, 93 - .release = kobil_release, 92 + .port_probe = kobil_port_probe, 93 + .port_remove = kobil_port_remove, 94 94 .ioctl = kobil_ioctl, 95 95 .set_termios = kobil_set_termios, 96 96 .init_termios = kobil_init_termios, ··· 117 117 }; 118 118 119 119 120 - static int kobil_startup(struct usb_serial *serial) 120 + static int kobil_port_probe(struct usb_serial_port *port) 121 121 { 122 122 int i; 123 + struct usb_serial *serial = port->serial; 123 124 struct kobil_private *priv; 124 125 struct usb_device *pdev; 125 126 struct usb_host_config *actconfig; ··· 150 149 dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); 151 150 break; 152 151 } 153 - usb_set_serial_port_data(serial->port[0], priv); 152 + usb_set_serial_port_data(port, priv); 154 153 155 154 /* search for the necessary endpoints */ 156 155 pdev = serial->dev; ··· 180 179 } 181 180 182 181 183 - static void kobil_release(struct usb_serial *serial) 182 + static int kobil_port_remove(struct usb_serial_port *port) 184 183 { 185 - int i; 184 + struct kobil_private *priv; 186 185 187 - for (i = 0; i < serial->num_ports; ++i) 188 - kfree(usb_get_serial_port_data(serial->port[i])); 186 + priv = usb_get_serial_port_data(port); 187 + kfree(priv); 188 + 189 + return 0; 189 190 } 190 191 191 192 static void kobil_init_termios(struct tty_struct *tty)
+64 -20
drivers/usb/serial/option.c
··· 503 503 .reserved = BIT(5), 504 504 }; 505 505 506 + static const struct option_blacklist_info net_intf6_blacklist = { 507 + .reserved = BIT(6), 508 + }; 509 + 506 510 static const struct option_blacklist_info zte_mf626_blacklist = { 507 511 .sendsetup = BIT(0) | BIT(1), 508 512 .reserved = BIT(4), 513 + }; 514 + 515 + static const struct option_blacklist_info zte_1255_blacklist = { 516 + .reserved = BIT(3) | BIT(4), 509 517 }; 510 518 511 519 static const struct usb_device_id option_ids[] = { ··· 861 853 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff), 862 854 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 863 855 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) }, 864 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff) }, 865 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff) }, 856 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff), 857 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 858 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff), 859 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 866 860 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) }, 867 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff) }, 868 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff) }, 869 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff) }, 870 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff) }, 861 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff), 862 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 863 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff), 864 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 865 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff), 866 + .driver_info = (kernel_ulong_t)&net_intf6_blacklist }, 867 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff), 868 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 871 869 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, 872 870 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, 873 871 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, ··· 886 872 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, 887 873 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff), 888 874 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 889 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, 875 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff), 876 + .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 890 877 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, 891 878 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, 892 879 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, ··· 895 880 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 896 881 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), 897 882 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 883 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ 884 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 885 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */ 886 + .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 887 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */ 888 + .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 898 889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), 899 890 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 900 891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), 901 892 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 902 893 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), 903 894 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 904 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, 895 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff), 896 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 897 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff), 898 + .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 905 899 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 906 900 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, 907 901 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) }, ··· 1026 1002 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) }, 1027 1003 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) }, 1028 1004 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) }, 1029 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff) }, 1005 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff), 1006 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1030 1007 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) }, 1031 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff) }, 1008 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff), 1009 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1032 1010 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) }, 1033 1011 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) }, 1034 1012 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) }, 1035 1013 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) }, 1036 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff) }, 1014 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff), 1015 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1037 1016 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) }, 1038 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff) }, 1039 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff) }, 1040 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff) }, 1017 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff), 1018 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1019 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff), 1020 + .driver_info = (kernel_ulong_t)&zte_1255_blacklist }, 1021 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff), 1022 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1041 1023 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) }, 1042 1024 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) }, 1043 1025 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) }, ··· 1088 1058 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, 1089 1059 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, 1090 1060 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, 1061 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff), 1062 + .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1091 1063 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), 1064 + .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1065 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff), 1066 + .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1067 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff), 1068 + .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1069 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */ 1092 1070 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1093 1071 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 1094 1072 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, ··· 1109 1071 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, 1110 1072 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, 1111 1073 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) }, 1112 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) }, 1113 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff) }, 1114 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) }, 1074 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff), 1075 + .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, 1076 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff), 1077 + .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1078 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff), 1079 + .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1115 1080 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) }, 1116 1081 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) }, 1117 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) }, 1082 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff), 1083 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1118 1084 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) }, 1119 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) }, 1120 - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) }, 1085 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff), 1086 + .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1087 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff), 1088 + .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, 1121 1089 1122 1090 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, 1123 1091 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
+25 -37
drivers/usb/serial/oti6858.c
··· 137 137 static int oti6858_tiocmget(struct tty_struct *tty); 138 138 static int oti6858_tiocmset(struct tty_struct *tty, 139 139 unsigned int set, unsigned int clear); 140 - static int oti6858_startup(struct usb_serial *serial); 141 - static void oti6858_release(struct usb_serial *serial); 140 + static int oti6858_port_probe(struct usb_serial_port *port); 141 + static int oti6858_port_remove(struct usb_serial_port *port); 142 142 143 143 /* device info */ 144 144 static struct usb_serial_driver oti6858_device = { ··· 161 161 .write_bulk_callback = oti6858_write_bulk_callback, 162 162 .write_room = oti6858_write_room, 163 163 .chars_in_buffer = oti6858_chars_in_buffer, 164 - .attach = oti6858_startup, 165 - .release = oti6858_release, 164 + .port_probe = oti6858_port_probe, 165 + .port_remove = oti6858_port_remove, 166 166 }; 167 167 168 168 static struct usb_serial_driver * const serial_drivers[] = { ··· 331 331 usb_serial_port_softint(port); 332 332 } 333 333 334 - static int oti6858_startup(struct usb_serial *serial) 334 + static int oti6858_port_probe(struct usb_serial_port *port) 335 335 { 336 - struct usb_serial_port *port = serial->port[0]; 337 336 struct oti6858_private *priv; 338 - int i; 339 337 340 - for (i = 0; i < serial->num_ports; ++i) { 341 - priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL); 342 - if (!priv) 343 - break; 338 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 339 + if (!priv) 340 + return -ENOMEM; 344 341 345 - spin_lock_init(&priv->lock); 346 - init_waitqueue_head(&priv->intr_wait); 347 - /* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */ 348 - /* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */ 349 - priv->port = port; 350 - INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); 351 - INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); 342 + spin_lock_init(&priv->lock); 343 + init_waitqueue_head(&priv->intr_wait); 344 + priv->port = port; 345 + INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); 346 + INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); 352 347 353 - usb_set_serial_port_data(serial->port[i], priv); 354 - } 355 - if (i == serial->num_ports) 356 - return 0; 348 + usb_set_serial_port_data(port, priv); 357 349 358 - for (--i; i >= 0; --i) { 359 - priv = usb_get_serial_port_data(serial->port[i]); 360 - kfree(priv); 361 - usb_set_serial_port_data(serial->port[i], NULL); 362 - } 363 - return -ENOMEM; 350 + return 0; 351 + } 352 + 353 + static int oti6858_port_remove(struct usb_serial_port *port) 354 + { 355 + struct oti6858_private *priv; 356 + 357 + priv = usb_get_serial_port_data(port); 358 + kfree(priv); 359 + 360 + return 0; 364 361 } 365 362 366 363 static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, ··· 704 707 break; 705 708 } 706 709 return -ENOIOCTLCMD; 707 - } 708 - 709 - 710 - static void oti6858_release(struct usb_serial *serial) 711 - { 712 - int i; 713 - 714 - for (i = 0; i < serial->num_ports; ++i) 715 - kfree(usb_get_serial_port_data(serial->port[i])); 716 710 } 717 711 718 712 static void oti6858_read_int_callback(struct urb *urb)
+54 -36
drivers/usb/serial/pl2303.c
··· 133 133 HX, /* HX version of the pl2303 chip */ 134 134 }; 135 135 136 + struct pl2303_serial_private { 137 + enum pl2303_type type; 138 + }; 139 + 136 140 struct pl2303_private { 137 141 spinlock_t lock; 138 142 wait_queue_head_t delta_msr_wait; 139 143 u8 line_control; 140 144 u8 line_status; 141 - enum pl2303_type type; 142 145 }; 143 146 144 147 static int pl2303_vendor_read(__u16 value, __u16 index, ··· 170 167 171 168 static int pl2303_startup(struct usb_serial *serial) 172 169 { 173 - struct pl2303_private *priv; 170 + struct pl2303_serial_private *spriv; 174 171 enum pl2303_type type = type_0; 175 172 unsigned char *buf; 176 - int i; 173 + 174 + spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 175 + if (!spriv) 176 + return -ENOMEM; 177 177 178 178 buf = kmalloc(10, GFP_KERNEL); 179 - if (buf == NULL) 179 + if (!buf) { 180 + kfree(spriv); 180 181 return -ENOMEM; 182 + } 181 183 182 184 if (serial->dev->descriptor.bDeviceClass == 0x02) 183 185 type = type_0; ··· 194 186 type = type_1; 195 187 dev_dbg(&serial->interface->dev, "device type: %d\n", type); 196 188 197 - for (i = 0; i < serial->num_ports; ++i) { 198 - priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL); 199 - if (!priv) 200 - goto cleanup; 201 - spin_lock_init(&priv->lock); 202 - init_waitqueue_head(&priv->delta_msr_wait); 203 - priv->type = type; 204 - usb_set_serial_port_data(serial->port[i], priv); 205 - } 189 + spriv->type = type; 190 + usb_set_serial_data(serial, spriv); 206 191 207 192 pl2303_vendor_read(0x8484, 0, serial, buf); 208 193 pl2303_vendor_write(0x0404, 0, serial); ··· 214 213 215 214 kfree(buf); 216 215 return 0; 216 + } 217 217 218 - cleanup: 219 - kfree(buf); 220 - for (--i; i >= 0; --i) { 221 - priv = usb_get_serial_port_data(serial->port[i]); 222 - kfree(priv); 223 - usb_set_serial_port_data(serial->port[i], NULL); 224 - } 225 - return -ENOMEM; 218 + static void pl2303_release(struct usb_serial *serial) 219 + { 220 + struct pl2303_serial_private *spriv; 221 + 222 + spriv = usb_get_serial_data(serial); 223 + kfree(spriv); 224 + } 225 + 226 + static int pl2303_port_probe(struct usb_serial_port *port) 227 + { 228 + struct pl2303_private *priv; 229 + 230 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 231 + if (!priv) 232 + return -ENOMEM; 233 + 234 + spin_lock_init(&priv->lock); 235 + init_waitqueue_head(&priv->delta_msr_wait); 236 + 237 + usb_set_serial_port_data(port, priv); 238 + 239 + return 0; 240 + } 241 + 242 + static int pl2303_port_remove(struct usb_serial_port *port) 243 + { 244 + struct pl2303_private *priv; 245 + 246 + priv = usb_get_serial_port_data(port); 247 + kfree(priv); 248 + 249 + return 0; 226 250 } 227 251 228 252 static int set_control_lines(struct usb_device *dev, u8 value) ··· 266 240 struct usb_serial_port *port, struct ktermios *old_termios) 267 241 { 268 242 struct usb_serial *serial = port->serial; 243 + struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 269 244 struct pl2303_private *priv = usb_get_serial_port_data(port); 270 245 unsigned long flags; 271 246 unsigned int cflag; ··· 350 323 } 351 324 if (baud > 1228800) { 352 325 /* type_0, type_1 only support up to 1228800 baud */ 353 - if (priv->type != HX) 326 + if (spriv->type != HX) 354 327 baud = 1228800; 355 328 else if (baud > 6000000) 356 329 baud = 6000000; ··· 453 426 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); 454 427 455 428 if (cflag & CRTSCTS) { 456 - if (priv->type == HX) 429 + if (spriv->type == HX) 457 430 pl2303_vendor_write(0x0, 0x61, serial); 458 431 else 459 432 pl2303_vendor_write(0x0, 0x41, serial); ··· 495 468 { 496 469 struct ktermios tmp_termios; 497 470 struct usb_serial *serial = port->serial; 498 - struct pl2303_private *priv = usb_get_serial_port_data(port); 471 + struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 499 472 int result; 500 473 501 - if (priv->type != HX) { 474 + if (spriv->type != HX) { 502 475 usb_clear_halt(serial->dev, port->write_urb->pipe); 503 476 usb_clear_halt(serial->dev, port->read_urb->pipe); 504 477 } else { ··· 682 655 dev_err(&port->dev, "error sending break = %d\n", result); 683 656 } 684 657 685 - static void pl2303_release(struct usb_serial *serial) 686 - { 687 - int i; 688 - struct pl2303_private *priv; 689 - 690 - for (i = 0; i < serial->num_ports; ++i) { 691 - priv = usb_get_serial_port_data(serial->port[i]); 692 - kfree(priv); 693 - } 694 - } 695 - 696 658 static void pl2303_update_line_status(struct usb_serial_port *port, 697 659 unsigned char *data, 698 660 unsigned int actual_length) ··· 843 827 .read_int_callback = pl2303_read_int_callback, 844 828 .attach = pl2303_startup, 845 829 .release = pl2303_release, 830 + .port_probe = pl2303_port_probe, 831 + .port_remove = pl2303_port_remove, 846 832 }; 847 833 848 834 static struct usb_serial_driver * const serial_drivers[] = {
+18 -28
drivers/usb/serial/spcp8x5.c
··· 157 157 u8 line_status; 158 158 }; 159 159 160 - /* desc : when device plug in,this function would be called. 161 - * thanks to usb_serial subsystem,then do almost every things for us. And what 162 - * we should do just alloc the buffer */ 163 - static int spcp8x5_startup(struct usb_serial *serial) 160 + static int spcp8x5_port_probe(struct usb_serial_port *port) 164 161 { 162 + struct usb_serial *serial = port->serial; 165 163 struct spcp8x5_private *priv; 166 - int i; 167 164 enum spcp8x5_type type = SPCP825_007_TYPE; 168 165 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 169 166 ··· 177 180 type = SPCP825_PHILIP_TYPE; 178 181 dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type); 179 182 180 - for (i = 0; i < serial->num_ports; ++i) { 181 - priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL); 182 - if (!priv) 183 - goto cleanup; 183 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 184 + if (!priv) 185 + return -ENOMEM; 184 186 185 - spin_lock_init(&priv->lock); 186 - init_waitqueue_head(&priv->delta_msr_wait); 187 - priv->type = type; 188 - usb_set_serial_port_data(serial->port[i] , priv); 189 - } 187 + spin_lock_init(&priv->lock); 188 + init_waitqueue_head(&priv->delta_msr_wait); 189 + priv->type = type; 190 + 191 + usb_set_serial_port_data(port , priv); 190 192 191 193 return 0; 192 - cleanup: 193 - for (--i; i >= 0; --i) { 194 - priv = usb_get_serial_port_data(serial->port[i]); 195 - kfree(priv); 196 - usb_set_serial_port_data(serial->port[i] , NULL); 197 - } 198 - return -ENOMEM; 199 194 } 200 195 201 - /* call when the device plug out. free all the memory alloced by probe */ 202 - static void spcp8x5_release(struct usb_serial *serial) 196 + static int spcp8x5_port_remove(struct usb_serial_port *port) 203 197 { 204 - int i; 198 + struct spcp8x5_private *priv; 205 199 206 - for (i = 0; i < serial->num_ports; i++) 207 - kfree(usb_get_serial_port_data(serial->port[i])); 200 + priv = usb_get_serial_port_data(port); 201 + kfree(priv); 202 + 203 + return 0; 208 204 } 209 205 210 206 /* set the modem control line of the device. ··· 639 649 .ioctl = spcp8x5_ioctl, 640 650 .tiocmget = spcp8x5_tiocmget, 641 651 .tiocmset = spcp8x5_tiocmset, 642 - .attach = spcp8x5_startup, 643 - .release = spcp8x5_release, 652 + .port_probe = spcp8x5_port_probe, 653 + .port_remove = spcp8x5_port_remove, 644 654 .process_read_urb = spcp8x5_process_read_urb, 645 655 }; 646 656
+20 -14
drivers/usb/serial/ssu100.c
··· 67 67 struct async_icount icount; 68 68 }; 69 69 70 - static void ssu100_release(struct usb_serial *serial) 71 - { 72 - struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port); 73 - 74 - kfree(priv); 75 - } 76 - 77 70 static inline int ssu100_control_msg(struct usb_device *dev, 78 71 u8 request, u16 data, u16 index) 79 72 { ··· 435 442 436 443 static int ssu100_attach(struct usb_serial *serial) 437 444 { 445 + return ssu100_initdevice(serial->dev); 446 + } 447 + 448 + static int ssu100_port_probe(struct usb_serial_port *port) 449 + { 438 450 struct ssu100_port_private *priv; 439 - struct usb_serial_port *port = *serial->port; 440 451 441 452 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 442 - if (!priv) { 443 - dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__, 444 - sizeof(*priv)); 453 + if (!priv) 445 454 return -ENOMEM; 446 - } 447 455 448 456 spin_lock_init(&priv->status_lock); 449 457 init_waitqueue_head(&priv->delta_msr_wait); 458 + 450 459 usb_set_serial_port_data(port, priv); 451 460 452 - return ssu100_initdevice(serial->dev); 461 + return 0; 462 + } 463 + 464 + static int ssu100_port_remove(struct usb_serial_port *port) 465 + { 466 + struct ssu100_port_private *priv; 467 + 468 + priv = usb_get_serial_port_data(port); 469 + kfree(priv); 470 + 471 + return 0; 453 472 } 454 473 455 474 static int ssu100_tiocmget(struct tty_struct *tty) ··· 652 647 .open = ssu100_open, 653 648 .close = ssu100_close, 654 649 .attach = ssu100_attach, 655 - .release = ssu100_release, 650 + .port_probe = ssu100_port_probe, 651 + .port_remove = ssu100_port_remove, 656 652 .dtr_rts = ssu100_dtr_rts, 657 653 .process_read_urb = ssu100_process_read_urb, 658 654 .tiocmget = ssu100_tiocmget,
+45 -47
drivers/usb/serial/ti_usb_3410_5052.c
··· 97 97 98 98 static int ti_startup(struct usb_serial *serial); 99 99 static void ti_release(struct usb_serial *serial); 100 + static int ti_port_probe(struct usb_serial_port *port); 101 + static int ti_port_remove(struct usb_serial_port *port); 100 102 static int ti_open(struct tty_struct *tty, struct usb_serial_port *port); 101 103 static void ti_close(struct usb_serial_port *port); 102 104 static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, ··· 223 221 .num_ports = 1, 224 222 .attach = ti_startup, 225 223 .release = ti_release, 224 + .port_probe = ti_port_probe, 225 + .port_remove = ti_port_remove, 226 226 .open = ti_open, 227 227 .close = ti_close, 228 228 .write = ti_write, ··· 253 249 .num_ports = 2, 254 250 .attach = ti_startup, 255 251 .release = ti_release, 252 + .port_probe = ti_port_probe, 253 + .port_remove = ti_port_remove, 256 254 .open = ti_open, 257 255 .close = ti_close, 258 256 .write = ti_write, ··· 353 347 static int ti_startup(struct usb_serial *serial) 354 348 { 355 349 struct ti_device *tdev; 356 - struct ti_port *tport; 357 350 struct usb_device *dev = serial->dev; 358 351 int status; 359 - int i; 360 - 361 352 362 353 dev_dbg(&dev->dev, 363 354 "%s - product 0x%4X, num configurations %d, configuration value %d", ··· 402 399 goto free_tdev; 403 400 } 404 401 405 - /* set up port structures */ 406 - for (i = 0; i < serial->num_ports; ++i) { 407 - tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL); 408 - if (tport == NULL) { 409 - dev_err(&dev->dev, "%s - out of memory\n", __func__); 410 - status = -ENOMEM; 411 - goto free_tports; 412 - } 413 - spin_lock_init(&tport->tp_lock); 414 - tport->tp_uart_base_addr = (i == 0 ? 415 - TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); 416 - tport->tp_closing_wait = closing_wait; 417 - init_waitqueue_head(&tport->tp_msr_wait); 418 - init_waitqueue_head(&tport->tp_write_wait); 419 - if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, 420 - GFP_KERNEL)) { 421 - dev_err(&dev->dev, "%s - out of memory\n", __func__); 422 - kfree(tport); 423 - status = -ENOMEM; 424 - goto free_tports; 425 - } 426 - tport->tp_port = serial->port[i]; 427 - tport->tp_tdev = tdev; 428 - usb_set_serial_port_data(serial->port[i], tport); 429 - tport->tp_uart_mode = 0; /* default is RS232 */ 430 - } 431 - 432 402 return 0; 433 403 434 - free_tports: 435 - for (--i; i >= 0; --i) { 436 - tport = usb_get_serial_port_data(serial->port[i]); 437 - kfifo_free(&tport->write_fifo); 438 - kfree(tport); 439 - usb_set_serial_port_data(serial->port[i], NULL); 440 - } 441 404 free_tdev: 442 405 kfree(tdev); 443 406 usb_set_serial_data(serial, NULL); ··· 413 444 414 445 static void ti_release(struct usb_serial *serial) 415 446 { 416 - int i; 417 447 struct ti_device *tdev = usb_get_serial_data(serial); 418 - struct ti_port *tport; 419 - 420 - for (i = 0; i < serial->num_ports; ++i) { 421 - tport = usb_get_serial_port_data(serial->port[i]); 422 - if (tport) { 423 - kfifo_free(&tport->write_fifo); 424 - kfree(tport); 425 - } 426 - } 427 448 428 449 kfree(tdev); 429 450 } 430 451 452 + static int ti_port_probe(struct usb_serial_port *port) 453 + { 454 + struct ti_port *tport; 455 + 456 + tport = kzalloc(sizeof(*tport), GFP_KERNEL); 457 + if (!tport) 458 + return -ENOMEM; 459 + 460 + spin_lock_init(&tport->tp_lock); 461 + if (port == port->serial->port[0]) 462 + tport->tp_uart_base_addr = TI_UART1_BASE_ADDR; 463 + else 464 + tport->tp_uart_base_addr = TI_UART2_BASE_ADDR; 465 + tport->tp_closing_wait = closing_wait; 466 + init_waitqueue_head(&tport->tp_msr_wait); 467 + init_waitqueue_head(&tport->tp_write_wait); 468 + if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) { 469 + kfree(tport); 470 + return -ENOMEM; 471 + } 472 + tport->tp_port = port; 473 + tport->tp_tdev = usb_get_serial_data(port->serial); 474 + tport->tp_uart_mode = 0; /* default is RS232 */ 475 + 476 + usb_set_serial_port_data(port, tport); 477 + 478 + return 0; 479 + } 480 + 481 + static int ti_port_remove(struct usb_serial_port *port) 482 + { 483 + struct ti_port *tport; 484 + 485 + tport = usb_get_serial_port_data(port); 486 + kfifo_free(&tport->write_fifo); 487 + kfree(tport); 488 + 489 + return 0; 490 + } 431 491 432 492 static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) 433 493 {
-11
include/linux/usb.h
··· 1778 1778 extern void usb_register_notify(struct notifier_block *nb); 1779 1779 extern void usb_unregister_notify(struct notifier_block *nb); 1780 1780 1781 - #ifdef DEBUG 1782 - #define dbg(format, arg...) \ 1783 - printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg) 1784 - #else 1785 - #define dbg(format, arg...) \ 1786 - do { \ 1787 - if (0) \ 1788 - printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ 1789 - } while (0) 1790 - #endif 1791 - 1792 1781 /* debugfs stuff */ 1793 1782 extern struct dentry *usb_debug_root; 1794 1783
-10
include/linux/usb/Kbuild
··· 1 - header-y += audio.h 2 - header-y += cdc.h 3 - header-y += ch9.h 4 - header-y += ch11.h 5 - header-y += functionfs.h 6 - header-y += gadgetfs.h 7 - header-y += midi.h 8 - header-y += g_printer.h 9 - header-y += tmc.h 10 - header-y += video.h
+1 -523
include/linux/usb/audio.h
··· 17 17 * Types and defines in this file are either specific to version 1.0 of 18 18 * this standard or common for newer versions. 19 19 */ 20 - 21 20 #ifndef __LINUX_USB_AUDIO_H 22 21 #define __LINUX_USB_AUDIO_H 23 22 24 - #include <linux/types.h> 23 + #include <uapi/linux/usb/audio.h> 25 24 26 - /* bInterfaceProtocol values to denote the version of the standard used */ 27 - #define UAC_VERSION_1 0x00 28 - #define UAC_VERSION_2 0x20 29 - 30 - /* A.2 Audio Interface Subclass Codes */ 31 - #define USB_SUBCLASS_AUDIOCONTROL 0x01 32 - #define USB_SUBCLASS_AUDIOSTREAMING 0x02 33 - #define USB_SUBCLASS_MIDISTREAMING 0x03 34 - 35 - /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ 36 - #define UAC_HEADER 0x01 37 - #define UAC_INPUT_TERMINAL 0x02 38 - #define UAC_OUTPUT_TERMINAL 0x03 39 - #define UAC_MIXER_UNIT 0x04 40 - #define UAC_SELECTOR_UNIT 0x05 41 - #define UAC_FEATURE_UNIT 0x06 42 - #define UAC1_PROCESSING_UNIT 0x07 43 - #define UAC1_EXTENSION_UNIT 0x08 44 - 45 - /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ 46 - #define UAC_AS_GENERAL 0x01 47 - #define UAC_FORMAT_TYPE 0x02 48 - #define UAC_FORMAT_SPECIFIC 0x03 49 - 50 - /* A.7 Processing Unit Process Types */ 51 - #define UAC_PROCESS_UNDEFINED 0x00 52 - #define UAC_PROCESS_UP_DOWNMIX 0x01 53 - #define UAC_PROCESS_DOLBY_PROLOGIC 0x02 54 - #define UAC_PROCESS_STEREO_EXTENDER 0x03 55 - #define UAC_PROCESS_REVERB 0x04 56 - #define UAC_PROCESS_CHORUS 0x05 57 - #define UAC_PROCESS_DYN_RANGE_COMP 0x06 58 - 59 - /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ 60 - #define UAC_EP_GENERAL 0x01 61 - 62 - /* A.9 Audio Class-Specific Request Codes */ 63 - #define UAC_SET_ 0x00 64 - #define UAC_GET_ 0x80 65 - 66 - #define UAC__CUR 0x1 67 - #define UAC__MIN 0x2 68 - #define UAC__MAX 0x3 69 - #define UAC__RES 0x4 70 - #define UAC__MEM 0x5 71 - 72 - #define UAC_SET_CUR (UAC_SET_ | UAC__CUR) 73 - #define UAC_GET_CUR (UAC_GET_ | UAC__CUR) 74 - #define UAC_SET_MIN (UAC_SET_ | UAC__MIN) 75 - #define UAC_GET_MIN (UAC_GET_ | UAC__MIN) 76 - #define UAC_SET_MAX (UAC_SET_ | UAC__MAX) 77 - #define UAC_GET_MAX (UAC_GET_ | UAC__MAX) 78 - #define UAC_SET_RES (UAC_SET_ | UAC__RES) 79 - #define UAC_GET_RES (UAC_GET_ | UAC__RES) 80 - #define UAC_SET_MEM (UAC_SET_ | UAC__MEM) 81 - #define UAC_GET_MEM (UAC_GET_ | UAC__MEM) 82 - 83 - #define UAC_GET_STAT 0xff 84 - 85 - /* A.10 Control Selector Codes */ 86 - 87 - /* A.10.1 Terminal Control Selectors */ 88 - #define UAC_TERM_COPY_PROTECT 0x01 89 - 90 - /* A.10.2 Feature Unit Control Selectors */ 91 - #define UAC_FU_MUTE 0x01 92 - #define UAC_FU_VOLUME 0x02 93 - #define UAC_FU_BASS 0x03 94 - #define UAC_FU_MID 0x04 95 - #define UAC_FU_TREBLE 0x05 96 - #define UAC_FU_GRAPHIC_EQUALIZER 0x06 97 - #define UAC_FU_AUTOMATIC_GAIN 0x07 98 - #define UAC_FU_DELAY 0x08 99 - #define UAC_FU_BASS_BOOST 0x09 100 - #define UAC_FU_LOUDNESS 0x0a 101 - 102 - #define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1)) 103 - 104 - /* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */ 105 - #define UAC_UD_ENABLE 0x01 106 - #define UAC_UD_MODE_SELECT 0x02 107 - 108 - /* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */ 109 - #define UAC_DP_ENABLE 0x01 110 - #define UAC_DP_MODE_SELECT 0x02 111 - 112 - /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */ 113 - #define UAC_3D_ENABLE 0x01 114 - #define UAC_3D_SPACE 0x02 115 - 116 - /* A.10.3.4 Reverberation Processing Unit Control Selectors */ 117 - #define UAC_REVERB_ENABLE 0x01 118 - #define UAC_REVERB_LEVEL 0x02 119 - #define UAC_REVERB_TIME 0x03 120 - #define UAC_REVERB_FEEDBACK 0x04 121 - 122 - /* A.10.3.5 Chorus Processing Unit Control Selectors */ 123 - #define UAC_CHORUS_ENABLE 0x01 124 - #define UAC_CHORUS_LEVEL 0x02 125 - #define UAC_CHORUS_RATE 0x03 126 - #define UAC_CHORUS_DEPTH 0x04 127 - 128 - /* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */ 129 - #define UAC_DCR_ENABLE 0x01 130 - #define UAC_DCR_RATE 0x02 131 - #define UAC_DCR_MAXAMPL 0x03 132 - #define UAC_DCR_THRESHOLD 0x04 133 - #define UAC_DCR_ATTACK_TIME 0x05 134 - #define UAC_DCR_RELEASE_TIME 0x06 135 - 136 - /* A.10.4 Extension Unit Control Selectors */ 137 - #define UAC_XU_ENABLE 0x01 138 - 139 - /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ 140 - #define UAC_MS_HEADER 0x01 141 - #define UAC_MIDI_IN_JACK 0x02 142 - #define UAC_MIDI_OUT_JACK 0x03 143 - 144 - /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */ 145 - #define UAC_MS_GENERAL 0x01 146 - 147 - /* Terminals - 2.1 USB Terminal Types */ 148 - #define UAC_TERMINAL_UNDEFINED 0x100 149 - #define UAC_TERMINAL_STREAMING 0x101 150 - #define UAC_TERMINAL_VENDOR_SPEC 0x1FF 151 - 152 - /* Terminal Control Selectors */ 153 - /* 4.3.2 Class-Specific AC Interface Descriptor */ 154 - struct uac1_ac_header_descriptor { 155 - __u8 bLength; /* 8 + n */ 156 - __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 157 - __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ 158 - __le16 bcdADC; /* 0x0100 */ 159 - __le16 wTotalLength; /* includes Unit and Terminal desc. */ 160 - __u8 bInCollection; /* n */ 161 - __u8 baInterfaceNr[]; /* [n] */ 162 - } __attribute__ ((packed)); 163 - 164 - #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) 165 - 166 - /* As above, but more useful for defining your own descriptors: */ 167 - #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ 168 - struct uac1_ac_header_descriptor_##n { \ 169 - __u8 bLength; \ 170 - __u8 bDescriptorType; \ 171 - __u8 bDescriptorSubtype; \ 172 - __le16 bcdADC; \ 173 - __le16 wTotalLength; \ 174 - __u8 bInCollection; \ 175 - __u8 baInterfaceNr[n]; \ 176 - } __attribute__ ((packed)) 177 - 178 - /* 4.3.2.1 Input Terminal Descriptor */ 179 - struct uac_input_terminal_descriptor { 180 - __u8 bLength; /* in bytes: 12 */ 181 - __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 182 - __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */ 183 - __u8 bTerminalID; /* Constant uniquely terminal ID */ 184 - __le16 wTerminalType; /* USB Audio Terminal Types */ 185 - __u8 bAssocTerminal; /* ID of the Output Terminal associated */ 186 - __u8 bNrChannels; /* Number of logical output channels */ 187 - __le16 wChannelConfig; 188 - __u8 iChannelNames; 189 - __u8 iTerminal; 190 - } __attribute__ ((packed)); 191 - 192 - #define UAC_DT_INPUT_TERMINAL_SIZE 12 193 - 194 - /* Terminals - 2.2 Input Terminal Types */ 195 - #define UAC_INPUT_TERMINAL_UNDEFINED 0x200 196 - #define UAC_INPUT_TERMINAL_MICROPHONE 0x201 197 - #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202 198 - #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203 199 - #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204 200 - #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 201 - #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 202 - 203 - /* Terminals - control selectors */ 204 - 205 - #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01 206 - 207 - /* 4.3.2.2 Output Terminal Descriptor */ 208 - struct uac1_output_terminal_descriptor { 209 - __u8 bLength; /* in bytes: 9 */ 210 - __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 211 - __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ 212 - __u8 bTerminalID; /* Constant uniquely terminal ID */ 213 - __le16 wTerminalType; /* USB Audio Terminal Types */ 214 - __u8 bAssocTerminal; /* ID of the Input Terminal associated */ 215 - __u8 bSourceID; /* ID of the connected Unit or Terminal*/ 216 - __u8 iTerminal; 217 - } __attribute__ ((packed)); 218 - 219 - #define UAC_DT_OUTPUT_TERMINAL_SIZE 9 220 - 221 - /* Terminals - 2.3 Output Terminal Types */ 222 - #define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300 223 - #define UAC_OUTPUT_TERMINAL_SPEAKER 0x301 224 - #define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302 225 - #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303 226 - #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304 227 - #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305 228 - #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306 229 - #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307 230 - 231 - /* Set bControlSize = 2 as default setting */ 232 - #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) 233 - 234 - /* As above, but more useful for defining your own descriptors: */ 235 - #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ 236 - struct uac_feature_unit_descriptor_##ch { \ 237 - __u8 bLength; \ 238 - __u8 bDescriptorType; \ 239 - __u8 bDescriptorSubtype; \ 240 - __u8 bUnitID; \ 241 - __u8 bSourceID; \ 242 - __u8 bControlSize; \ 243 - __le16 bmaControls[ch + 1]; \ 244 - __u8 iFeature; \ 245 - } __attribute__ ((packed)) 246 - 247 - /* 4.3.2.3 Mixer Unit Descriptor */ 248 - struct uac_mixer_unit_descriptor { 249 - __u8 bLength; 250 - __u8 bDescriptorType; 251 - __u8 bDescriptorSubtype; 252 - __u8 bUnitID; 253 - __u8 bNrInPins; 254 - __u8 baSourceID[]; 255 - } __attribute__ ((packed)); 256 - 257 - static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc) 258 - { 259 - return desc->baSourceID[desc->bNrInPins]; 260 - } 261 - 262 - static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc, 263 - int protocol) 264 - { 265 - if (protocol == UAC_VERSION_1) 266 - return (desc->baSourceID[desc->bNrInPins + 2] << 8) | 267 - desc->baSourceID[desc->bNrInPins + 1]; 268 - else 269 - return (desc->baSourceID[desc->bNrInPins + 4] << 24) | 270 - (desc->baSourceID[desc->bNrInPins + 3] << 16) | 271 - (desc->baSourceID[desc->bNrInPins + 2] << 8) | 272 - (desc->baSourceID[desc->bNrInPins + 1]); 273 - } 274 - 275 - static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc, 276 - int protocol) 277 - { 278 - return (protocol == UAC_VERSION_1) ? 279 - desc->baSourceID[desc->bNrInPins + 3] : 280 - desc->baSourceID[desc->bNrInPins + 5]; 281 - } 282 - 283 - static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc, 284 - int protocol) 285 - { 286 - return (protocol == UAC_VERSION_1) ? 287 - &desc->baSourceID[desc->bNrInPins + 4] : 288 - &desc->baSourceID[desc->bNrInPins + 6]; 289 - } 290 - 291 - static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc) 292 - { 293 - __u8 *raw = (__u8 *) desc; 294 - return raw[desc->bLength - 1]; 295 - } 296 - 297 - /* 4.3.2.4 Selector Unit Descriptor */ 298 - struct uac_selector_unit_descriptor { 299 - __u8 bLength; 300 - __u8 bDescriptorType; 301 - __u8 bDescriptorSubtype; 302 - __u8 bUintID; 303 - __u8 bNrInPins; 304 - __u8 baSourceID[]; 305 - } __attribute__ ((packed)); 306 - 307 - static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc) 308 - { 309 - __u8 *raw = (__u8 *) desc; 310 - return raw[desc->bLength - 1]; 311 - } 312 - 313 - /* 4.3.2.5 Feature Unit Descriptor */ 314 - struct uac_feature_unit_descriptor { 315 - __u8 bLength; 316 - __u8 bDescriptorType; 317 - __u8 bDescriptorSubtype; 318 - __u8 bUnitID; 319 - __u8 bSourceID; 320 - __u8 bControlSize; 321 - __u8 bmaControls[0]; /* variable length */ 322 - } __attribute__((packed)); 323 - 324 - static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc) 325 - { 326 - __u8 *raw = (__u8 *) desc; 327 - return raw[desc->bLength - 1]; 328 - } 329 - 330 - /* 4.3.2.6 Processing Unit Descriptors */ 331 - struct uac_processing_unit_descriptor { 332 - __u8 bLength; 333 - __u8 bDescriptorType; 334 - __u8 bDescriptorSubtype; 335 - __u8 bUnitID; 336 - __u16 wProcessType; 337 - __u8 bNrInPins; 338 - __u8 baSourceID[]; 339 - } __attribute__ ((packed)); 340 - 341 - static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc) 342 - { 343 - return desc->baSourceID[desc->bNrInPins]; 344 - } 345 - 346 - static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc, 347 - int protocol) 348 - { 349 - if (protocol == UAC_VERSION_1) 350 - return (desc->baSourceID[desc->bNrInPins + 2] << 8) | 351 - desc->baSourceID[desc->bNrInPins + 1]; 352 - else 353 - return (desc->baSourceID[desc->bNrInPins + 4] << 24) | 354 - (desc->baSourceID[desc->bNrInPins + 3] << 16) | 355 - (desc->baSourceID[desc->bNrInPins + 2] << 8) | 356 - (desc->baSourceID[desc->bNrInPins + 1]); 357 - } 358 - 359 - static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc, 360 - int protocol) 361 - { 362 - return (protocol == UAC_VERSION_1) ? 363 - desc->baSourceID[desc->bNrInPins + 3] : 364 - desc->baSourceID[desc->bNrInPins + 5]; 365 - } 366 - 367 - static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc, 368 - int protocol) 369 - { 370 - return (protocol == UAC_VERSION_1) ? 371 - desc->baSourceID[desc->bNrInPins + 4] : 372 - desc->baSourceID[desc->bNrInPins + 6]; 373 - } 374 - 375 - static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc, 376 - int protocol) 377 - { 378 - return (protocol == UAC_VERSION_1) ? 379 - &desc->baSourceID[desc->bNrInPins + 5] : 380 - &desc->baSourceID[desc->bNrInPins + 7]; 381 - } 382 - 383 - static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc, 384 - int protocol) 385 - { 386 - __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); 387 - return desc->baSourceID[desc->bNrInPins + control_size]; 388 - } 389 - 390 - static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc, 391 - int protocol) 392 - { 393 - __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); 394 - return &desc->baSourceID[desc->bNrInPins + control_size + 1]; 395 - } 396 - 397 - /* 4.5.2 Class-Specific AS Interface Descriptor */ 398 - struct uac1_as_header_descriptor { 399 - __u8 bLength; /* in bytes: 7 */ 400 - __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 401 - __u8 bDescriptorSubtype; /* AS_GENERAL */ 402 - __u8 bTerminalLink; /* Terminal ID of connected Terminal */ 403 - __u8 bDelay; /* Delay introduced by the data path */ 404 - __le16 wFormatTag; /* The Audio Data Format */ 405 - } __attribute__ ((packed)); 406 - 407 - #define UAC_DT_AS_HEADER_SIZE 7 408 - 409 - /* Formats - A.1.1 Audio Data Format Type I Codes */ 410 - #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0 411 - #define UAC_FORMAT_TYPE_I_PCM 0x1 412 - #define UAC_FORMAT_TYPE_I_PCM8 0x2 413 - #define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3 414 - #define UAC_FORMAT_TYPE_I_ALAW 0x4 415 - #define UAC_FORMAT_TYPE_I_MULAW 0x5 416 - 417 - struct uac_format_type_i_continuous_descriptor { 418 - __u8 bLength; /* in bytes: 8 + (ns * 3) */ 419 - __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 420 - __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 421 - __u8 bFormatType; /* FORMAT_TYPE_1 */ 422 - __u8 bNrChannels; /* physical channels in the stream */ 423 - __u8 bSubframeSize; /* */ 424 - __u8 bBitResolution; 425 - __u8 bSamFreqType; 426 - __u8 tLowerSamFreq[3]; 427 - __u8 tUpperSamFreq[3]; 428 - } __attribute__ ((packed)); 429 - 430 - #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14 431 - 432 - struct uac_format_type_i_discrete_descriptor { 433 - __u8 bLength; /* in bytes: 8 + (ns * 3) */ 434 - __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 435 - __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 436 - __u8 bFormatType; /* FORMAT_TYPE_1 */ 437 - __u8 bNrChannels; /* physical channels in the stream */ 438 - __u8 bSubframeSize; /* */ 439 - __u8 bBitResolution; 440 - __u8 bSamFreqType; 441 - __u8 tSamFreq[][3]; 442 - } __attribute__ ((packed)); 443 - 444 - #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ 445 - struct uac_format_type_i_discrete_descriptor_##n { \ 446 - __u8 bLength; \ 447 - __u8 bDescriptorType; \ 448 - __u8 bDescriptorSubtype; \ 449 - __u8 bFormatType; \ 450 - __u8 bNrChannels; \ 451 - __u8 bSubframeSize; \ 452 - __u8 bBitResolution; \ 453 - __u8 bSamFreqType; \ 454 - __u8 tSamFreq[n][3]; \ 455 - } __attribute__ ((packed)) 456 - 457 - #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) 458 - 459 - struct uac_format_type_i_ext_descriptor { 460 - __u8 bLength; 461 - __u8 bDescriptorType; 462 - __u8 bDescriptorSubtype; 463 - __u8 bFormatType; 464 - __u8 bSubslotSize; 465 - __u8 bBitResolution; 466 - __u8 bHeaderLength; 467 - __u8 bControlSize; 468 - __u8 bSideBandProtocol; 469 - } __attribute__((packed)); 470 - 471 - /* Formats - Audio Data Format Type I Codes */ 472 - 473 - #define UAC_FORMAT_TYPE_II_MPEG 0x1001 474 - #define UAC_FORMAT_TYPE_II_AC3 0x1002 475 - 476 - struct uac_format_type_ii_discrete_descriptor { 477 - __u8 bLength; 478 - __u8 bDescriptorType; 479 - __u8 bDescriptorSubtype; 480 - __u8 bFormatType; 481 - __le16 wMaxBitRate; 482 - __le16 wSamplesPerFrame; 483 - __u8 bSamFreqType; 484 - __u8 tSamFreq[][3]; 485 - } __attribute__((packed)); 486 - 487 - struct uac_format_type_ii_ext_descriptor { 488 - __u8 bLength; 489 - __u8 bDescriptorType; 490 - __u8 bDescriptorSubtype; 491 - __u8 bFormatType; 492 - __u16 wMaxBitRate; 493 - __u16 wSamplesPerFrame; 494 - __u8 bHeaderLength; 495 - __u8 bSideBandProtocol; 496 - } __attribute__((packed)); 497 - 498 - /* type III */ 499 - #define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001 500 - #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002 501 - #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003 502 - #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004 503 - #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005 504 - #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006 505 - 506 - /* Formats - A.2 Format Type Codes */ 507 - #define UAC_FORMAT_TYPE_UNDEFINED 0x0 508 - #define UAC_FORMAT_TYPE_I 0x1 509 - #define UAC_FORMAT_TYPE_II 0x2 510 - #define UAC_FORMAT_TYPE_III 0x3 511 - #define UAC_EXT_FORMAT_TYPE_I 0x81 512 - #define UAC_EXT_FORMAT_TYPE_II 0x82 513 - #define UAC_EXT_FORMAT_TYPE_III 0x83 514 - 515 - struct uac_iso_endpoint_descriptor { 516 - __u8 bLength; /* in bytes: 7 */ 517 - __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ 518 - __u8 bDescriptorSubtype; /* EP_GENERAL */ 519 - __u8 bmAttributes; 520 - __u8 bLockDelayUnits; 521 - __le16 wLockDelay; 522 - } __attribute__((packed)); 523 - #define UAC_ISO_ENDPOINT_DESC_SIZE 7 524 - 525 - #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 526 - #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 527 - #define UAC_EP_CS_ATTR_FILL_MAX 0x80 528 - 529 - /* status word format (3.7.1.1) */ 530 - 531 - #define UAC1_STATUS_TYPE_ORIG_MASK 0x0f 532 - #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0 533 - #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1 534 - #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2 535 - 536 - #define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7) 537 - #define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6) 538 - 539 - struct uac1_status_word { 540 - __u8 bStatusType; 541 - __u8 bOriginator; 542 - } __attribute__((packed)); 543 - 544 - #ifdef __KERNEL__ 545 25 546 26 struct usb_audio_control { 547 27 struct list_head list; ··· 40 560 u8 type; 41 561 struct usb_descriptor_header *desc; 42 562 }; 43 - 44 - #endif /* __KERNEL__ */ 45 563 46 564 #endif /* __LINUX_USB_AUDIO_H */
include/linux/usb/cdc.h include/uapi/linux/usb/cdc.h
include/linux/usb/ch11.h include/uapi/linux/usb/ch11.h
+1 -959
include/linux/usb/ch9.h
··· 29 29 * someone that the two other points are non-issues for that 30 30 * particular descriptor type. 31 31 */ 32 - 33 32 #ifndef __LINUX_USB_CH9_H 34 33 #define __LINUX_USB_CH9_H 35 34 36 - #include <linux/types.h> /* __u8 etc */ 37 - #include <asm/byteorder.h> /* le16_to_cpu */ 35 + #include <uapi/linux/usb/ch9.h> 38 36 39 - /*-------------------------------------------------------------------------*/ 40 - 41 - /* CONTROL REQUEST SUPPORT */ 42 - 43 - /* 44 - * USB directions 45 - * 46 - * This bit flag is used in endpoint descriptors' bEndpointAddress field. 47 - * It's also one of three fields in control requests bRequestType. 48 - */ 49 - #define USB_DIR_OUT 0 /* to device */ 50 - #define USB_DIR_IN 0x80 /* to host */ 51 - 52 - /* 53 - * USB types, the second of three bRequestType fields 54 - */ 55 - #define USB_TYPE_MASK (0x03 << 5) 56 - #define USB_TYPE_STANDARD (0x00 << 5) 57 - #define USB_TYPE_CLASS (0x01 << 5) 58 - #define USB_TYPE_VENDOR (0x02 << 5) 59 - #define USB_TYPE_RESERVED (0x03 << 5) 60 - 61 - /* 62 - * USB recipients, the third of three bRequestType fields 63 - */ 64 - #define USB_RECIP_MASK 0x1f 65 - #define USB_RECIP_DEVICE 0x00 66 - #define USB_RECIP_INTERFACE 0x01 67 - #define USB_RECIP_ENDPOINT 0x02 68 - #define USB_RECIP_OTHER 0x03 69 - /* From Wireless USB 1.0 */ 70 - #define USB_RECIP_PORT 0x04 71 - #define USB_RECIP_RPIPE 0x05 72 - 73 - /* 74 - * Standard requests, for the bRequest field of a SETUP packet. 75 - * 76 - * These are qualified by the bRequestType field, so that for example 77 - * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved 78 - * by a GET_STATUS request. 79 - */ 80 - #define USB_REQ_GET_STATUS 0x00 81 - #define USB_REQ_CLEAR_FEATURE 0x01 82 - #define USB_REQ_SET_FEATURE 0x03 83 - #define USB_REQ_SET_ADDRESS 0x05 84 - #define USB_REQ_GET_DESCRIPTOR 0x06 85 - #define USB_REQ_SET_DESCRIPTOR 0x07 86 - #define USB_REQ_GET_CONFIGURATION 0x08 87 - #define USB_REQ_SET_CONFIGURATION 0x09 88 - #define USB_REQ_GET_INTERFACE 0x0A 89 - #define USB_REQ_SET_INTERFACE 0x0B 90 - #define USB_REQ_SYNCH_FRAME 0x0C 91 - #define USB_REQ_SET_SEL 0x30 92 - #define USB_REQ_SET_ISOCH_DELAY 0x31 93 - 94 - #define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */ 95 - #define USB_REQ_GET_ENCRYPTION 0x0E 96 - #define USB_REQ_RPIPE_ABORT 0x0E 97 - #define USB_REQ_SET_HANDSHAKE 0x0F 98 - #define USB_REQ_RPIPE_RESET 0x0F 99 - #define USB_REQ_GET_HANDSHAKE 0x10 100 - #define USB_REQ_SET_CONNECTION 0x11 101 - #define USB_REQ_SET_SECURITY_DATA 0x12 102 - #define USB_REQ_GET_SECURITY_DATA 0x13 103 - #define USB_REQ_SET_WUSB_DATA 0x14 104 - #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 105 - #define USB_REQ_LOOPBACK_DATA_READ 0x16 106 - #define USB_REQ_SET_INTERFACE_DS 0x17 107 - 108 - /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, 109 - * used by hubs to put ports into a new L1 suspend state, except that it 110 - * forgot to define its number ... 111 - */ 112 - 113 - /* 114 - * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and 115 - * are read as a bit array returned by USB_REQ_GET_STATUS. (So there 116 - * are at most sixteen features of each type.) Hubs may also support a 117 - * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. 118 - */ 119 - #define USB_DEVICE_SELF_POWERED 0 /* (read only) */ 120 - #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ 121 - #define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */ 122 - #define USB_DEVICE_BATTERY 2 /* (wireless) */ 123 - #define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */ 124 - #define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/ 125 - #define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */ 126 - #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ 127 - #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ 128 - 129 - /* 130 - * Test Mode Selectors 131 - * See USB 2.0 spec Table 9-7 132 - */ 133 - #define TEST_J 1 134 - #define TEST_K 2 135 - #define TEST_SE0_NAK 3 136 - #define TEST_PACKET 4 137 - #define TEST_FORCE_EN 5 138 - 139 - /* 140 - * New Feature Selectors as added by USB 3.0 141 - * See USB 3.0 spec Table 9-6 142 - */ 143 - #define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ 144 - #define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */ 145 - #define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */ 146 - #define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */ 147 - 148 - #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 149 - /* 150 - * Suspend Options, Table 9-7 USB 3.0 spec 151 - */ 152 - #define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0)) 153 - #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1)) 154 - 155 - #define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ 156 - 157 - /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */ 158 - #define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */ 159 - #define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ 160 - #define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ 161 - 162 - /** 163 - * struct usb_ctrlrequest - SETUP data for a USB device control request 164 - * @bRequestType: matches the USB bmRequestType field 165 - * @bRequest: matches the USB bRequest field 166 - * @wValue: matches the USB wValue field (le16 byte order) 167 - * @wIndex: matches the USB wIndex field (le16 byte order) 168 - * @wLength: matches the USB wLength field (le16 byte order) 169 - * 170 - * This structure is used to send control requests to a USB device. It matches 171 - * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the 172 - * USB spec for a fuller description of the different fields, and what they are 173 - * used for. 174 - * 175 - * Note that the driver for any interface can issue control requests. 176 - * For most devices, interfaces don't coordinate with each other, so 177 - * such requests may be made at any time. 178 - */ 179 - struct usb_ctrlrequest { 180 - __u8 bRequestType; 181 - __u8 bRequest; 182 - __le16 wValue; 183 - __le16 wIndex; 184 - __le16 wLength; 185 - } __attribute__ ((packed)); 186 - 187 - /*-------------------------------------------------------------------------*/ 188 - 189 - /* 190 - * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or 191 - * (rarely) accepted by SET_DESCRIPTOR. 192 - * 193 - * Note that all multi-byte values here are encoded in little endian 194 - * byte order "on the wire". Within the kernel and when exposed 195 - * through the Linux-USB APIs, they are not converted to cpu byte 196 - * order; it is the responsibility of the client code to do this. 197 - * The single exception is when device and configuration descriptors (but 198 - * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD); 199 - * in this case the fields are converted to host endianness by the kernel. 200 - */ 201 - 202 - /* 203 - * Descriptor types ... USB 2.0 spec table 9.5 204 - */ 205 - #define USB_DT_DEVICE 0x01 206 - #define USB_DT_CONFIG 0x02 207 - #define USB_DT_STRING 0x03 208 - #define USB_DT_INTERFACE 0x04 209 - #define USB_DT_ENDPOINT 0x05 210 - #define USB_DT_DEVICE_QUALIFIER 0x06 211 - #define USB_DT_OTHER_SPEED_CONFIG 0x07 212 - #define USB_DT_INTERFACE_POWER 0x08 213 - /* these are from a minor usb 2.0 revision (ECN) */ 214 - #define USB_DT_OTG 0x09 215 - #define USB_DT_DEBUG 0x0a 216 - #define USB_DT_INTERFACE_ASSOCIATION 0x0b 217 - /* these are from the Wireless USB spec */ 218 - #define USB_DT_SECURITY 0x0c 219 - #define USB_DT_KEY 0x0d 220 - #define USB_DT_ENCRYPTION_TYPE 0x0e 221 - #define USB_DT_BOS 0x0f 222 - #define USB_DT_DEVICE_CAPABILITY 0x10 223 - #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 224 - #define USB_DT_WIRE_ADAPTER 0x21 225 - #define USB_DT_RPIPE 0x22 226 - #define USB_DT_CS_RADIO_CONTROL 0x23 227 - /* From the T10 UAS specification */ 228 - #define USB_DT_PIPE_USAGE 0x24 229 - /* From the USB 3.0 spec */ 230 - #define USB_DT_SS_ENDPOINT_COMP 0x30 231 - 232 - /* Conventional codes for class-specific descriptors. The convention is 233 - * defined in the USB "Common Class" Spec (3.11). Individual class specs 234 - * are authoritative for their usage, not the "common class" writeup. 235 - */ 236 - #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) 237 - #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) 238 - #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) 239 - #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) 240 - #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) 241 - 242 - /* All standard descriptors have these 2 fields at the beginning */ 243 - struct usb_descriptor_header { 244 - __u8 bLength; 245 - __u8 bDescriptorType; 246 - } __attribute__ ((packed)); 247 - 248 - 249 - /*-------------------------------------------------------------------------*/ 250 - 251 - /* USB_DT_DEVICE: Device descriptor */ 252 - struct usb_device_descriptor { 253 - __u8 bLength; 254 - __u8 bDescriptorType; 255 - 256 - __le16 bcdUSB; 257 - __u8 bDeviceClass; 258 - __u8 bDeviceSubClass; 259 - __u8 bDeviceProtocol; 260 - __u8 bMaxPacketSize0; 261 - __le16 idVendor; 262 - __le16 idProduct; 263 - __le16 bcdDevice; 264 - __u8 iManufacturer; 265 - __u8 iProduct; 266 - __u8 iSerialNumber; 267 - __u8 bNumConfigurations; 268 - } __attribute__ ((packed)); 269 - 270 - #define USB_DT_DEVICE_SIZE 18 271 - 272 - 273 - /* 274 - * Device and/or Interface Class codes 275 - * as found in bDeviceClass or bInterfaceClass 276 - * and defined by www.usb.org documents 277 - */ 278 - #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ 279 - #define USB_CLASS_AUDIO 1 280 - #define USB_CLASS_COMM 2 281 - #define USB_CLASS_HID 3 282 - #define USB_CLASS_PHYSICAL 5 283 - #define USB_CLASS_STILL_IMAGE 6 284 - #define USB_CLASS_PRINTER 7 285 - #define USB_CLASS_MASS_STORAGE 8 286 - #define USB_CLASS_HUB 9 287 - #define USB_CLASS_CDC_DATA 0x0a 288 - #define USB_CLASS_CSCID 0x0b /* chip+ smart card */ 289 - #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ 290 - #define USB_CLASS_VIDEO 0x0e 291 - #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 292 - #define USB_CLASS_MISC 0xef 293 - #define USB_CLASS_APP_SPEC 0xfe 294 - #define USB_CLASS_VENDOR_SPEC 0xff 295 - 296 - #define USB_SUBCLASS_VENDOR_SPEC 0xff 297 - 298 - /*-------------------------------------------------------------------------*/ 299 - 300 - /* USB_DT_CONFIG: Configuration descriptor information. 301 - * 302 - * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the 303 - * descriptor type is different. Highspeed-capable devices can look 304 - * different depending on what speed they're currently running. Only 305 - * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG 306 - * descriptors. 307 - */ 308 - struct usb_config_descriptor { 309 - __u8 bLength; 310 - __u8 bDescriptorType; 311 - 312 - __le16 wTotalLength; 313 - __u8 bNumInterfaces; 314 - __u8 bConfigurationValue; 315 - __u8 iConfiguration; 316 - __u8 bmAttributes; 317 - __u8 bMaxPower; 318 - } __attribute__ ((packed)); 319 - 320 - #define USB_DT_CONFIG_SIZE 9 321 - 322 - /* from config descriptor bmAttributes */ 323 - #define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ 324 - #define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ 325 - #define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ 326 - #define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ 327 - 328 - /*-------------------------------------------------------------------------*/ 329 - 330 - /* USB_DT_STRING: String descriptor */ 331 - struct usb_string_descriptor { 332 - __u8 bLength; 333 - __u8 bDescriptorType; 334 - 335 - __le16 wData[1]; /* UTF-16LE encoded */ 336 - } __attribute__ ((packed)); 337 - 338 - /* note that "string" zero is special, it holds language codes that 339 - * the device supports, not Unicode characters. 340 - */ 341 - 342 - /*-------------------------------------------------------------------------*/ 343 - 344 - /* USB_DT_INTERFACE: Interface descriptor */ 345 - struct usb_interface_descriptor { 346 - __u8 bLength; 347 - __u8 bDescriptorType; 348 - 349 - __u8 bInterfaceNumber; 350 - __u8 bAlternateSetting; 351 - __u8 bNumEndpoints; 352 - __u8 bInterfaceClass; 353 - __u8 bInterfaceSubClass; 354 - __u8 bInterfaceProtocol; 355 - __u8 iInterface; 356 - } __attribute__ ((packed)); 357 - 358 - #define USB_DT_INTERFACE_SIZE 9 359 - 360 - /*-------------------------------------------------------------------------*/ 361 - 362 - /* USB_DT_ENDPOINT: Endpoint descriptor */ 363 - struct usb_endpoint_descriptor { 364 - __u8 bLength; 365 - __u8 bDescriptorType; 366 - 367 - __u8 bEndpointAddress; 368 - __u8 bmAttributes; 369 - __le16 wMaxPacketSize; 370 - __u8 bInterval; 371 - 372 - /* NOTE: these two are _only_ in audio endpoints. */ 373 - /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ 374 - __u8 bRefresh; 375 - __u8 bSynchAddress; 376 - } __attribute__ ((packed)); 377 - 378 - #define USB_DT_ENDPOINT_SIZE 7 379 - #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ 380 - 381 - 382 - /* 383 - * Endpoints 384 - */ 385 - #define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ 386 - #define USB_ENDPOINT_DIR_MASK 0x80 387 - 388 - #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ 389 - #define USB_ENDPOINT_XFER_CONTROL 0 390 - #define USB_ENDPOINT_XFER_ISOC 1 391 - #define USB_ENDPOINT_XFER_BULK 2 392 - #define USB_ENDPOINT_XFER_INT 3 393 - #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 394 - 395 - /* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */ 396 - #define USB_ENDPOINT_INTRTYPE 0x30 397 - #define USB_ENDPOINT_INTR_PERIODIC (0 << 4) 398 - #define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4) 399 - 400 - #define USB_ENDPOINT_SYNCTYPE 0x0c 401 - #define USB_ENDPOINT_SYNC_NONE (0 << 2) 402 - #define USB_ENDPOINT_SYNC_ASYNC (1 << 2) 403 - #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) 404 - #define USB_ENDPOINT_SYNC_SYNC (3 << 2) 405 - 406 - #define USB_ENDPOINT_USAGE_MASK 0x30 407 - #define USB_ENDPOINT_USAGE_DATA 0x00 408 - #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 409 - #define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */ 410 - 411 - /*-------------------------------------------------------------------------*/ 412 - 413 - /** 414 - * usb_endpoint_num - get the endpoint's number 415 - * @epd: endpoint to be checked 416 - * 417 - * Returns @epd's number: 0 to 15. 418 - */ 419 - static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) 420 - { 421 - return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 422 - } 423 - 424 - /** 425 - * usb_endpoint_type - get the endpoint's transfer type 426 - * @epd: endpoint to be checked 427 - * 428 - * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according 429 - * to @epd's transfer type. 430 - */ 431 - static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) 432 - { 433 - return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 434 - } 435 - 436 - /** 437 - * usb_endpoint_dir_in - check if the endpoint has IN direction 438 - * @epd: endpoint to be checked 439 - * 440 - * Returns true if the endpoint is of type IN, otherwise it returns false. 441 - */ 442 - static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) 443 - { 444 - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); 445 - } 446 - 447 - /** 448 - * usb_endpoint_dir_out - check if the endpoint has OUT direction 449 - * @epd: endpoint to be checked 450 - * 451 - * Returns true if the endpoint is of type OUT, otherwise it returns false. 452 - */ 453 - static inline int usb_endpoint_dir_out( 454 - const struct usb_endpoint_descriptor *epd) 455 - { 456 - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); 457 - } 458 - 459 - /** 460 - * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type 461 - * @epd: endpoint to be checked 462 - * 463 - * Returns true if the endpoint is of type bulk, otherwise it returns false. 464 - */ 465 - static inline int usb_endpoint_xfer_bulk( 466 - const struct usb_endpoint_descriptor *epd) 467 - { 468 - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 469 - USB_ENDPOINT_XFER_BULK); 470 - } 471 - 472 - /** 473 - * usb_endpoint_xfer_control - check if the endpoint has control transfer type 474 - * @epd: endpoint to be checked 475 - * 476 - * Returns true if the endpoint is of type control, otherwise it returns false. 477 - */ 478 - static inline int usb_endpoint_xfer_control( 479 - const struct usb_endpoint_descriptor *epd) 480 - { 481 - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 482 - USB_ENDPOINT_XFER_CONTROL); 483 - } 484 - 485 - /** 486 - * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type 487 - * @epd: endpoint to be checked 488 - * 489 - * Returns true if the endpoint is of type interrupt, otherwise it returns 490 - * false. 491 - */ 492 - static inline int usb_endpoint_xfer_int( 493 - const struct usb_endpoint_descriptor *epd) 494 - { 495 - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 496 - USB_ENDPOINT_XFER_INT); 497 - } 498 - 499 - /** 500 - * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type 501 - * @epd: endpoint to be checked 502 - * 503 - * Returns true if the endpoint is of type isochronous, otherwise it returns 504 - * false. 505 - */ 506 - static inline int usb_endpoint_xfer_isoc( 507 - const struct usb_endpoint_descriptor *epd) 508 - { 509 - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 510 - USB_ENDPOINT_XFER_ISOC); 511 - } 512 - 513 - /** 514 - * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN 515 - * @epd: endpoint to be checked 516 - * 517 - * Returns true if the endpoint has bulk transfer type and IN direction, 518 - * otherwise it returns false. 519 - */ 520 - static inline int usb_endpoint_is_bulk_in( 521 - const struct usb_endpoint_descriptor *epd) 522 - { 523 - return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); 524 - } 525 - 526 - /** 527 - * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT 528 - * @epd: endpoint to be checked 529 - * 530 - * Returns true if the endpoint has bulk transfer type and OUT direction, 531 - * otherwise it returns false. 532 - */ 533 - static inline int usb_endpoint_is_bulk_out( 534 - const struct usb_endpoint_descriptor *epd) 535 - { 536 - return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); 537 - } 538 - 539 - /** 540 - * usb_endpoint_is_int_in - check if the endpoint is interrupt IN 541 - * @epd: endpoint to be checked 542 - * 543 - * Returns true if the endpoint has interrupt transfer type and IN direction, 544 - * otherwise it returns false. 545 - */ 546 - static inline int usb_endpoint_is_int_in( 547 - const struct usb_endpoint_descriptor *epd) 548 - { 549 - return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); 550 - } 551 - 552 - /** 553 - * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT 554 - * @epd: endpoint to be checked 555 - * 556 - * Returns true if the endpoint has interrupt transfer type and OUT direction, 557 - * otherwise it returns false. 558 - */ 559 - static inline int usb_endpoint_is_int_out( 560 - const struct usb_endpoint_descriptor *epd) 561 - { 562 - return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd); 563 - } 564 - 565 - /** 566 - * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN 567 - * @epd: endpoint to be checked 568 - * 569 - * Returns true if the endpoint has isochronous transfer type and IN direction, 570 - * otherwise it returns false. 571 - */ 572 - static inline int usb_endpoint_is_isoc_in( 573 - const struct usb_endpoint_descriptor *epd) 574 - { 575 - return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd); 576 - } 577 - 578 - /** 579 - * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT 580 - * @epd: endpoint to be checked 581 - * 582 - * Returns true if the endpoint has isochronous transfer type and OUT direction, 583 - * otherwise it returns false. 584 - */ 585 - static inline int usb_endpoint_is_isoc_out( 586 - const struct usb_endpoint_descriptor *epd) 587 - { 588 - return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd); 589 - } 590 - 591 - /** 592 - * usb_endpoint_maxp - get endpoint's max packet size 593 - * @epd: endpoint to be checked 594 - * 595 - * Returns @epd's max packet 596 - */ 597 - static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd) 598 - { 599 - return __le16_to_cpu(epd->wMaxPacketSize); 600 - } 601 - 602 - static inline int usb_endpoint_interrupt_type( 603 - const struct usb_endpoint_descriptor *epd) 604 - { 605 - return epd->bmAttributes & USB_ENDPOINT_INTRTYPE; 606 - } 607 - 608 - /*-------------------------------------------------------------------------*/ 609 - 610 - /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */ 611 - struct usb_ss_ep_comp_descriptor { 612 - __u8 bLength; 613 - __u8 bDescriptorType; 614 - 615 - __u8 bMaxBurst; 616 - __u8 bmAttributes; 617 - __le16 wBytesPerInterval; 618 - } __attribute__ ((packed)); 619 - 620 - #define USB_DT_SS_EP_COMP_SIZE 6 621 - 622 - /* Bits 4:0 of bmAttributes if this is a bulk endpoint */ 623 - static inline int 624 - usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp) 625 - { 626 - int max_streams; 627 - 628 - if (!comp) 629 - return 0; 630 - 631 - max_streams = comp->bmAttributes & 0x1f; 632 - 633 - if (!max_streams) 634 - return 0; 635 - 636 - max_streams = 1 << max_streams; 637 - 638 - return max_streams; 639 - } 640 - 641 - /* Bits 1:0 of bmAttributes if this is an isoc endpoint */ 642 - #define USB_SS_MULT(p) (1 + ((p) & 0x3)) 643 - 644 - /*-------------------------------------------------------------------------*/ 645 - 646 - /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ 647 - struct usb_qualifier_descriptor { 648 - __u8 bLength; 649 - __u8 bDescriptorType; 650 - 651 - __le16 bcdUSB; 652 - __u8 bDeviceClass; 653 - __u8 bDeviceSubClass; 654 - __u8 bDeviceProtocol; 655 - __u8 bMaxPacketSize0; 656 - __u8 bNumConfigurations; 657 - __u8 bRESERVED; 658 - } __attribute__ ((packed)); 659 - 660 - 661 - /*-------------------------------------------------------------------------*/ 662 - 663 - /* USB_DT_OTG (from OTG 1.0a supplement) */ 664 - struct usb_otg_descriptor { 665 - __u8 bLength; 666 - __u8 bDescriptorType; 667 - 668 - __u8 bmAttributes; /* support for HNP, SRP, etc */ 669 - } __attribute__ ((packed)); 670 - 671 - /* from usb_otg_descriptor.bmAttributes */ 672 - #define USB_OTG_SRP (1 << 0) 673 - #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ 674 - 675 - /*-------------------------------------------------------------------------*/ 676 - 677 - /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ 678 - struct usb_debug_descriptor { 679 - __u8 bLength; 680 - __u8 bDescriptorType; 681 - 682 - /* bulk endpoints with 8 byte maxpacket */ 683 - __u8 bDebugInEndpoint; 684 - __u8 bDebugOutEndpoint; 685 - } __attribute__((packed)); 686 - 687 - /*-------------------------------------------------------------------------*/ 688 - 689 - /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ 690 - struct usb_interface_assoc_descriptor { 691 - __u8 bLength; 692 - __u8 bDescriptorType; 693 - 694 - __u8 bFirstInterface; 695 - __u8 bInterfaceCount; 696 - __u8 bFunctionClass; 697 - __u8 bFunctionSubClass; 698 - __u8 bFunctionProtocol; 699 - __u8 iFunction; 700 - } __attribute__ ((packed)); 701 - 702 - 703 - /*-------------------------------------------------------------------------*/ 704 - 705 - /* USB_DT_SECURITY: group of wireless security descriptors, including 706 - * encryption types available for setting up a CC/association. 707 - */ 708 - struct usb_security_descriptor { 709 - __u8 bLength; 710 - __u8 bDescriptorType; 711 - 712 - __le16 wTotalLength; 713 - __u8 bNumEncryptionTypes; 714 - } __attribute__((packed)); 715 - 716 - /*-------------------------------------------------------------------------*/ 717 - 718 - /* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys 719 - * may be retrieved. 720 - */ 721 - struct usb_key_descriptor { 722 - __u8 bLength; 723 - __u8 bDescriptorType; 724 - 725 - __u8 tTKID[3]; 726 - __u8 bReserved; 727 - __u8 bKeyData[0]; 728 - } __attribute__((packed)); 729 - 730 - /*-------------------------------------------------------------------------*/ 731 - 732 - /* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */ 733 - struct usb_encryption_descriptor { 734 - __u8 bLength; 735 - __u8 bDescriptorType; 736 - 737 - __u8 bEncryptionType; 738 - #define USB_ENC_TYPE_UNSECURE 0 739 - #define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */ 740 - #define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */ 741 - #define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ 742 - __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ 743 - __u8 bAuthKeyIndex; 744 - } __attribute__((packed)); 745 - 746 - 747 - /*-------------------------------------------------------------------------*/ 748 - 749 - /* USB_DT_BOS: group of device-level capabilities */ 750 - struct usb_bos_descriptor { 751 - __u8 bLength; 752 - __u8 bDescriptorType; 753 - 754 - __le16 wTotalLength; 755 - __u8 bNumDeviceCaps; 756 - } __attribute__((packed)); 757 - 758 - #define USB_DT_BOS_SIZE 5 759 - /*-------------------------------------------------------------------------*/ 760 - 761 - /* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ 762 - struct usb_dev_cap_header { 763 - __u8 bLength; 764 - __u8 bDescriptorType; 765 - __u8 bDevCapabilityType; 766 - } __attribute__((packed)); 767 - 768 - #define USB_CAP_TYPE_WIRELESS_USB 1 769 - 770 - struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ 771 - __u8 bLength; 772 - __u8 bDescriptorType; 773 - __u8 bDevCapabilityType; 774 - 775 - __u8 bmAttributes; 776 - #define USB_WIRELESS_P2P_DRD (1 << 1) 777 - #define USB_WIRELESS_BEACON_MASK (3 << 2) 778 - #define USB_WIRELESS_BEACON_SELF (1 << 2) 779 - #define USB_WIRELESS_BEACON_DIRECTED (2 << 2) 780 - #define USB_WIRELESS_BEACON_NONE (3 << 2) 781 - __le16 wPHYRates; /* bit rates, Mbps */ 782 - #define USB_WIRELESS_PHY_53 (1 << 0) /* always set */ 783 - #define USB_WIRELESS_PHY_80 (1 << 1) 784 - #define USB_WIRELESS_PHY_107 (1 << 2) /* always set */ 785 - #define USB_WIRELESS_PHY_160 (1 << 3) 786 - #define USB_WIRELESS_PHY_200 (1 << 4) /* always set */ 787 - #define USB_WIRELESS_PHY_320 (1 << 5) 788 - #define USB_WIRELESS_PHY_400 (1 << 6) 789 - #define USB_WIRELESS_PHY_480 (1 << 7) 790 - __u8 bmTFITXPowerInfo; /* TFI power levels */ 791 - __u8 bmFFITXPowerInfo; /* FFI power levels */ 792 - __le16 bmBandGroup; 793 - __u8 bReserved; 794 - } __attribute__((packed)); 795 - 796 - /* USB 2.0 Extension descriptor */ 797 - #define USB_CAP_TYPE_EXT 2 798 - 799 - struct usb_ext_cap_descriptor { /* Link Power Management */ 800 - __u8 bLength; 801 - __u8 bDescriptorType; 802 - __u8 bDevCapabilityType; 803 - __le32 bmAttributes; 804 - #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ 805 - #define USB_BESL_SUPPORT (1 << 2) /* supports BESL */ 806 - #define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/ 807 - #define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */ 808 - #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) 809 - #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) 810 - } __attribute__((packed)); 811 - 812 - #define USB_DT_USB_EXT_CAP_SIZE 7 813 - 814 - /* 815 - * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB 816 - * specific device level capabilities 817 - */ 818 - #define USB_SS_CAP_TYPE 3 819 - struct usb_ss_cap_descriptor { /* Link Power Management */ 820 - __u8 bLength; 821 - __u8 bDescriptorType; 822 - __u8 bDevCapabilityType; 823 - __u8 bmAttributes; 824 - #define USB_LTM_SUPPORT (1 << 1) /* supports LTM */ 825 - __le16 wSpeedSupported; 826 - #define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */ 827 - #define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */ 828 - #define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */ 829 - #define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */ 830 - __u8 bFunctionalitySupport; 831 - __u8 bU1devExitLat; 832 - __le16 bU2DevExitLat; 833 - } __attribute__((packed)); 834 - 835 - #define USB_DT_USB_SS_CAP_SIZE 10 836 - 837 - /* 838 - * Container ID Capability descriptor: Defines the instance unique ID used to 839 - * identify the instance across all operating modes 840 - */ 841 - #define CONTAINER_ID_TYPE 4 842 - struct usb_ss_container_id_descriptor { 843 - __u8 bLength; 844 - __u8 bDescriptorType; 845 - __u8 bDevCapabilityType; 846 - __u8 bReserved; 847 - __u8 ContainerID[16]; /* 128-bit number */ 848 - } __attribute__((packed)); 849 - 850 - #define USB_DT_USB_SS_CONTN_ID_SIZE 20 851 - /*-------------------------------------------------------------------------*/ 852 - 853 - /* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with 854 - * each endpoint descriptor for a wireless device 855 - */ 856 - struct usb_wireless_ep_comp_descriptor { 857 - __u8 bLength; 858 - __u8 bDescriptorType; 859 - 860 - __u8 bMaxBurst; 861 - __u8 bMaxSequence; 862 - __le16 wMaxStreamDelay; 863 - __le16 wOverTheAirPacketSize; 864 - __u8 bOverTheAirInterval; 865 - __u8 bmCompAttributes; 866 - #define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */ 867 - #define USB_ENDPOINT_SWITCH_NO 0 868 - #define USB_ENDPOINT_SWITCH_SWITCH 1 869 - #define USB_ENDPOINT_SWITCH_SCALE 2 870 - } __attribute__((packed)); 871 - 872 - /*-------------------------------------------------------------------------*/ 873 - 874 - /* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless 875 - * host and a device for connection set up, mutual authentication, and 876 - * exchanging short lived session keys. The handshake depends on a CC. 877 - */ 878 - struct usb_handshake { 879 - __u8 bMessageNumber; 880 - __u8 bStatus; 881 - __u8 tTKID[3]; 882 - __u8 bReserved; 883 - __u8 CDID[16]; 884 - __u8 nonce[16]; 885 - __u8 MIC[8]; 886 - } __attribute__((packed)); 887 - 888 - /*-------------------------------------------------------------------------*/ 889 - 890 - /* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC). 891 - * A CC may also be set up using non-wireless secure channels (including 892 - * wired USB!), and some devices may support CCs with multiple hosts. 893 - */ 894 - struct usb_connection_context { 895 - __u8 CHID[16]; /* persistent host id */ 896 - __u8 CDID[16]; /* device id (unique w/in host context) */ 897 - __u8 CK[16]; /* connection key */ 898 - } __attribute__((packed)); 899 - 900 - /*-------------------------------------------------------------------------*/ 901 - 902 - /* USB 2.0 defines three speeds, here's how Linux identifies them */ 903 - 904 - enum usb_device_speed { 905 - USB_SPEED_UNKNOWN = 0, /* enumerating */ 906 - USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ 907 - USB_SPEED_HIGH, /* usb 2.0 */ 908 - USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ 909 - USB_SPEED_SUPER, /* usb 3.0 */ 910 - }; 911 - 912 - #ifdef __KERNEL__ 913 37 914 38 /** 915 39 * usb_speed_string() - Returns human readable-name of the speed. ··· 42 918 * USB_SPEED_UNKNOWN will be returned. 43 919 */ 44 920 extern const char *usb_speed_string(enum usb_device_speed speed); 45 - 46 - #endif 47 - 48 - enum usb_device_state { 49 - /* NOTATTACHED isn't in the USB spec, and this state acts 50 - * the same as ATTACHED ... but it's clearer this way. 51 - */ 52 - USB_STATE_NOTATTACHED = 0, 53 - 54 - /* chapter 9 and authentication (wireless) device states */ 55 - USB_STATE_ATTACHED, 56 - USB_STATE_POWERED, /* wired */ 57 - USB_STATE_RECONNECTING, /* auth */ 58 - USB_STATE_UNAUTHENTICATED, /* auth */ 59 - USB_STATE_DEFAULT, /* limited function */ 60 - USB_STATE_ADDRESS, 61 - USB_STATE_CONFIGURED, /* most functions */ 62 - 63 - USB_STATE_SUSPENDED 64 - 65 - /* NOTE: there are actually four different SUSPENDED 66 - * states, returning to POWERED, DEFAULT, ADDRESS, or 67 - * CONFIGURED respectively when SOF tokens flow again. 68 - * At this level there's no difference between L1 and L2 69 - * suspend states. (L2 being original USB 1.1 suspend.) 70 - */ 71 - }; 72 - 73 - enum usb3_link_state { 74 - USB3_LPM_U0 = 0, 75 - USB3_LPM_U1, 76 - USB3_LPM_U2, 77 - USB3_LPM_U3 78 - }; 79 - 80 - /* 81 - * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1. 82 - * 0xff means the parent hub will accept transitions to U1, but will not 83 - * initiate a transition. 84 - * 85 - * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to 86 - * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved 87 - * values. 88 - * 89 - * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2. 90 - * 0xff means the parent hub will accept transitions to U2, but will not 91 - * initiate a transition. 92 - * 93 - * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to 94 - * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2 95 - * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means 96 - * 65.024ms. 97 - */ 98 - #define USB3_LPM_DISABLED 0x0 99 - #define USB3_LPM_U1_MAX_TIMEOUT 0x7F 100 - #define USB3_LPM_U2_MAX_TIMEOUT 0xFE 101 - #define USB3_LPM_DEVICE_INITIATED 0xFF 102 - 103 - struct usb_set_sel_req { 104 - __u8 u1_sel; 105 - __u8 u1_pel; 106 - __le16 u2_sel; 107 - __le16 u2_pel; 108 - } __attribute__ ((packed)); 109 - 110 - /* 111 - * The Set System Exit Latency control transfer provides one byte each for 112 - * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each 113 - * are two bytes long. 114 - */ 115 - #define USB3_LPM_MAX_U1_SEL_PEL 0xFF 116 - #define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF 117 - 118 - /*-------------------------------------------------------------------------*/ 119 - 120 - /* 121 - * As per USB compliance update, a device that is actively drawing 122 - * more than 100mA from USB must report itself as bus-powered in 123 - * the GetStatus(DEVICE) call. 124 - * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34 125 - */ 126 - #define USB_SELF_POWER_VBUS_MAX_DRAW 100 127 921 128 922 #endif /* __LINUX_USB_CH9_H */
+1 -166
include/linux/usb/functionfs.h
··· 1 1 #ifndef __LINUX_FUNCTIONFS_H__ 2 2 #define __LINUX_FUNCTIONFS_H__ 1 3 3 4 + #include <uapi/linux/usb/functionfs.h> 4 5 5 - #include <linux/types.h> 6 - #include <linux/ioctl.h> 7 - 8 - #include <linux/usb/ch9.h> 9 - 10 - 11 - enum { 12 - FUNCTIONFS_DESCRIPTORS_MAGIC = 1, 13 - FUNCTIONFS_STRINGS_MAGIC = 2 14 - }; 15 - 16 - 17 - #ifndef __KERNEL__ 18 - 19 - /* Descriptor of an non-audio endpoint */ 20 - struct usb_endpoint_descriptor_no_audio { 21 - __u8 bLength; 22 - __u8 bDescriptorType; 23 - 24 - __u8 bEndpointAddress; 25 - __u8 bmAttributes; 26 - __le16 wMaxPacketSize; 27 - __u8 bInterval; 28 - } __attribute__((packed)); 29 - 30 - 31 - /* 32 - * All numbers must be in little endian order. 33 - */ 34 - 35 - struct usb_functionfs_descs_head { 36 - __le32 magic; 37 - __le32 length; 38 - __le32 fs_count; 39 - __le32 hs_count; 40 - } __attribute__((packed)); 41 - 42 - /* 43 - * Descriptors format: 44 - * 45 - * | off | name | type | description | 46 - * |-----+-----------+--------------+--------------------------------------| 47 - * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | 48 - * | 4 | length | LE32 | length of the whole data chunk | 49 - * | 8 | fs_count | LE32 | number of full-speed descriptors | 50 - * | 12 | hs_count | LE32 | number of high-speed descriptors | 51 - * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | 52 - * | | hs_descrs | Descriptor[] | list of high-speed descriptors | 53 - * 54 - * descs are just valid USB descriptors and have the following format: 55 - * 56 - * | off | name | type | description | 57 - * |-----+-----------------+------+--------------------------| 58 - * | 0 | bLength | U8 | length of the descriptor | 59 - * | 1 | bDescriptorType | U8 | descriptor type | 60 - * | 2 | payload | | descriptor's payload | 61 - */ 62 - 63 - struct usb_functionfs_strings_head { 64 - __le32 magic; 65 - __le32 length; 66 - __le32 str_count; 67 - __le32 lang_count; 68 - } __attribute__((packed)); 69 - 70 - /* 71 - * Strings format: 72 - * 73 - * | off | name | type | description | 74 - * |-----+------------+-----------------------+----------------------------| 75 - * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC | 76 - * | 4 | length | LE32 | length of the data chunk | 77 - * | 8 | str_count | LE32 | number of strings | 78 - * | 12 | lang_count | LE32 | number of languages | 79 - * | 16 | stringtab | StringTab[lang_count] | table of strings per lang | 80 - * 81 - * For each language there is one stringtab entry (ie. there are lang_count 82 - * stringtab entires). Each StringTab has following format: 83 - * 84 - * | off | name | type | description | 85 - * |-----+---------+-------------------+------------------------------------| 86 - * | 0 | lang | LE16 | language code | 87 - * | 2 | strings | String[str_count] | array of strings in given language | 88 - * 89 - * For each string there is one strings entry (ie. there are str_count 90 - * string entries). Each String is a NUL terminated string encoded in 91 - * UTF-8. 92 - */ 93 - 94 - #endif 95 - 96 - 97 - /* 98 - * Events are delivered on the ep0 file descriptor, when the user mode driver 99 - * reads from this file descriptor after writing the descriptors. Don't 100 - * stop polling this descriptor. 101 - */ 102 - 103 - enum usb_functionfs_event_type { 104 - FUNCTIONFS_BIND, 105 - FUNCTIONFS_UNBIND, 106 - 107 - FUNCTIONFS_ENABLE, 108 - FUNCTIONFS_DISABLE, 109 - 110 - FUNCTIONFS_SETUP, 111 - 112 - FUNCTIONFS_SUSPEND, 113 - FUNCTIONFS_RESUME 114 - }; 115 - 116 - /* NOTE: this structure must stay the same size and layout on 117 - * both 32-bit and 64-bit kernels. 118 - */ 119 - struct usb_functionfs_event { 120 - union { 121 - /* SETUP: packet; DATA phase i/o precedes next event 122 - *(setup.bmRequestType & USB_DIR_IN) flags direction */ 123 - struct usb_ctrlrequest setup; 124 - } __attribute__((packed)) u; 125 - 126 - /* enum usb_functionfs_event_type */ 127 - __u8 type; 128 - __u8 _pad[3]; 129 - } __attribute__((packed)); 130 - 131 - 132 - /* Endpoint ioctls */ 133 - /* The same as in gadgetfs */ 134 - 135 - /* IN transfers may be reported to the gadget driver as complete 136 - * when the fifo is loaded, before the host reads the data; 137 - * OUT transfers may be reported to the host's "client" driver as 138 - * complete when they're sitting in the FIFO unread. 139 - * THIS returns how many bytes are "unclaimed" in the endpoint fifo 140 - * (needed for precise fault handling, when the hardware allows it) 141 - */ 142 - #define FUNCTIONFS_FIFO_STATUS _IO('g', 1) 143 - 144 - /* discards any unclaimed data in the fifo. */ 145 - #define FUNCTIONFS_FIFO_FLUSH _IO('g', 2) 146 - 147 - /* resets endpoint halt+toggle; used to implement set_interface. 148 - * some hardware (like pxa2xx) can't support this. 149 - */ 150 - #define FUNCTIONFS_CLEAR_HALT _IO('g', 3) 151 - 152 - /* Specific for functionfs */ 153 - 154 - /* 155 - * Returns reverse mapping of an interface. Called on EP0. If there 156 - * is no such interface returns -EDOM. If function is not active 157 - * returns -ENODEV. 158 - */ 159 - #define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128) 160 - 161 - /* 162 - * Returns real bEndpointAddress of an endpoint. If function is not 163 - * active returns -ENODEV. 164 - */ 165 - #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) 166 - 167 - 168 - #ifdef __KERNEL__ 169 6 170 7 struct ffs_data; 171 8 struct usb_composite_dev; ··· 32 195 static void functionfs_release_dev_callback(struct ffs_data *ffs_data) 33 196 __attribute__((nonnull)); 34 197 35 - 36 - #endif 37 198 38 199 #endif
include/linux/usb/g_printer.h include/uapi/linux/usb/g_printer.h
include/linux/usb/gadgetfs.h include/uapi/linux/usb/gadgetfs.h
include/linux/usb/midi.h include/uapi/linux/usb/midi.h
include/linux/usb/tmc.h include/uapi/linux/usb/tmc.h
include/linux/usb/video.h include/uapi/linux/usb/video.h
+10
include/uapi/linux/usb/Kbuild
··· 1 1 # UAPI Header export list 2 + header-y += audio.h 3 + header-y += cdc.h 4 + header-y += ch11.h 5 + header-y += ch9.h 6 + header-y += functionfs.h 7 + header-y += g_printer.h 8 + header-y += gadgetfs.h 9 + header-y += midi.h 10 + header-y += tmc.h 11 + header-y += video.h
+545
include/uapi/linux/usb/audio.h
··· 1 + /* 2 + * <linux/usb/audio.h> -- USB Audio definitions. 3 + * 4 + * Copyright (C) 2006 Thumtronics Pty Ltd. 5 + * Developed for Thumtronics by Grey Innovation 6 + * Ben Williamson <ben.williamson@greyinnovation.com> 7 + * 8 + * This software is distributed under the terms of the GNU General Public 9 + * License ("GPL") version 2, as published by the Free Software Foundation. 10 + * 11 + * This file holds USB constants and structures defined 12 + * by the USB Device Class Definition for Audio Devices. 13 + * Comments below reference relevant sections of that document: 14 + * 15 + * http://www.usb.org/developers/devclass_docs/audio10.pdf 16 + * 17 + * Types and defines in this file are either specific to version 1.0 of 18 + * this standard or common for newer versions. 19 + */ 20 + 21 + #ifndef _UAPI__LINUX_USB_AUDIO_H 22 + #define _UAPI__LINUX_USB_AUDIO_H 23 + 24 + #include <linux/types.h> 25 + 26 + /* bInterfaceProtocol values to denote the version of the standard used */ 27 + #define UAC_VERSION_1 0x00 28 + #define UAC_VERSION_2 0x20 29 + 30 + /* A.2 Audio Interface Subclass Codes */ 31 + #define USB_SUBCLASS_AUDIOCONTROL 0x01 32 + #define USB_SUBCLASS_AUDIOSTREAMING 0x02 33 + #define USB_SUBCLASS_MIDISTREAMING 0x03 34 + 35 + /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ 36 + #define UAC_HEADER 0x01 37 + #define UAC_INPUT_TERMINAL 0x02 38 + #define UAC_OUTPUT_TERMINAL 0x03 39 + #define UAC_MIXER_UNIT 0x04 40 + #define UAC_SELECTOR_UNIT 0x05 41 + #define UAC_FEATURE_UNIT 0x06 42 + #define UAC1_PROCESSING_UNIT 0x07 43 + #define UAC1_EXTENSION_UNIT 0x08 44 + 45 + /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ 46 + #define UAC_AS_GENERAL 0x01 47 + #define UAC_FORMAT_TYPE 0x02 48 + #define UAC_FORMAT_SPECIFIC 0x03 49 + 50 + /* A.7 Processing Unit Process Types */ 51 + #define UAC_PROCESS_UNDEFINED 0x00 52 + #define UAC_PROCESS_UP_DOWNMIX 0x01 53 + #define UAC_PROCESS_DOLBY_PROLOGIC 0x02 54 + #define UAC_PROCESS_STEREO_EXTENDER 0x03 55 + #define UAC_PROCESS_REVERB 0x04 56 + #define UAC_PROCESS_CHORUS 0x05 57 + #define UAC_PROCESS_DYN_RANGE_COMP 0x06 58 + 59 + /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ 60 + #define UAC_EP_GENERAL 0x01 61 + 62 + /* A.9 Audio Class-Specific Request Codes */ 63 + #define UAC_SET_ 0x00 64 + #define UAC_GET_ 0x80 65 + 66 + #define UAC__CUR 0x1 67 + #define UAC__MIN 0x2 68 + #define UAC__MAX 0x3 69 + #define UAC__RES 0x4 70 + #define UAC__MEM 0x5 71 + 72 + #define UAC_SET_CUR (UAC_SET_ | UAC__CUR) 73 + #define UAC_GET_CUR (UAC_GET_ | UAC__CUR) 74 + #define UAC_SET_MIN (UAC_SET_ | UAC__MIN) 75 + #define UAC_GET_MIN (UAC_GET_ | UAC__MIN) 76 + #define UAC_SET_MAX (UAC_SET_ | UAC__MAX) 77 + #define UAC_GET_MAX (UAC_GET_ | UAC__MAX) 78 + #define UAC_SET_RES (UAC_SET_ | UAC__RES) 79 + #define UAC_GET_RES (UAC_GET_ | UAC__RES) 80 + #define UAC_SET_MEM (UAC_SET_ | UAC__MEM) 81 + #define UAC_GET_MEM (UAC_GET_ | UAC__MEM) 82 + 83 + #define UAC_GET_STAT 0xff 84 + 85 + /* A.10 Control Selector Codes */ 86 + 87 + /* A.10.1 Terminal Control Selectors */ 88 + #define UAC_TERM_COPY_PROTECT 0x01 89 + 90 + /* A.10.2 Feature Unit Control Selectors */ 91 + #define UAC_FU_MUTE 0x01 92 + #define UAC_FU_VOLUME 0x02 93 + #define UAC_FU_BASS 0x03 94 + #define UAC_FU_MID 0x04 95 + #define UAC_FU_TREBLE 0x05 96 + #define UAC_FU_GRAPHIC_EQUALIZER 0x06 97 + #define UAC_FU_AUTOMATIC_GAIN 0x07 98 + #define UAC_FU_DELAY 0x08 99 + #define UAC_FU_BASS_BOOST 0x09 100 + #define UAC_FU_LOUDNESS 0x0a 101 + 102 + #define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1)) 103 + 104 + /* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */ 105 + #define UAC_UD_ENABLE 0x01 106 + #define UAC_UD_MODE_SELECT 0x02 107 + 108 + /* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */ 109 + #define UAC_DP_ENABLE 0x01 110 + #define UAC_DP_MODE_SELECT 0x02 111 + 112 + /* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */ 113 + #define UAC_3D_ENABLE 0x01 114 + #define UAC_3D_SPACE 0x02 115 + 116 + /* A.10.3.4 Reverberation Processing Unit Control Selectors */ 117 + #define UAC_REVERB_ENABLE 0x01 118 + #define UAC_REVERB_LEVEL 0x02 119 + #define UAC_REVERB_TIME 0x03 120 + #define UAC_REVERB_FEEDBACK 0x04 121 + 122 + /* A.10.3.5 Chorus Processing Unit Control Selectors */ 123 + #define UAC_CHORUS_ENABLE 0x01 124 + #define UAC_CHORUS_LEVEL 0x02 125 + #define UAC_CHORUS_RATE 0x03 126 + #define UAC_CHORUS_DEPTH 0x04 127 + 128 + /* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */ 129 + #define UAC_DCR_ENABLE 0x01 130 + #define UAC_DCR_RATE 0x02 131 + #define UAC_DCR_MAXAMPL 0x03 132 + #define UAC_DCR_THRESHOLD 0x04 133 + #define UAC_DCR_ATTACK_TIME 0x05 134 + #define UAC_DCR_RELEASE_TIME 0x06 135 + 136 + /* A.10.4 Extension Unit Control Selectors */ 137 + #define UAC_XU_ENABLE 0x01 138 + 139 + /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ 140 + #define UAC_MS_HEADER 0x01 141 + #define UAC_MIDI_IN_JACK 0x02 142 + #define UAC_MIDI_OUT_JACK 0x03 143 + 144 + /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */ 145 + #define UAC_MS_GENERAL 0x01 146 + 147 + /* Terminals - 2.1 USB Terminal Types */ 148 + #define UAC_TERMINAL_UNDEFINED 0x100 149 + #define UAC_TERMINAL_STREAMING 0x101 150 + #define UAC_TERMINAL_VENDOR_SPEC 0x1FF 151 + 152 + /* Terminal Control Selectors */ 153 + /* 4.3.2 Class-Specific AC Interface Descriptor */ 154 + struct uac1_ac_header_descriptor { 155 + __u8 bLength; /* 8 + n */ 156 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 157 + __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ 158 + __le16 bcdADC; /* 0x0100 */ 159 + __le16 wTotalLength; /* includes Unit and Terminal desc. */ 160 + __u8 bInCollection; /* n */ 161 + __u8 baInterfaceNr[]; /* [n] */ 162 + } __attribute__ ((packed)); 163 + 164 + #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) 165 + 166 + /* As above, but more useful for defining your own descriptors: */ 167 + #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ 168 + struct uac1_ac_header_descriptor_##n { \ 169 + __u8 bLength; \ 170 + __u8 bDescriptorType; \ 171 + __u8 bDescriptorSubtype; \ 172 + __le16 bcdADC; \ 173 + __le16 wTotalLength; \ 174 + __u8 bInCollection; \ 175 + __u8 baInterfaceNr[n]; \ 176 + } __attribute__ ((packed)) 177 + 178 + /* 4.3.2.1 Input Terminal Descriptor */ 179 + struct uac_input_terminal_descriptor { 180 + __u8 bLength; /* in bytes: 12 */ 181 + __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 182 + __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */ 183 + __u8 bTerminalID; /* Constant uniquely terminal ID */ 184 + __le16 wTerminalType; /* USB Audio Terminal Types */ 185 + __u8 bAssocTerminal; /* ID of the Output Terminal associated */ 186 + __u8 bNrChannels; /* Number of logical output channels */ 187 + __le16 wChannelConfig; 188 + __u8 iChannelNames; 189 + __u8 iTerminal; 190 + } __attribute__ ((packed)); 191 + 192 + #define UAC_DT_INPUT_TERMINAL_SIZE 12 193 + 194 + /* Terminals - 2.2 Input Terminal Types */ 195 + #define UAC_INPUT_TERMINAL_UNDEFINED 0x200 196 + #define UAC_INPUT_TERMINAL_MICROPHONE 0x201 197 + #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202 198 + #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203 199 + #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204 200 + #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 201 + #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 202 + 203 + /* Terminals - control selectors */ 204 + 205 + #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01 206 + 207 + /* 4.3.2.2 Output Terminal Descriptor */ 208 + struct uac1_output_terminal_descriptor { 209 + __u8 bLength; /* in bytes: 9 */ 210 + __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 211 + __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ 212 + __u8 bTerminalID; /* Constant uniquely terminal ID */ 213 + __le16 wTerminalType; /* USB Audio Terminal Types */ 214 + __u8 bAssocTerminal; /* ID of the Input Terminal associated */ 215 + __u8 bSourceID; /* ID of the connected Unit or Terminal*/ 216 + __u8 iTerminal; 217 + } __attribute__ ((packed)); 218 + 219 + #define UAC_DT_OUTPUT_TERMINAL_SIZE 9 220 + 221 + /* Terminals - 2.3 Output Terminal Types */ 222 + #define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300 223 + #define UAC_OUTPUT_TERMINAL_SPEAKER 0x301 224 + #define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302 225 + #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303 226 + #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304 227 + #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305 228 + #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306 229 + #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307 230 + 231 + /* Set bControlSize = 2 as default setting */ 232 + #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) 233 + 234 + /* As above, but more useful for defining your own descriptors: */ 235 + #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ 236 + struct uac_feature_unit_descriptor_##ch { \ 237 + __u8 bLength; \ 238 + __u8 bDescriptorType; \ 239 + __u8 bDescriptorSubtype; \ 240 + __u8 bUnitID; \ 241 + __u8 bSourceID; \ 242 + __u8 bControlSize; \ 243 + __le16 bmaControls[ch + 1]; \ 244 + __u8 iFeature; \ 245 + } __attribute__ ((packed)) 246 + 247 + /* 4.3.2.3 Mixer Unit Descriptor */ 248 + struct uac_mixer_unit_descriptor { 249 + __u8 bLength; 250 + __u8 bDescriptorType; 251 + __u8 bDescriptorSubtype; 252 + __u8 bUnitID; 253 + __u8 bNrInPins; 254 + __u8 baSourceID[]; 255 + } __attribute__ ((packed)); 256 + 257 + static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc) 258 + { 259 + return desc->baSourceID[desc->bNrInPins]; 260 + } 261 + 262 + static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc, 263 + int protocol) 264 + { 265 + if (protocol == UAC_VERSION_1) 266 + return (desc->baSourceID[desc->bNrInPins + 2] << 8) | 267 + desc->baSourceID[desc->bNrInPins + 1]; 268 + else 269 + return (desc->baSourceID[desc->bNrInPins + 4] << 24) | 270 + (desc->baSourceID[desc->bNrInPins + 3] << 16) | 271 + (desc->baSourceID[desc->bNrInPins + 2] << 8) | 272 + (desc->baSourceID[desc->bNrInPins + 1]); 273 + } 274 + 275 + static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc, 276 + int protocol) 277 + { 278 + return (protocol == UAC_VERSION_1) ? 279 + desc->baSourceID[desc->bNrInPins + 3] : 280 + desc->baSourceID[desc->bNrInPins + 5]; 281 + } 282 + 283 + static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc, 284 + int protocol) 285 + { 286 + return (protocol == UAC_VERSION_1) ? 287 + &desc->baSourceID[desc->bNrInPins + 4] : 288 + &desc->baSourceID[desc->bNrInPins + 6]; 289 + } 290 + 291 + static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc) 292 + { 293 + __u8 *raw = (__u8 *) desc; 294 + return raw[desc->bLength - 1]; 295 + } 296 + 297 + /* 4.3.2.4 Selector Unit Descriptor */ 298 + struct uac_selector_unit_descriptor { 299 + __u8 bLength; 300 + __u8 bDescriptorType; 301 + __u8 bDescriptorSubtype; 302 + __u8 bUintID; 303 + __u8 bNrInPins; 304 + __u8 baSourceID[]; 305 + } __attribute__ ((packed)); 306 + 307 + static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc) 308 + { 309 + __u8 *raw = (__u8 *) desc; 310 + return raw[desc->bLength - 1]; 311 + } 312 + 313 + /* 4.3.2.5 Feature Unit Descriptor */ 314 + struct uac_feature_unit_descriptor { 315 + __u8 bLength; 316 + __u8 bDescriptorType; 317 + __u8 bDescriptorSubtype; 318 + __u8 bUnitID; 319 + __u8 bSourceID; 320 + __u8 bControlSize; 321 + __u8 bmaControls[0]; /* variable length */ 322 + } __attribute__((packed)); 323 + 324 + static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc) 325 + { 326 + __u8 *raw = (__u8 *) desc; 327 + return raw[desc->bLength - 1]; 328 + } 329 + 330 + /* 4.3.2.6 Processing Unit Descriptors */ 331 + struct uac_processing_unit_descriptor { 332 + __u8 bLength; 333 + __u8 bDescriptorType; 334 + __u8 bDescriptorSubtype; 335 + __u8 bUnitID; 336 + __u16 wProcessType; 337 + __u8 bNrInPins; 338 + __u8 baSourceID[]; 339 + } __attribute__ ((packed)); 340 + 341 + static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc) 342 + { 343 + return desc->baSourceID[desc->bNrInPins]; 344 + } 345 + 346 + static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc, 347 + int protocol) 348 + { 349 + if (protocol == UAC_VERSION_1) 350 + return (desc->baSourceID[desc->bNrInPins + 2] << 8) | 351 + desc->baSourceID[desc->bNrInPins + 1]; 352 + else 353 + return (desc->baSourceID[desc->bNrInPins + 4] << 24) | 354 + (desc->baSourceID[desc->bNrInPins + 3] << 16) | 355 + (desc->baSourceID[desc->bNrInPins + 2] << 8) | 356 + (desc->baSourceID[desc->bNrInPins + 1]); 357 + } 358 + 359 + static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc, 360 + int protocol) 361 + { 362 + return (protocol == UAC_VERSION_1) ? 363 + desc->baSourceID[desc->bNrInPins + 3] : 364 + desc->baSourceID[desc->bNrInPins + 5]; 365 + } 366 + 367 + static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc, 368 + int protocol) 369 + { 370 + return (protocol == UAC_VERSION_1) ? 371 + desc->baSourceID[desc->bNrInPins + 4] : 372 + desc->baSourceID[desc->bNrInPins + 6]; 373 + } 374 + 375 + static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc, 376 + int protocol) 377 + { 378 + return (protocol == UAC_VERSION_1) ? 379 + &desc->baSourceID[desc->bNrInPins + 5] : 380 + &desc->baSourceID[desc->bNrInPins + 7]; 381 + } 382 + 383 + static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc, 384 + int protocol) 385 + { 386 + __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); 387 + return desc->baSourceID[desc->bNrInPins + control_size]; 388 + } 389 + 390 + static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc, 391 + int protocol) 392 + { 393 + __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); 394 + return &desc->baSourceID[desc->bNrInPins + control_size + 1]; 395 + } 396 + 397 + /* 4.5.2 Class-Specific AS Interface Descriptor */ 398 + struct uac1_as_header_descriptor { 399 + __u8 bLength; /* in bytes: 7 */ 400 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 401 + __u8 bDescriptorSubtype; /* AS_GENERAL */ 402 + __u8 bTerminalLink; /* Terminal ID of connected Terminal */ 403 + __u8 bDelay; /* Delay introduced by the data path */ 404 + __le16 wFormatTag; /* The Audio Data Format */ 405 + } __attribute__ ((packed)); 406 + 407 + #define UAC_DT_AS_HEADER_SIZE 7 408 + 409 + /* Formats - A.1.1 Audio Data Format Type I Codes */ 410 + #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0 411 + #define UAC_FORMAT_TYPE_I_PCM 0x1 412 + #define UAC_FORMAT_TYPE_I_PCM8 0x2 413 + #define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3 414 + #define UAC_FORMAT_TYPE_I_ALAW 0x4 415 + #define UAC_FORMAT_TYPE_I_MULAW 0x5 416 + 417 + struct uac_format_type_i_continuous_descriptor { 418 + __u8 bLength; /* in bytes: 8 + (ns * 3) */ 419 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 420 + __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 421 + __u8 bFormatType; /* FORMAT_TYPE_1 */ 422 + __u8 bNrChannels; /* physical channels in the stream */ 423 + __u8 bSubframeSize; /* */ 424 + __u8 bBitResolution; 425 + __u8 bSamFreqType; 426 + __u8 tLowerSamFreq[3]; 427 + __u8 tUpperSamFreq[3]; 428 + } __attribute__ ((packed)); 429 + 430 + #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14 431 + 432 + struct uac_format_type_i_discrete_descriptor { 433 + __u8 bLength; /* in bytes: 8 + (ns * 3) */ 434 + __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 435 + __u8 bDescriptorSubtype; /* FORMAT_TYPE */ 436 + __u8 bFormatType; /* FORMAT_TYPE_1 */ 437 + __u8 bNrChannels; /* physical channels in the stream */ 438 + __u8 bSubframeSize; /* */ 439 + __u8 bBitResolution; 440 + __u8 bSamFreqType; 441 + __u8 tSamFreq[][3]; 442 + } __attribute__ ((packed)); 443 + 444 + #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ 445 + struct uac_format_type_i_discrete_descriptor_##n { \ 446 + __u8 bLength; \ 447 + __u8 bDescriptorType; \ 448 + __u8 bDescriptorSubtype; \ 449 + __u8 bFormatType; \ 450 + __u8 bNrChannels; \ 451 + __u8 bSubframeSize; \ 452 + __u8 bBitResolution; \ 453 + __u8 bSamFreqType; \ 454 + __u8 tSamFreq[n][3]; \ 455 + } __attribute__ ((packed)) 456 + 457 + #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) 458 + 459 + struct uac_format_type_i_ext_descriptor { 460 + __u8 bLength; 461 + __u8 bDescriptorType; 462 + __u8 bDescriptorSubtype; 463 + __u8 bFormatType; 464 + __u8 bSubslotSize; 465 + __u8 bBitResolution; 466 + __u8 bHeaderLength; 467 + __u8 bControlSize; 468 + __u8 bSideBandProtocol; 469 + } __attribute__((packed)); 470 + 471 + /* Formats - Audio Data Format Type I Codes */ 472 + 473 + #define UAC_FORMAT_TYPE_II_MPEG 0x1001 474 + #define UAC_FORMAT_TYPE_II_AC3 0x1002 475 + 476 + struct uac_format_type_ii_discrete_descriptor { 477 + __u8 bLength; 478 + __u8 bDescriptorType; 479 + __u8 bDescriptorSubtype; 480 + __u8 bFormatType; 481 + __le16 wMaxBitRate; 482 + __le16 wSamplesPerFrame; 483 + __u8 bSamFreqType; 484 + __u8 tSamFreq[][3]; 485 + } __attribute__((packed)); 486 + 487 + struct uac_format_type_ii_ext_descriptor { 488 + __u8 bLength; 489 + __u8 bDescriptorType; 490 + __u8 bDescriptorSubtype; 491 + __u8 bFormatType; 492 + __u16 wMaxBitRate; 493 + __u16 wSamplesPerFrame; 494 + __u8 bHeaderLength; 495 + __u8 bSideBandProtocol; 496 + } __attribute__((packed)); 497 + 498 + /* type III */ 499 + #define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001 500 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002 501 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003 502 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004 503 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005 504 + #define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006 505 + 506 + /* Formats - A.2 Format Type Codes */ 507 + #define UAC_FORMAT_TYPE_UNDEFINED 0x0 508 + #define UAC_FORMAT_TYPE_I 0x1 509 + #define UAC_FORMAT_TYPE_II 0x2 510 + #define UAC_FORMAT_TYPE_III 0x3 511 + #define UAC_EXT_FORMAT_TYPE_I 0x81 512 + #define UAC_EXT_FORMAT_TYPE_II 0x82 513 + #define UAC_EXT_FORMAT_TYPE_III 0x83 514 + 515 + struct uac_iso_endpoint_descriptor { 516 + __u8 bLength; /* in bytes: 7 */ 517 + __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ 518 + __u8 bDescriptorSubtype; /* EP_GENERAL */ 519 + __u8 bmAttributes; 520 + __u8 bLockDelayUnits; 521 + __le16 wLockDelay; 522 + } __attribute__((packed)); 523 + #define UAC_ISO_ENDPOINT_DESC_SIZE 7 524 + 525 + #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 526 + #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 527 + #define UAC_EP_CS_ATTR_FILL_MAX 0x80 528 + 529 + /* status word format (3.7.1.1) */ 530 + 531 + #define UAC1_STATUS_TYPE_ORIG_MASK 0x0f 532 + #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0 533 + #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1 534 + #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2 535 + 536 + #define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7) 537 + #define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6) 538 + 539 + struct uac1_status_word { 540 + __u8 bStatusType; 541 + __u8 bOriginator; 542 + } __attribute__((packed)); 543 + 544 + 545 + #endif /* _UAPI__LINUX_USB_AUDIO_H */
+993
include/uapi/linux/usb/ch9.h
··· 1 + /* 2 + * This file holds USB constants and structures that are needed for 3 + * USB device APIs. These are used by the USB device model, which is 4 + * defined in chapter 9 of the USB 2.0 specification and in the 5 + * Wireless USB 1.0 (spread around). Linux has several APIs in C that 6 + * need these: 7 + * 8 + * - the master/host side Linux-USB kernel driver API; 9 + * - the "usbfs" user space API; and 10 + * - the Linux "gadget" slave/device/peripheral side driver API. 11 + * 12 + * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems 13 + * act either as a USB master/host or as a USB slave/device. That means 14 + * the master and slave side APIs benefit from working well together. 15 + * 16 + * There's also "Wireless USB", using low power short range radios for 17 + * peripheral interconnection but otherwise building on the USB framework. 18 + * 19 + * Note all descriptors are declared '__attribute__((packed))' so that: 20 + * 21 + * [a] they never get padded, either internally (USB spec writers 22 + * probably handled that) or externally; 23 + * 24 + * [b] so that accessing bigger-than-a-bytes fields will never 25 + * generate bus errors on any platform, even when the location of 26 + * its descriptor inside a bundle isn't "naturally aligned", and 27 + * 28 + * [c] for consistency, removing all doubt even when it appears to 29 + * someone that the two other points are non-issues for that 30 + * particular descriptor type. 31 + */ 32 + 33 + #ifndef _UAPI__LINUX_USB_CH9_H 34 + #define _UAPI__LINUX_USB_CH9_H 35 + 36 + #include <linux/types.h> /* __u8 etc */ 37 + #include <asm/byteorder.h> /* le16_to_cpu */ 38 + 39 + /*-------------------------------------------------------------------------*/ 40 + 41 + /* CONTROL REQUEST SUPPORT */ 42 + 43 + /* 44 + * USB directions 45 + * 46 + * This bit flag is used in endpoint descriptors' bEndpointAddress field. 47 + * It's also one of three fields in control requests bRequestType. 48 + */ 49 + #define USB_DIR_OUT 0 /* to device */ 50 + #define USB_DIR_IN 0x80 /* to host */ 51 + 52 + /* 53 + * USB types, the second of three bRequestType fields 54 + */ 55 + #define USB_TYPE_MASK (0x03 << 5) 56 + #define USB_TYPE_STANDARD (0x00 << 5) 57 + #define USB_TYPE_CLASS (0x01 << 5) 58 + #define USB_TYPE_VENDOR (0x02 << 5) 59 + #define USB_TYPE_RESERVED (0x03 << 5) 60 + 61 + /* 62 + * USB recipients, the third of three bRequestType fields 63 + */ 64 + #define USB_RECIP_MASK 0x1f 65 + #define USB_RECIP_DEVICE 0x00 66 + #define USB_RECIP_INTERFACE 0x01 67 + #define USB_RECIP_ENDPOINT 0x02 68 + #define USB_RECIP_OTHER 0x03 69 + /* From Wireless USB 1.0 */ 70 + #define USB_RECIP_PORT 0x04 71 + #define USB_RECIP_RPIPE 0x05 72 + 73 + /* 74 + * Standard requests, for the bRequest field of a SETUP packet. 75 + * 76 + * These are qualified by the bRequestType field, so that for example 77 + * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved 78 + * by a GET_STATUS request. 79 + */ 80 + #define USB_REQ_GET_STATUS 0x00 81 + #define USB_REQ_CLEAR_FEATURE 0x01 82 + #define USB_REQ_SET_FEATURE 0x03 83 + #define USB_REQ_SET_ADDRESS 0x05 84 + #define USB_REQ_GET_DESCRIPTOR 0x06 85 + #define USB_REQ_SET_DESCRIPTOR 0x07 86 + #define USB_REQ_GET_CONFIGURATION 0x08 87 + #define USB_REQ_SET_CONFIGURATION 0x09 88 + #define USB_REQ_GET_INTERFACE 0x0A 89 + #define USB_REQ_SET_INTERFACE 0x0B 90 + #define USB_REQ_SYNCH_FRAME 0x0C 91 + #define USB_REQ_SET_SEL 0x30 92 + #define USB_REQ_SET_ISOCH_DELAY 0x31 93 + 94 + #define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */ 95 + #define USB_REQ_GET_ENCRYPTION 0x0E 96 + #define USB_REQ_RPIPE_ABORT 0x0E 97 + #define USB_REQ_SET_HANDSHAKE 0x0F 98 + #define USB_REQ_RPIPE_RESET 0x0F 99 + #define USB_REQ_GET_HANDSHAKE 0x10 100 + #define USB_REQ_SET_CONNECTION 0x11 101 + #define USB_REQ_SET_SECURITY_DATA 0x12 102 + #define USB_REQ_GET_SECURITY_DATA 0x13 103 + #define USB_REQ_SET_WUSB_DATA 0x14 104 + #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 105 + #define USB_REQ_LOOPBACK_DATA_READ 0x16 106 + #define USB_REQ_SET_INTERFACE_DS 0x17 107 + 108 + /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, 109 + * used by hubs to put ports into a new L1 suspend state, except that it 110 + * forgot to define its number ... 111 + */ 112 + 113 + /* 114 + * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and 115 + * are read as a bit array returned by USB_REQ_GET_STATUS. (So there 116 + * are at most sixteen features of each type.) Hubs may also support a 117 + * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. 118 + */ 119 + #define USB_DEVICE_SELF_POWERED 0 /* (read only) */ 120 + #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ 121 + #define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */ 122 + #define USB_DEVICE_BATTERY 2 /* (wireless) */ 123 + #define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */ 124 + #define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/ 125 + #define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */ 126 + #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ 127 + #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ 128 + 129 + /* 130 + * Test Mode Selectors 131 + * See USB 2.0 spec Table 9-7 132 + */ 133 + #define TEST_J 1 134 + #define TEST_K 2 135 + #define TEST_SE0_NAK 3 136 + #define TEST_PACKET 4 137 + #define TEST_FORCE_EN 5 138 + 139 + /* 140 + * New Feature Selectors as added by USB 3.0 141 + * See USB 3.0 spec Table 9-6 142 + */ 143 + #define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ 144 + #define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */ 145 + #define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */ 146 + #define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */ 147 + 148 + #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 149 + /* 150 + * Suspend Options, Table 9-7 USB 3.0 spec 151 + */ 152 + #define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0)) 153 + #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1)) 154 + 155 + #define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ 156 + 157 + /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */ 158 + #define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */ 159 + #define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ 160 + #define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ 161 + 162 + /** 163 + * struct usb_ctrlrequest - SETUP data for a USB device control request 164 + * @bRequestType: matches the USB bmRequestType field 165 + * @bRequest: matches the USB bRequest field 166 + * @wValue: matches the USB wValue field (le16 byte order) 167 + * @wIndex: matches the USB wIndex field (le16 byte order) 168 + * @wLength: matches the USB wLength field (le16 byte order) 169 + * 170 + * This structure is used to send control requests to a USB device. It matches 171 + * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the 172 + * USB spec for a fuller description of the different fields, and what they are 173 + * used for. 174 + * 175 + * Note that the driver for any interface can issue control requests. 176 + * For most devices, interfaces don't coordinate with each other, so 177 + * such requests may be made at any time. 178 + */ 179 + struct usb_ctrlrequest { 180 + __u8 bRequestType; 181 + __u8 bRequest; 182 + __le16 wValue; 183 + __le16 wIndex; 184 + __le16 wLength; 185 + } __attribute__ ((packed)); 186 + 187 + /*-------------------------------------------------------------------------*/ 188 + 189 + /* 190 + * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or 191 + * (rarely) accepted by SET_DESCRIPTOR. 192 + * 193 + * Note that all multi-byte values here are encoded in little endian 194 + * byte order "on the wire". Within the kernel and when exposed 195 + * through the Linux-USB APIs, they are not converted to cpu byte 196 + * order; it is the responsibility of the client code to do this. 197 + * The single exception is when device and configuration descriptors (but 198 + * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD); 199 + * in this case the fields are converted to host endianness by the kernel. 200 + */ 201 + 202 + /* 203 + * Descriptor types ... USB 2.0 spec table 9.5 204 + */ 205 + #define USB_DT_DEVICE 0x01 206 + #define USB_DT_CONFIG 0x02 207 + #define USB_DT_STRING 0x03 208 + #define USB_DT_INTERFACE 0x04 209 + #define USB_DT_ENDPOINT 0x05 210 + #define USB_DT_DEVICE_QUALIFIER 0x06 211 + #define USB_DT_OTHER_SPEED_CONFIG 0x07 212 + #define USB_DT_INTERFACE_POWER 0x08 213 + /* these are from a minor usb 2.0 revision (ECN) */ 214 + #define USB_DT_OTG 0x09 215 + #define USB_DT_DEBUG 0x0a 216 + #define USB_DT_INTERFACE_ASSOCIATION 0x0b 217 + /* these are from the Wireless USB spec */ 218 + #define USB_DT_SECURITY 0x0c 219 + #define USB_DT_KEY 0x0d 220 + #define USB_DT_ENCRYPTION_TYPE 0x0e 221 + #define USB_DT_BOS 0x0f 222 + #define USB_DT_DEVICE_CAPABILITY 0x10 223 + #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 224 + #define USB_DT_WIRE_ADAPTER 0x21 225 + #define USB_DT_RPIPE 0x22 226 + #define USB_DT_CS_RADIO_CONTROL 0x23 227 + /* From the T10 UAS specification */ 228 + #define USB_DT_PIPE_USAGE 0x24 229 + /* From the USB 3.0 spec */ 230 + #define USB_DT_SS_ENDPOINT_COMP 0x30 231 + 232 + /* Conventional codes for class-specific descriptors. The convention is 233 + * defined in the USB "Common Class" Spec (3.11). Individual class specs 234 + * are authoritative for their usage, not the "common class" writeup. 235 + */ 236 + #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) 237 + #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) 238 + #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) 239 + #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) 240 + #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) 241 + 242 + /* All standard descriptors have these 2 fields at the beginning */ 243 + struct usb_descriptor_header { 244 + __u8 bLength; 245 + __u8 bDescriptorType; 246 + } __attribute__ ((packed)); 247 + 248 + 249 + /*-------------------------------------------------------------------------*/ 250 + 251 + /* USB_DT_DEVICE: Device descriptor */ 252 + struct usb_device_descriptor { 253 + __u8 bLength; 254 + __u8 bDescriptorType; 255 + 256 + __le16 bcdUSB; 257 + __u8 bDeviceClass; 258 + __u8 bDeviceSubClass; 259 + __u8 bDeviceProtocol; 260 + __u8 bMaxPacketSize0; 261 + __le16 idVendor; 262 + __le16 idProduct; 263 + __le16 bcdDevice; 264 + __u8 iManufacturer; 265 + __u8 iProduct; 266 + __u8 iSerialNumber; 267 + __u8 bNumConfigurations; 268 + } __attribute__ ((packed)); 269 + 270 + #define USB_DT_DEVICE_SIZE 18 271 + 272 + 273 + /* 274 + * Device and/or Interface Class codes 275 + * as found in bDeviceClass or bInterfaceClass 276 + * and defined by www.usb.org documents 277 + */ 278 + #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ 279 + #define USB_CLASS_AUDIO 1 280 + #define USB_CLASS_COMM 2 281 + #define USB_CLASS_HID 3 282 + #define USB_CLASS_PHYSICAL 5 283 + #define USB_CLASS_STILL_IMAGE 6 284 + #define USB_CLASS_PRINTER 7 285 + #define USB_CLASS_MASS_STORAGE 8 286 + #define USB_CLASS_HUB 9 287 + #define USB_CLASS_CDC_DATA 0x0a 288 + #define USB_CLASS_CSCID 0x0b /* chip+ smart card */ 289 + #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ 290 + #define USB_CLASS_VIDEO 0x0e 291 + #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 292 + #define USB_CLASS_MISC 0xef 293 + #define USB_CLASS_APP_SPEC 0xfe 294 + #define USB_CLASS_VENDOR_SPEC 0xff 295 + 296 + #define USB_SUBCLASS_VENDOR_SPEC 0xff 297 + 298 + /*-------------------------------------------------------------------------*/ 299 + 300 + /* USB_DT_CONFIG: Configuration descriptor information. 301 + * 302 + * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the 303 + * descriptor type is different. Highspeed-capable devices can look 304 + * different depending on what speed they're currently running. Only 305 + * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG 306 + * descriptors. 307 + */ 308 + struct usb_config_descriptor { 309 + __u8 bLength; 310 + __u8 bDescriptorType; 311 + 312 + __le16 wTotalLength; 313 + __u8 bNumInterfaces; 314 + __u8 bConfigurationValue; 315 + __u8 iConfiguration; 316 + __u8 bmAttributes; 317 + __u8 bMaxPower; 318 + } __attribute__ ((packed)); 319 + 320 + #define USB_DT_CONFIG_SIZE 9 321 + 322 + /* from config descriptor bmAttributes */ 323 + #define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ 324 + #define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ 325 + #define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ 326 + #define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ 327 + 328 + /*-------------------------------------------------------------------------*/ 329 + 330 + /* USB_DT_STRING: String descriptor */ 331 + struct usb_string_descriptor { 332 + __u8 bLength; 333 + __u8 bDescriptorType; 334 + 335 + __le16 wData[1]; /* UTF-16LE encoded */ 336 + } __attribute__ ((packed)); 337 + 338 + /* note that "string" zero is special, it holds language codes that 339 + * the device supports, not Unicode characters. 340 + */ 341 + 342 + /*-------------------------------------------------------------------------*/ 343 + 344 + /* USB_DT_INTERFACE: Interface descriptor */ 345 + struct usb_interface_descriptor { 346 + __u8 bLength; 347 + __u8 bDescriptorType; 348 + 349 + __u8 bInterfaceNumber; 350 + __u8 bAlternateSetting; 351 + __u8 bNumEndpoints; 352 + __u8 bInterfaceClass; 353 + __u8 bInterfaceSubClass; 354 + __u8 bInterfaceProtocol; 355 + __u8 iInterface; 356 + } __attribute__ ((packed)); 357 + 358 + #define USB_DT_INTERFACE_SIZE 9 359 + 360 + /*-------------------------------------------------------------------------*/ 361 + 362 + /* USB_DT_ENDPOINT: Endpoint descriptor */ 363 + struct usb_endpoint_descriptor { 364 + __u8 bLength; 365 + __u8 bDescriptorType; 366 + 367 + __u8 bEndpointAddress; 368 + __u8 bmAttributes; 369 + __le16 wMaxPacketSize; 370 + __u8 bInterval; 371 + 372 + /* NOTE: these two are _only_ in audio endpoints. */ 373 + /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ 374 + __u8 bRefresh; 375 + __u8 bSynchAddress; 376 + } __attribute__ ((packed)); 377 + 378 + #define USB_DT_ENDPOINT_SIZE 7 379 + #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ 380 + 381 + 382 + /* 383 + * Endpoints 384 + */ 385 + #define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ 386 + #define USB_ENDPOINT_DIR_MASK 0x80 387 + 388 + #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ 389 + #define USB_ENDPOINT_XFER_CONTROL 0 390 + #define USB_ENDPOINT_XFER_ISOC 1 391 + #define USB_ENDPOINT_XFER_BULK 2 392 + #define USB_ENDPOINT_XFER_INT 3 393 + #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 394 + 395 + /* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */ 396 + #define USB_ENDPOINT_INTRTYPE 0x30 397 + #define USB_ENDPOINT_INTR_PERIODIC (0 << 4) 398 + #define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4) 399 + 400 + #define USB_ENDPOINT_SYNCTYPE 0x0c 401 + #define USB_ENDPOINT_SYNC_NONE (0 << 2) 402 + #define USB_ENDPOINT_SYNC_ASYNC (1 << 2) 403 + #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) 404 + #define USB_ENDPOINT_SYNC_SYNC (3 << 2) 405 + 406 + #define USB_ENDPOINT_USAGE_MASK 0x30 407 + #define USB_ENDPOINT_USAGE_DATA 0x00 408 + #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 409 + #define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */ 410 + 411 + /*-------------------------------------------------------------------------*/ 412 + 413 + /** 414 + * usb_endpoint_num - get the endpoint's number 415 + * @epd: endpoint to be checked 416 + * 417 + * Returns @epd's number: 0 to 15. 418 + */ 419 + static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) 420 + { 421 + return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; 422 + } 423 + 424 + /** 425 + * usb_endpoint_type - get the endpoint's transfer type 426 + * @epd: endpoint to be checked 427 + * 428 + * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according 429 + * to @epd's transfer type. 430 + */ 431 + static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) 432 + { 433 + return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; 434 + } 435 + 436 + /** 437 + * usb_endpoint_dir_in - check if the endpoint has IN direction 438 + * @epd: endpoint to be checked 439 + * 440 + * Returns true if the endpoint is of type IN, otherwise it returns false. 441 + */ 442 + static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) 443 + { 444 + return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); 445 + } 446 + 447 + /** 448 + * usb_endpoint_dir_out - check if the endpoint has OUT direction 449 + * @epd: endpoint to be checked 450 + * 451 + * Returns true if the endpoint is of type OUT, otherwise it returns false. 452 + */ 453 + static inline int usb_endpoint_dir_out( 454 + const struct usb_endpoint_descriptor *epd) 455 + { 456 + return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); 457 + } 458 + 459 + /** 460 + * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type 461 + * @epd: endpoint to be checked 462 + * 463 + * Returns true if the endpoint is of type bulk, otherwise it returns false. 464 + */ 465 + static inline int usb_endpoint_xfer_bulk( 466 + const struct usb_endpoint_descriptor *epd) 467 + { 468 + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 469 + USB_ENDPOINT_XFER_BULK); 470 + } 471 + 472 + /** 473 + * usb_endpoint_xfer_control - check if the endpoint has control transfer type 474 + * @epd: endpoint to be checked 475 + * 476 + * Returns true if the endpoint is of type control, otherwise it returns false. 477 + */ 478 + static inline int usb_endpoint_xfer_control( 479 + const struct usb_endpoint_descriptor *epd) 480 + { 481 + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 482 + USB_ENDPOINT_XFER_CONTROL); 483 + } 484 + 485 + /** 486 + * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type 487 + * @epd: endpoint to be checked 488 + * 489 + * Returns true if the endpoint is of type interrupt, otherwise it returns 490 + * false. 491 + */ 492 + static inline int usb_endpoint_xfer_int( 493 + const struct usb_endpoint_descriptor *epd) 494 + { 495 + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 496 + USB_ENDPOINT_XFER_INT); 497 + } 498 + 499 + /** 500 + * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type 501 + * @epd: endpoint to be checked 502 + * 503 + * Returns true if the endpoint is of type isochronous, otherwise it returns 504 + * false. 505 + */ 506 + static inline int usb_endpoint_xfer_isoc( 507 + const struct usb_endpoint_descriptor *epd) 508 + { 509 + return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 510 + USB_ENDPOINT_XFER_ISOC); 511 + } 512 + 513 + /** 514 + * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN 515 + * @epd: endpoint to be checked 516 + * 517 + * Returns true if the endpoint has bulk transfer type and IN direction, 518 + * otherwise it returns false. 519 + */ 520 + static inline int usb_endpoint_is_bulk_in( 521 + const struct usb_endpoint_descriptor *epd) 522 + { 523 + return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); 524 + } 525 + 526 + /** 527 + * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT 528 + * @epd: endpoint to be checked 529 + * 530 + * Returns true if the endpoint has bulk transfer type and OUT direction, 531 + * otherwise it returns false. 532 + */ 533 + static inline int usb_endpoint_is_bulk_out( 534 + const struct usb_endpoint_descriptor *epd) 535 + { 536 + return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); 537 + } 538 + 539 + /** 540 + * usb_endpoint_is_int_in - check if the endpoint is interrupt IN 541 + * @epd: endpoint to be checked 542 + * 543 + * Returns true if the endpoint has interrupt transfer type and IN direction, 544 + * otherwise it returns false. 545 + */ 546 + static inline int usb_endpoint_is_int_in( 547 + const struct usb_endpoint_descriptor *epd) 548 + { 549 + return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); 550 + } 551 + 552 + /** 553 + * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT 554 + * @epd: endpoint to be checked 555 + * 556 + * Returns true if the endpoint has interrupt transfer type and OUT direction, 557 + * otherwise it returns false. 558 + */ 559 + static inline int usb_endpoint_is_int_out( 560 + const struct usb_endpoint_descriptor *epd) 561 + { 562 + return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd); 563 + } 564 + 565 + /** 566 + * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN 567 + * @epd: endpoint to be checked 568 + * 569 + * Returns true if the endpoint has isochronous transfer type and IN direction, 570 + * otherwise it returns false. 571 + */ 572 + static inline int usb_endpoint_is_isoc_in( 573 + const struct usb_endpoint_descriptor *epd) 574 + { 575 + return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd); 576 + } 577 + 578 + /** 579 + * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT 580 + * @epd: endpoint to be checked 581 + * 582 + * Returns true if the endpoint has isochronous transfer type and OUT direction, 583 + * otherwise it returns false. 584 + */ 585 + static inline int usb_endpoint_is_isoc_out( 586 + const struct usb_endpoint_descriptor *epd) 587 + { 588 + return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd); 589 + } 590 + 591 + /** 592 + * usb_endpoint_maxp - get endpoint's max packet size 593 + * @epd: endpoint to be checked 594 + * 595 + * Returns @epd's max packet 596 + */ 597 + static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd) 598 + { 599 + return __le16_to_cpu(epd->wMaxPacketSize); 600 + } 601 + 602 + static inline int usb_endpoint_interrupt_type( 603 + const struct usb_endpoint_descriptor *epd) 604 + { 605 + return epd->bmAttributes & USB_ENDPOINT_INTRTYPE; 606 + } 607 + 608 + /*-------------------------------------------------------------------------*/ 609 + 610 + /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */ 611 + struct usb_ss_ep_comp_descriptor { 612 + __u8 bLength; 613 + __u8 bDescriptorType; 614 + 615 + __u8 bMaxBurst; 616 + __u8 bmAttributes; 617 + __le16 wBytesPerInterval; 618 + } __attribute__ ((packed)); 619 + 620 + #define USB_DT_SS_EP_COMP_SIZE 6 621 + 622 + /* Bits 4:0 of bmAttributes if this is a bulk endpoint */ 623 + static inline int 624 + usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp) 625 + { 626 + int max_streams; 627 + 628 + if (!comp) 629 + return 0; 630 + 631 + max_streams = comp->bmAttributes & 0x1f; 632 + 633 + if (!max_streams) 634 + return 0; 635 + 636 + max_streams = 1 << max_streams; 637 + 638 + return max_streams; 639 + } 640 + 641 + /* Bits 1:0 of bmAttributes if this is an isoc endpoint */ 642 + #define USB_SS_MULT(p) (1 + ((p) & 0x3)) 643 + 644 + /*-------------------------------------------------------------------------*/ 645 + 646 + /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ 647 + struct usb_qualifier_descriptor { 648 + __u8 bLength; 649 + __u8 bDescriptorType; 650 + 651 + __le16 bcdUSB; 652 + __u8 bDeviceClass; 653 + __u8 bDeviceSubClass; 654 + __u8 bDeviceProtocol; 655 + __u8 bMaxPacketSize0; 656 + __u8 bNumConfigurations; 657 + __u8 bRESERVED; 658 + } __attribute__ ((packed)); 659 + 660 + 661 + /*-------------------------------------------------------------------------*/ 662 + 663 + /* USB_DT_OTG (from OTG 1.0a supplement) */ 664 + struct usb_otg_descriptor { 665 + __u8 bLength; 666 + __u8 bDescriptorType; 667 + 668 + __u8 bmAttributes; /* support for HNP, SRP, etc */ 669 + } __attribute__ ((packed)); 670 + 671 + /* from usb_otg_descriptor.bmAttributes */ 672 + #define USB_OTG_SRP (1 << 0) 673 + #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ 674 + 675 + /*-------------------------------------------------------------------------*/ 676 + 677 + /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ 678 + struct usb_debug_descriptor { 679 + __u8 bLength; 680 + __u8 bDescriptorType; 681 + 682 + /* bulk endpoints with 8 byte maxpacket */ 683 + __u8 bDebugInEndpoint; 684 + __u8 bDebugOutEndpoint; 685 + } __attribute__((packed)); 686 + 687 + /*-------------------------------------------------------------------------*/ 688 + 689 + /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ 690 + struct usb_interface_assoc_descriptor { 691 + __u8 bLength; 692 + __u8 bDescriptorType; 693 + 694 + __u8 bFirstInterface; 695 + __u8 bInterfaceCount; 696 + __u8 bFunctionClass; 697 + __u8 bFunctionSubClass; 698 + __u8 bFunctionProtocol; 699 + __u8 iFunction; 700 + } __attribute__ ((packed)); 701 + 702 + 703 + /*-------------------------------------------------------------------------*/ 704 + 705 + /* USB_DT_SECURITY: group of wireless security descriptors, including 706 + * encryption types available for setting up a CC/association. 707 + */ 708 + struct usb_security_descriptor { 709 + __u8 bLength; 710 + __u8 bDescriptorType; 711 + 712 + __le16 wTotalLength; 713 + __u8 bNumEncryptionTypes; 714 + } __attribute__((packed)); 715 + 716 + /*-------------------------------------------------------------------------*/ 717 + 718 + /* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys 719 + * may be retrieved. 720 + */ 721 + struct usb_key_descriptor { 722 + __u8 bLength; 723 + __u8 bDescriptorType; 724 + 725 + __u8 tTKID[3]; 726 + __u8 bReserved; 727 + __u8 bKeyData[0]; 728 + } __attribute__((packed)); 729 + 730 + /*-------------------------------------------------------------------------*/ 731 + 732 + /* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */ 733 + struct usb_encryption_descriptor { 734 + __u8 bLength; 735 + __u8 bDescriptorType; 736 + 737 + __u8 bEncryptionType; 738 + #define USB_ENC_TYPE_UNSECURE 0 739 + #define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */ 740 + #define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */ 741 + #define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ 742 + __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ 743 + __u8 bAuthKeyIndex; 744 + } __attribute__((packed)); 745 + 746 + 747 + /*-------------------------------------------------------------------------*/ 748 + 749 + /* USB_DT_BOS: group of device-level capabilities */ 750 + struct usb_bos_descriptor { 751 + __u8 bLength; 752 + __u8 bDescriptorType; 753 + 754 + __le16 wTotalLength; 755 + __u8 bNumDeviceCaps; 756 + } __attribute__((packed)); 757 + 758 + #define USB_DT_BOS_SIZE 5 759 + /*-------------------------------------------------------------------------*/ 760 + 761 + /* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ 762 + struct usb_dev_cap_header { 763 + __u8 bLength; 764 + __u8 bDescriptorType; 765 + __u8 bDevCapabilityType; 766 + } __attribute__((packed)); 767 + 768 + #define USB_CAP_TYPE_WIRELESS_USB 1 769 + 770 + struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ 771 + __u8 bLength; 772 + __u8 bDescriptorType; 773 + __u8 bDevCapabilityType; 774 + 775 + __u8 bmAttributes; 776 + #define USB_WIRELESS_P2P_DRD (1 << 1) 777 + #define USB_WIRELESS_BEACON_MASK (3 << 2) 778 + #define USB_WIRELESS_BEACON_SELF (1 << 2) 779 + #define USB_WIRELESS_BEACON_DIRECTED (2 << 2) 780 + #define USB_WIRELESS_BEACON_NONE (3 << 2) 781 + __le16 wPHYRates; /* bit rates, Mbps */ 782 + #define USB_WIRELESS_PHY_53 (1 << 0) /* always set */ 783 + #define USB_WIRELESS_PHY_80 (1 << 1) 784 + #define USB_WIRELESS_PHY_107 (1 << 2) /* always set */ 785 + #define USB_WIRELESS_PHY_160 (1 << 3) 786 + #define USB_WIRELESS_PHY_200 (1 << 4) /* always set */ 787 + #define USB_WIRELESS_PHY_320 (1 << 5) 788 + #define USB_WIRELESS_PHY_400 (1 << 6) 789 + #define USB_WIRELESS_PHY_480 (1 << 7) 790 + __u8 bmTFITXPowerInfo; /* TFI power levels */ 791 + __u8 bmFFITXPowerInfo; /* FFI power levels */ 792 + __le16 bmBandGroup; 793 + __u8 bReserved; 794 + } __attribute__((packed)); 795 + 796 + /* USB 2.0 Extension descriptor */ 797 + #define USB_CAP_TYPE_EXT 2 798 + 799 + struct usb_ext_cap_descriptor { /* Link Power Management */ 800 + __u8 bLength; 801 + __u8 bDescriptorType; 802 + __u8 bDevCapabilityType; 803 + __le32 bmAttributes; 804 + #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ 805 + #define USB_BESL_SUPPORT (1 << 2) /* supports BESL */ 806 + #define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/ 807 + #define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */ 808 + #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) 809 + #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) 810 + } __attribute__((packed)); 811 + 812 + #define USB_DT_USB_EXT_CAP_SIZE 7 813 + 814 + /* 815 + * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB 816 + * specific device level capabilities 817 + */ 818 + #define USB_SS_CAP_TYPE 3 819 + struct usb_ss_cap_descriptor { /* Link Power Management */ 820 + __u8 bLength; 821 + __u8 bDescriptorType; 822 + __u8 bDevCapabilityType; 823 + __u8 bmAttributes; 824 + #define USB_LTM_SUPPORT (1 << 1) /* supports LTM */ 825 + __le16 wSpeedSupported; 826 + #define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */ 827 + #define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */ 828 + #define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */ 829 + #define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */ 830 + __u8 bFunctionalitySupport; 831 + __u8 bU1devExitLat; 832 + __le16 bU2DevExitLat; 833 + } __attribute__((packed)); 834 + 835 + #define USB_DT_USB_SS_CAP_SIZE 10 836 + 837 + /* 838 + * Container ID Capability descriptor: Defines the instance unique ID used to 839 + * identify the instance across all operating modes 840 + */ 841 + #define CONTAINER_ID_TYPE 4 842 + struct usb_ss_container_id_descriptor { 843 + __u8 bLength; 844 + __u8 bDescriptorType; 845 + __u8 bDevCapabilityType; 846 + __u8 bReserved; 847 + __u8 ContainerID[16]; /* 128-bit number */ 848 + } __attribute__((packed)); 849 + 850 + #define USB_DT_USB_SS_CONTN_ID_SIZE 20 851 + /*-------------------------------------------------------------------------*/ 852 + 853 + /* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with 854 + * each endpoint descriptor for a wireless device 855 + */ 856 + struct usb_wireless_ep_comp_descriptor { 857 + __u8 bLength; 858 + __u8 bDescriptorType; 859 + 860 + __u8 bMaxBurst; 861 + __u8 bMaxSequence; 862 + __le16 wMaxStreamDelay; 863 + __le16 wOverTheAirPacketSize; 864 + __u8 bOverTheAirInterval; 865 + __u8 bmCompAttributes; 866 + #define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */ 867 + #define USB_ENDPOINT_SWITCH_NO 0 868 + #define USB_ENDPOINT_SWITCH_SWITCH 1 869 + #define USB_ENDPOINT_SWITCH_SCALE 2 870 + } __attribute__((packed)); 871 + 872 + /*-------------------------------------------------------------------------*/ 873 + 874 + /* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless 875 + * host and a device for connection set up, mutual authentication, and 876 + * exchanging short lived session keys. The handshake depends on a CC. 877 + */ 878 + struct usb_handshake { 879 + __u8 bMessageNumber; 880 + __u8 bStatus; 881 + __u8 tTKID[3]; 882 + __u8 bReserved; 883 + __u8 CDID[16]; 884 + __u8 nonce[16]; 885 + __u8 MIC[8]; 886 + } __attribute__((packed)); 887 + 888 + /*-------------------------------------------------------------------------*/ 889 + 890 + /* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC). 891 + * A CC may also be set up using non-wireless secure channels (including 892 + * wired USB!), and some devices may support CCs with multiple hosts. 893 + */ 894 + struct usb_connection_context { 895 + __u8 CHID[16]; /* persistent host id */ 896 + __u8 CDID[16]; /* device id (unique w/in host context) */ 897 + __u8 CK[16]; /* connection key */ 898 + } __attribute__((packed)); 899 + 900 + /*-------------------------------------------------------------------------*/ 901 + 902 + /* USB 2.0 defines three speeds, here's how Linux identifies them */ 903 + 904 + enum usb_device_speed { 905 + USB_SPEED_UNKNOWN = 0, /* enumerating */ 906 + USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ 907 + USB_SPEED_HIGH, /* usb 2.0 */ 908 + USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ 909 + USB_SPEED_SUPER, /* usb 3.0 */ 910 + }; 911 + 912 + 913 + enum usb_device_state { 914 + /* NOTATTACHED isn't in the USB spec, and this state acts 915 + * the same as ATTACHED ... but it's clearer this way. 916 + */ 917 + USB_STATE_NOTATTACHED = 0, 918 + 919 + /* chapter 9 and authentication (wireless) device states */ 920 + USB_STATE_ATTACHED, 921 + USB_STATE_POWERED, /* wired */ 922 + USB_STATE_RECONNECTING, /* auth */ 923 + USB_STATE_UNAUTHENTICATED, /* auth */ 924 + USB_STATE_DEFAULT, /* limited function */ 925 + USB_STATE_ADDRESS, 926 + USB_STATE_CONFIGURED, /* most functions */ 927 + 928 + USB_STATE_SUSPENDED 929 + 930 + /* NOTE: there are actually four different SUSPENDED 931 + * states, returning to POWERED, DEFAULT, ADDRESS, or 932 + * CONFIGURED respectively when SOF tokens flow again. 933 + * At this level there's no difference between L1 and L2 934 + * suspend states. (L2 being original USB 1.1 suspend.) 935 + */ 936 + }; 937 + 938 + enum usb3_link_state { 939 + USB3_LPM_U0 = 0, 940 + USB3_LPM_U1, 941 + USB3_LPM_U2, 942 + USB3_LPM_U3 943 + }; 944 + 945 + /* 946 + * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1. 947 + * 0xff means the parent hub will accept transitions to U1, but will not 948 + * initiate a transition. 949 + * 950 + * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to 951 + * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved 952 + * values. 953 + * 954 + * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2. 955 + * 0xff means the parent hub will accept transitions to U2, but will not 956 + * initiate a transition. 957 + * 958 + * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to 959 + * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2 960 + * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means 961 + * 65.024ms. 962 + */ 963 + #define USB3_LPM_DISABLED 0x0 964 + #define USB3_LPM_U1_MAX_TIMEOUT 0x7F 965 + #define USB3_LPM_U2_MAX_TIMEOUT 0xFE 966 + #define USB3_LPM_DEVICE_INITIATED 0xFF 967 + 968 + struct usb_set_sel_req { 969 + __u8 u1_sel; 970 + __u8 u1_pel; 971 + __le16 u2_sel; 972 + __le16 u2_pel; 973 + } __attribute__ ((packed)); 974 + 975 + /* 976 + * The Set System Exit Latency control transfer provides one byte each for 977 + * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each 978 + * are two bytes long. 979 + */ 980 + #define USB3_LPM_MAX_U1_SEL_PEL 0xFF 981 + #define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF 982 + 983 + /*-------------------------------------------------------------------------*/ 984 + 985 + /* 986 + * As per USB compliance update, a device that is actively drawing 987 + * more than 100mA from USB must report itself as bus-powered in 988 + * the GetStatus(DEVICE) call. 989 + * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34 990 + */ 991 + #define USB_SELF_POWER_VBUS_MAX_DRAW 100 992 + 993 + #endif /* _UAPI__LINUX_USB_CH9_H */
+169
include/uapi/linux/usb/functionfs.h
··· 1 + #ifndef _UAPI__LINUX_FUNCTIONFS_H__ 2 + #define _UAPI__LINUX_FUNCTIONFS_H__ 3 + 4 + 5 + #include <linux/types.h> 6 + #include <linux/ioctl.h> 7 + 8 + #include <linux/usb/ch9.h> 9 + 10 + 11 + enum { 12 + FUNCTIONFS_DESCRIPTORS_MAGIC = 1, 13 + FUNCTIONFS_STRINGS_MAGIC = 2 14 + }; 15 + 16 + 17 + #ifndef __KERNEL__ 18 + 19 + /* Descriptor of an non-audio endpoint */ 20 + struct usb_endpoint_descriptor_no_audio { 21 + __u8 bLength; 22 + __u8 bDescriptorType; 23 + 24 + __u8 bEndpointAddress; 25 + __u8 bmAttributes; 26 + __le16 wMaxPacketSize; 27 + __u8 bInterval; 28 + } __attribute__((packed)); 29 + 30 + 31 + /* 32 + * All numbers must be in little endian order. 33 + */ 34 + 35 + struct usb_functionfs_descs_head { 36 + __le32 magic; 37 + __le32 length; 38 + __le32 fs_count; 39 + __le32 hs_count; 40 + } __attribute__((packed)); 41 + 42 + /* 43 + * Descriptors format: 44 + * 45 + * | off | name | type | description | 46 + * |-----+-----------+--------------+--------------------------------------| 47 + * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC | 48 + * | 4 | length | LE32 | length of the whole data chunk | 49 + * | 8 | fs_count | LE32 | number of full-speed descriptors | 50 + * | 12 | hs_count | LE32 | number of high-speed descriptors | 51 + * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors | 52 + * | | hs_descrs | Descriptor[] | list of high-speed descriptors | 53 + * 54 + * descs are just valid USB descriptors and have the following format: 55 + * 56 + * | off | name | type | description | 57 + * |-----+-----------------+------+--------------------------| 58 + * | 0 | bLength | U8 | length of the descriptor | 59 + * | 1 | bDescriptorType | U8 | descriptor type | 60 + * | 2 | payload | | descriptor's payload | 61 + */ 62 + 63 + struct usb_functionfs_strings_head { 64 + __le32 magic; 65 + __le32 length; 66 + __le32 str_count; 67 + __le32 lang_count; 68 + } __attribute__((packed)); 69 + 70 + /* 71 + * Strings format: 72 + * 73 + * | off | name | type | description | 74 + * |-----+------------+-----------------------+----------------------------| 75 + * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC | 76 + * | 4 | length | LE32 | length of the data chunk | 77 + * | 8 | str_count | LE32 | number of strings | 78 + * | 12 | lang_count | LE32 | number of languages | 79 + * | 16 | stringtab | StringTab[lang_count] | table of strings per lang | 80 + * 81 + * For each language there is one stringtab entry (ie. there are lang_count 82 + * stringtab entires). Each StringTab has following format: 83 + * 84 + * | off | name | type | description | 85 + * |-----+---------+-------------------+------------------------------------| 86 + * | 0 | lang | LE16 | language code | 87 + * | 2 | strings | String[str_count] | array of strings in given language | 88 + * 89 + * For each string there is one strings entry (ie. there are str_count 90 + * string entries). Each String is a NUL terminated string encoded in 91 + * UTF-8. 92 + */ 93 + 94 + #endif 95 + 96 + 97 + /* 98 + * Events are delivered on the ep0 file descriptor, when the user mode driver 99 + * reads from this file descriptor after writing the descriptors. Don't 100 + * stop polling this descriptor. 101 + */ 102 + 103 + enum usb_functionfs_event_type { 104 + FUNCTIONFS_BIND, 105 + FUNCTIONFS_UNBIND, 106 + 107 + FUNCTIONFS_ENABLE, 108 + FUNCTIONFS_DISABLE, 109 + 110 + FUNCTIONFS_SETUP, 111 + 112 + FUNCTIONFS_SUSPEND, 113 + FUNCTIONFS_RESUME 114 + }; 115 + 116 + /* NOTE: this structure must stay the same size and layout on 117 + * both 32-bit and 64-bit kernels. 118 + */ 119 + struct usb_functionfs_event { 120 + union { 121 + /* SETUP: packet; DATA phase i/o precedes next event 122 + *(setup.bmRequestType & USB_DIR_IN) flags direction */ 123 + struct usb_ctrlrequest setup; 124 + } __attribute__((packed)) u; 125 + 126 + /* enum usb_functionfs_event_type */ 127 + __u8 type; 128 + __u8 _pad[3]; 129 + } __attribute__((packed)); 130 + 131 + 132 + /* Endpoint ioctls */ 133 + /* The same as in gadgetfs */ 134 + 135 + /* IN transfers may be reported to the gadget driver as complete 136 + * when the fifo is loaded, before the host reads the data; 137 + * OUT transfers may be reported to the host's "client" driver as 138 + * complete when they're sitting in the FIFO unread. 139 + * THIS returns how many bytes are "unclaimed" in the endpoint fifo 140 + * (needed for precise fault handling, when the hardware allows it) 141 + */ 142 + #define FUNCTIONFS_FIFO_STATUS _IO('g', 1) 143 + 144 + /* discards any unclaimed data in the fifo. */ 145 + #define FUNCTIONFS_FIFO_FLUSH _IO('g', 2) 146 + 147 + /* resets endpoint halt+toggle; used to implement set_interface. 148 + * some hardware (like pxa2xx) can't support this. 149 + */ 150 + #define FUNCTIONFS_CLEAR_HALT _IO('g', 3) 151 + 152 + /* Specific for functionfs */ 153 + 154 + /* 155 + * Returns reverse mapping of an interface. Called on EP0. If there 156 + * is no such interface returns -EDOM. If function is not active 157 + * returns -ENODEV. 158 + */ 159 + #define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128) 160 + 161 + /* 162 + * Returns real bEndpointAddress of an endpoint. If function is not 163 + * active returns -ENODEV. 164 + */ 165 + #define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129) 166 + 167 + 168 + 169 + #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */