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

USB: serial: ftdi_sio: rename channel index

Multi-channel devices require a channel selector to be included in
control requests.

Replace "interface" with the less ambiguous "channel", which is the
terminology used for newer devices, in the corresponding defines and
variables.

Signed-off-by: Johan Hovold <johan@kernel.org>

+24 -26
+19 -21
drivers/usb/serial/ftdi_sio.c
··· 72 72 unsigned long last_dtr_rts; /* saved modem control outputs */ 73 73 char prev_status; /* Used for TIOCMIWAIT */ 74 74 char transmit_empty; /* If transmitter is empty or not */ 75 - u16 interface; /* FT2232C, FT2232H or FT4232H port interface 76 - (0 for FT232/245) */ 75 + u16 channel; /* channel index, or 0 for legacy types */ 77 76 78 77 speed_t force_baud; /* if non-zero, force the baud rate to 79 78 this value */ ··· 1270 1271 usb_sndctrlpipe(port->serial->dev, 0), 1271 1272 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 1272 1273 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 1273 - value, priv->interface, 1274 + value, priv->channel, 1274 1275 NULL, 0, WDR_TIMEOUT); 1275 1276 if (rv < 0) { 1276 1277 dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n", ··· 1411 1412 priv->chip_type == FTX) { 1412 1413 /* Probably the BM type needs the MSB of the encoded fractional 1413 1414 * divider also moved like for the chips above. Any infos? */ 1414 - index = (u16)((index << 8) | priv->interface); 1415 + index = (u16)((index << 8) | priv->channel); 1415 1416 } 1416 1417 1417 1418 rv = usb_control_msg(port->serial->dev, ··· 1442 1443 usb_sndctrlpipe(udev, 0), 1443 1444 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1444 1445 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1445 - l, priv->interface, 1446 + l, priv->channel, 1446 1447 NULL, 0, WDR_TIMEOUT); 1447 1448 if (rv < 0) 1448 1449 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); ··· 1458 1459 1459 1460 rv = usb_control_msg_recv(udev, 0, FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1460 1461 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 0, 1461 - priv->interface, &buf, 1, WDR_TIMEOUT, 1462 + priv->channel, &buf, 1, WDR_TIMEOUT, 1462 1463 GFP_KERNEL); 1463 1464 if (rv == 0) 1464 1465 rv = buf; ··· 1579 1580 } else 1580 1581 priv->chip_type = FT2232C; 1581 1582 1582 - /* Determine interface code. */ 1583 1583 if (ifnum == 0) 1584 - priv->interface = INTERFACE_A; 1584 + priv->channel = CHANNEL_A; 1585 1585 else if (ifnum == 1) 1586 - priv->interface = INTERFACE_B; 1586 + priv->channel = CHANNEL_B; 1587 1587 else if (ifnum == 2) 1588 - priv->interface = INTERFACE_C; 1588 + priv->channel = CHANNEL_C; 1589 1589 else if (ifnum == 3) 1590 - priv->interface = INTERFACE_D; 1590 + priv->channel = CHANNEL_D; 1591 1591 1592 1592 /* BM-type devices have a bug where bcdDevice gets set 1593 1593 * to 0x200 when iSerialNumber is 0. */ ··· 1727 1729 usb_sndctrlpipe(udev, 0), 1728 1730 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1729 1731 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1730 - v, priv->interface, 1732 + v, priv->channel, 1731 1733 NULL, 0, WDR_TIMEOUT); 1732 1734 if (rv < 0) { 1733 1735 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); ··· 1801 1803 usb_sndctrlpipe(serial->dev, 0), 1802 1804 FTDI_SIO_SET_BITMODE_REQUEST, 1803 1805 FTDI_SIO_SET_BITMODE_REQUEST_TYPE, val, 1804 - priv->interface, NULL, 0, WDR_TIMEOUT); 1806 + priv->channel, NULL, 0, WDR_TIMEOUT); 1805 1807 if (result < 0) { 1806 1808 dev_err(&serial->interface->dev, 1807 1809 "bitmode request failed for value 0x%04x: %d\n", ··· 1865 1867 result = usb_control_msg_recv(serial->dev, 0, 1866 1868 FTDI_SIO_READ_PINS_REQUEST, 1867 1869 FTDI_SIO_READ_PINS_REQUEST_TYPE, 0, 1868 - priv->interface, &buf, 1, WDR_TIMEOUT, 1870 + priv->channel, &buf, 1, WDR_TIMEOUT, 1869 1871 GFP_KERNEL); 1870 1872 if (result == 0) 1871 1873 result = buf; ··· 2401 2403 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2402 2404 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 2403 2405 FTDI_SIO_RESET_SIO, 2404 - priv->interface, NULL, 0, WDR_TIMEOUT); 2406 + priv->channel, NULL, 0, WDR_TIMEOUT); 2405 2407 2406 2408 /* Termios defaults are set by usb_serial_init. We don't change 2407 2409 port->tty->termios - this would lose speed settings, etc. ··· 2424 2426 usb_sndctrlpipe(port->serial->dev, 0), 2425 2427 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2426 2428 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2427 - 0, priv->interface, NULL, 0, 2429 + 0, priv->channel, NULL, 0, 2428 2430 WDR_TIMEOUT) < 0) { 2429 2431 dev_err(&port->dev, "error from flowcontrol urb\n"); 2430 2432 } ··· 2617 2619 usb_sndctrlpipe(port->serial->dev, 0), 2618 2620 FTDI_SIO_SET_DATA_REQUEST, 2619 2621 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2620 - value , priv->interface, 2622 + value, priv->channel, 2621 2623 NULL, 0, WDR_TIMEOUT) < 0) { 2622 2624 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", 2623 2625 __func__, break_state); ··· 2753 2755 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2754 2756 FTDI_SIO_SET_DATA_REQUEST, 2755 2757 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2756 - value , priv->interface, 2758 + value, priv->channel, 2757 2759 NULL, 0, WDR_SHORT_TIMEOUT) < 0) { 2758 2760 dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n", 2759 2761 __func__); ··· 2766 2768 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2767 2769 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2768 2770 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2769 - 0, priv->interface, 2771 + 0, priv->channel, 2770 2772 NULL, 0, WDR_TIMEOUT) < 0) { 2771 2773 dev_err(ddev, "%s error from disable flowcontrol urb\n", 2772 2774 __func__); ··· 2800 2802 index = FTDI_SIO_DISABLE_FLOW_CTRL; 2801 2803 } 2802 2804 2803 - index |= priv->interface; 2805 + index |= priv->channel; 2804 2806 2805 2807 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 2806 2808 FTDI_SIO_SET_FLOW_CTRL_REQUEST, ··· 2854 2856 usb_rcvctrlpipe(port->serial->dev, 0), 2855 2857 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2856 2858 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2857 - 0, priv->interface, 2859 + 0, priv->channel, 2858 2860 buf, len, WDR_TIMEOUT); 2859 2861 2860 2862 /* NOTE: We allow short responses and handle that below. */
+5 -5
drivers/usb/serial/ftdi_sio.h
··· 40 40 #define FTDI_SIO_READ_PINS 0x0c /* Read immediate value of pins */ 41 41 #define FTDI_SIO_READ_EEPROM 0x90 /* Read EEPROM */ 42 42 43 - /* Interface indices for FT2232, FT2232H and FT4232H devices */ 44 - #define INTERFACE_A 1 45 - #define INTERFACE_B 2 46 - #define INTERFACE_C 3 47 - #define INTERFACE_D 4 43 + /* Channel indices for FT2232, FT2232H and FT4232H devices */ 44 + #define CHANNEL_A 1 45 + #define CHANNEL_B 2 46 + #define CHANNEL_C 3 47 + #define CHANNEL_D 4 48 48 49 49 50 50 /*