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

Merge tag 'usb-serial-5.9-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for 5.9-rc1

Here are the USB-serial updates for 5.9-rc1, including:

- console flow-control support
- simulated line-breaks on some ch341
- hardware flow-control fixes for cp210x
- break-detection and sysrq fixes for ftdi_sio
- sysrq optimisations
- input parity checking for cp210x

Included are also some new device ids and various clean ups.

All have been in linux-next with no reported issues.

* tag 'usb-serial-5.9-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial: (31 commits)
USB: serial: qcserial: add EM7305 QDL product ID
USB: serial: iuu_phoenix: fix led-activity helpers
USB: serial: sierra: clean up special-interface handling
USB: serial: cp210x: use in-kernel types in port data
USB: serial: cp210x: drop unnecessary packed attributes
USB: serial: cp210x: add support for TIOCGICOUNT
USB: serial: cp210x: add support for line-status events
USB: serial: cp210x: disable interface on errors in open
USB: serial: drop redundant transfer-buffer casts
USB: serial: drop extern keyword from function declarations
USB: serial: drop unnecessary sysrq include
USB: serial: add sysrq break-handler dummy
USB: serial: inline sysrq dummy function
USB: serial: only process sysrq when enabled
USB: serial: only set sysrq timestamp for consoles
USB: serial: ftdi_sio: fix break and sysrq handling
USB: serial: ftdi_sio: clean up receive processing
USB: serial: ftdi_sio: make process-packet buffer unsigned
USB: serial: use fallthrough pseudo-keyword
USB: serial: ch341: fix missing simulated-break margin
...

+508 -192
+1 -1
drivers/usb/serial/aircable.c
··· 117 117 static void aircable_process_read_urb(struct urb *urb) 118 118 { 119 119 struct usb_serial_port *port = urb->context; 120 - char *data = (char *)urb->transfer_buffer; 120 + char *data = urb->transfer_buffer; 121 121 int has_headers; 122 122 int count; 123 123 int len;
+115 -12
drivers/usb/serial/ch341.c
··· 59 59 #define CH341_REQ_MODEM_CTRL 0xA4 60 60 61 61 #define CH341_REG_BREAK 0x05 62 + #define CH341_REG_PRESCALER 0x12 63 + #define CH341_REG_DIVISOR 0x13 62 64 #define CH341_REG_LCR 0x18 65 + #define CH341_REG_LCR2 0x25 66 + 63 67 #define CH341_NBREAK_BITS 0x01 64 68 65 69 #define CH341_LCR_ENABLE_RX 0x80 ··· 78 74 #define CH341_LCR_CS5 0x00 79 75 80 76 #define CH341_QUIRK_LIMITED_PRESCALER BIT(0) 77 + #define CH341_QUIRK_SIMULATE_BREAK BIT(1) 81 78 82 79 static const struct usb_device_id id_table[] = { 83 80 { USB_DEVICE(0x4348, 0x5523) }, ··· 96 91 u8 msr; 97 92 u8 lcr; 98 93 unsigned long quirks; 94 + unsigned long break_end; 99 95 }; 100 96 101 97 static void ch341_set_termios(struct tty_struct *tty, ··· 159 153 CH341_MIN_RATE(3), 160 154 }; 161 155 156 + /* Supported range is 46 to 3000000 bps. */ 157 + #define CH341_MIN_BPS DIV_ROUND_UP(CH341_CLKRATE, CH341_CLK_DIV(0, 0) * 256) 158 + #define CH341_MAX_BPS (CH341_CLKRATE / (CH341_CLK_DIV(3, 0) * 2)) 159 + 162 160 /* 163 161 * The device line speed is given by the following equation: 164 162 * ··· 173 163 * 2 <= div <= 256 if fact = 0, or 174 164 * 9 <= div <= 256 if fact = 1 175 165 */ 176 - static int ch341_get_divisor(struct ch341_private *priv) 166 + static int ch341_get_divisor(struct ch341_private *priv, speed_t speed) 177 167 { 178 168 unsigned int fact, div, clk_div; 179 - speed_t speed = priv->baud_rate; 180 169 bool force_fact0 = false; 181 170 int ps; 182 171 ··· 183 174 * Clamp to supported range, this makes the (ps < 0) and (div < 2) 184 175 * sanity checks below redundant. 185 176 */ 186 - speed = clamp(speed, 46U, 3000000U); 177 + speed = clamp_val(speed, CH341_MIN_BPS, CH341_MAX_BPS); 187 178 188 179 /* 189 180 * Start with highest possible base clock (fact = 1) that will give a ··· 238 229 } 239 230 240 231 static int ch341_set_baudrate_lcr(struct usb_device *dev, 241 - struct ch341_private *priv, u8 lcr) 232 + struct ch341_private *priv, 233 + speed_t baud_rate, u8 lcr) 242 234 { 243 235 int val; 244 236 int r; 245 237 246 - if (!priv->baud_rate) 238 + if (!baud_rate) 247 239 return -EINVAL; 248 240 249 - val = ch341_get_divisor(priv); 241 + val = ch341_get_divisor(priv, baud_rate); 250 242 if (val < 0) 251 243 return -EINVAL; 252 244 ··· 257 247 */ 258 248 val |= BIT(7); 259 249 260 - r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, val); 250 + r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 251 + CH341_REG_DIVISOR << 8 | CH341_REG_PRESCALER, 252 + val); 261 253 if (r) 262 254 return r; 263 255 264 - r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr); 256 + /* 257 + * Chip versions before version 0x30 as read using 258 + * CH341_REQ_READ_VERSION used separate registers for line control 259 + * (stop bits, parity and word length). Version 0x30 and above use 260 + * CH341_REG_LCR only and CH341_REG_LCR2 is always set to zero. 261 + */ 262 + r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 263 + CH341_REG_LCR2 << 8 | CH341_REG_LCR, lcr); 265 264 if (r) 266 265 return r; 267 266 ··· 327 308 if (r < 0) 328 309 goto out; 329 310 330 - r = ch341_set_baudrate_lcr(dev, priv, priv->lcr); 311 + r = ch341_set_baudrate_lcr(dev, priv, priv->baud_rate, priv->lcr); 331 312 if (r < 0) 332 313 goto out; 333 314 ··· 360 341 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 361 342 CH341_REG_BREAK, 0, buffer, size, DEFAULT_TIMEOUT); 362 343 if (r == -EPIPE) { 363 - dev_dbg(&port->dev, "break control not supported\n"); 364 - quirks = CH341_QUIRK_LIMITED_PRESCALER; 344 + dev_info(&port->dev, "break control not supported, using simulated break\n"); 345 + quirks = CH341_QUIRK_LIMITED_PRESCALER | CH341_QUIRK_SIMULATE_BREAK; 365 346 r = 0; 366 347 goto out; 367 348 } ··· 542 523 if (baud_rate) { 543 524 priv->baud_rate = baud_rate; 544 525 545 - r = ch341_set_baudrate_lcr(port->serial->dev, priv, lcr); 526 + r = ch341_set_baudrate_lcr(port->serial->dev, priv, 527 + priv->baud_rate, lcr); 546 528 if (r < 0 && old_termios) { 547 529 priv->baud_rate = tty_termios_baud_rate(old_termios); 548 530 tty_termios_copy_hw(&tty->termios, old_termios); ··· 562 542 ch341_set_handshake(port->serial->dev, priv->mcr); 563 543 } 564 544 545 + /* 546 + * A subset of all CH34x devices don't support a real break condition and 547 + * reading CH341_REG_BREAK fails (see also ch341_detect_quirks). This function 548 + * simulates a break condition by lowering the baud rate to the minimum 549 + * supported by the hardware upon enabling the break condition and sending 550 + * a NUL byte. 551 + * 552 + * Incoming data is corrupted while the break condition is being simulated. 553 + * 554 + * Normally the duration of the break condition can be controlled individually 555 + * by userspace using TIOCSBRK and TIOCCBRK or by passing an argument to 556 + * TCSBRKP. Due to how the simulation is implemented the duration can't be 557 + * controlled. The duration is always about (1s / 46bd * 9bit) = 196ms. 558 + */ 559 + static void ch341_simulate_break(struct tty_struct *tty, int break_state) 560 + { 561 + struct usb_serial_port *port = tty->driver_data; 562 + struct ch341_private *priv = usb_get_serial_port_data(port); 563 + unsigned long now, delay; 564 + int r; 565 + 566 + if (break_state != 0) { 567 + dev_dbg(&port->dev, "enter break state requested\n"); 568 + 569 + r = ch341_set_baudrate_lcr(port->serial->dev, priv, 570 + CH341_MIN_BPS, 571 + CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX | CH341_LCR_CS8); 572 + if (r < 0) { 573 + dev_err(&port->dev, 574 + "failed to change baud rate to %u: %d\n", 575 + CH341_MIN_BPS, r); 576 + goto restore; 577 + } 578 + 579 + r = tty_put_char(tty, '\0'); 580 + if (r < 0) { 581 + dev_err(&port->dev, 582 + "failed to write NUL byte for simulated break condition: %d\n", 583 + r); 584 + goto restore; 585 + } 586 + 587 + /* 588 + * Compute expected transmission duration including safety 589 + * margin. The original baud rate is only restored after the 590 + * computed point in time. 591 + * 592 + * 11 bits = 1 start, 8 data, 1 stop, 1 margin 593 + */ 594 + priv->break_end = jiffies + (11 * HZ / CH341_MIN_BPS); 595 + 596 + return; 597 + } 598 + 599 + dev_dbg(&port->dev, "leave break state requested\n"); 600 + 601 + now = jiffies; 602 + 603 + if (time_before(now, priv->break_end)) { 604 + /* Wait until NUL byte is written */ 605 + delay = priv->break_end - now; 606 + dev_dbg(&port->dev, 607 + "wait %d ms while transmitting NUL byte at %u baud\n", 608 + jiffies_to_msecs(delay), CH341_MIN_BPS); 609 + schedule_timeout_interruptible(delay); 610 + } 611 + 612 + restore: 613 + /* Restore original baud rate */ 614 + r = ch341_set_baudrate_lcr(port->serial->dev, priv, priv->baud_rate, 615 + priv->lcr); 616 + if (r < 0) 617 + dev_err(&port->dev, 618 + "restoring original baud rate of %u failed: %d\n", 619 + priv->baud_rate, r); 620 + } 621 + 565 622 static void ch341_break_ctl(struct tty_struct *tty, int break_state) 566 623 { 567 624 const uint16_t ch341_break_reg = 568 625 ((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK; 569 626 struct usb_serial_port *port = tty->driver_data; 627 + struct ch341_private *priv = usb_get_serial_port_data(port); 570 628 int r; 571 629 uint16_t reg_contents; 572 630 uint8_t *break_reg; 631 + 632 + if (priv->quirks & CH341_QUIRK_SIMULATE_BREAK) { 633 + ch341_simulate_break(tty, break_state); 634 + return; 635 + } 573 636 574 637 break_reg = kmalloc(2, GFP_KERNEL); 575 638 if (!break_reg)
+4 -1
drivers/usb/serial/console.c
··· 79 79 if (*s) 80 80 doflow = (*s++ == 'r'); 81 81 } 82 - 82 + 83 83 /* Sane default */ 84 84 if (baud == 0) 85 85 baud = 9600; ··· 101 101 cflag |= PARENB; 102 102 break; 103 103 } 104 + 105 + if (doflow) 106 + cflag |= CRTSCTS; 104 107 105 108 /* 106 109 * no need to check the index here: if the index is wrong, console
+220 -8
drivers/usb/serial/cp210x.c
··· 50 50 static int cp210x_port_probe(struct usb_serial_port *); 51 51 static int cp210x_port_remove(struct usb_serial_port *); 52 52 static void cp210x_dtr_rts(struct usb_serial_port *p, int on); 53 + static void cp210x_process_read_urb(struct urb *urb); 54 + static void cp210x_enable_event_mode(struct usb_serial_port *port); 55 + static void cp210x_disable_event_mode(struct usb_serial_port *port); 53 56 54 57 static const struct usb_device_id id_table[] = { 55 58 { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ ··· 256 253 bool use_actual_rate; 257 254 }; 258 255 256 + enum cp210x_event_state { 257 + ES_DATA, 258 + ES_ESCAPE, 259 + ES_LSR, 260 + ES_LSR_DATA_0, 261 + ES_LSR_DATA_1, 262 + ES_MSR 263 + }; 264 + 259 265 struct cp210x_port_private { 260 - __u8 bInterfaceNumber; 266 + u8 bInterfaceNumber; 261 267 bool has_swapped_line_ctl; 268 + bool event_mode; 269 + enum cp210x_event_state event_state; 270 + u8 lsr; 262 271 }; 263 272 264 273 static struct usb_serial_driver cp210x_device = { ··· 287 272 .break_ctl = cp210x_break_ctl, 288 273 .set_termios = cp210x_set_termios, 289 274 .tx_empty = cp210x_tx_empty, 275 + .throttle = usb_serial_generic_throttle, 276 + .unthrottle = usb_serial_generic_unthrottle, 290 277 .tiocmget = cp210x_tiocmget, 291 278 .tiocmset = cp210x_tiocmset, 279 + .get_icount = usb_serial_generic_get_icount, 292 280 .attach = cp210x_attach, 293 281 .disconnect = cp210x_disconnect, 294 282 .release = cp210x_release, 295 283 .port_probe = cp210x_port_probe, 296 284 .port_remove = cp210x_port_remove, 297 - .dtr_rts = cp210x_dtr_rts 285 + .dtr_rts = cp210x_dtr_rts, 286 + .process_read_urb = cp210x_process_read_urb, 298 287 }; 299 288 300 289 static struct usb_serial_driver * const serial_drivers[] = { ··· 420 401 */ 421 402 #define PURGE_ALL 0x000f 422 403 404 + /* CP210X_EMBED_EVENTS */ 405 + #define CP210X_ESCCHAR 0xec 406 + 407 + #define CP210X_LSR_OVERRUN BIT(1) 408 + #define CP210X_LSR_PARITY BIT(2) 409 + #define CP210X_LSR_FRAME BIT(3) 410 + #define CP210X_LSR_BREAK BIT(4) 411 + 412 + 423 413 /* CP210X_GET_FLOW/CP210X_SET_FLOW read/write these 0x10 bytes */ 424 414 struct cp210x_flow_ctl { 425 415 __le32 ulControlHandshake; 426 416 __le32 ulFlowReplace; 427 417 __le32 ulXonLimit; 428 418 __le32 ulXoffLimit; 429 - } __packed; 419 + }; 430 420 431 421 /* cp210x_flow_ctl::ulControlHandshake */ 432 422 #define CP210X_SERIAL_DTR_MASK GENMASK(1, 0) ··· 469 441 struct cp210x_pin_mode { 470 442 u8 eci; 471 443 u8 sci; 472 - } __packed; 444 + }; 473 445 474 446 #define CP210X_PIN_MODE_MODEM 0 475 447 #define CP210X_PIN_MODE_GPIO BIT(0) ··· 532 504 struct cp210x_gpio_write { 533 505 u8 mask; 534 506 u8 state; 535 - } __packed; 507 + }; 536 508 537 509 /* 538 510 * Helper to get interface number when we only have struct usb_serial. ··· 835 807 836 808 static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port) 837 809 { 810 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 838 811 int result; 839 812 840 813 result = cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_ENABLE); ··· 847 818 /* Configure the termios structure */ 848 819 cp210x_get_termios(tty, port); 849 820 850 - /* The baud rate must be initialised on cp2104 */ 851 - if (tty) 821 + if (tty) { 822 + /* The baud rate must be initialised on cp2104 */ 852 823 cp210x_change_speed(tty, port, NULL); 853 824 854 - return usb_serial_generic_open(tty, port); 825 + if (I_INPCK(tty)) 826 + cp210x_enable_event_mode(port); 827 + } 828 + 829 + result = usb_serial_generic_open(tty, port); 830 + if (result) 831 + goto err_disable; 832 + 833 + return 0; 834 + 835 + err_disable: 836 + cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE); 837 + port_priv->event_mode = false; 838 + 839 + return result; 855 840 } 856 841 857 842 static void cp210x_close(struct usb_serial_port *port) 858 843 { 844 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 845 + 859 846 usb_serial_generic_close(port); 860 847 861 848 /* Clear both queues; cp2108 needs this to avoid an occasional hang */ 862 849 cp210x_write_u16_reg(port, CP210X_PURGE, PURGE_ALL); 863 850 864 851 cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE); 852 + 853 + /* Disabling the interface disables event-insertion mode. */ 854 + port_priv->event_mode = false; 855 + } 856 + 857 + static void cp210x_process_lsr(struct usb_serial_port *port, unsigned char lsr, char *flag) 858 + { 859 + if (lsr & CP210X_LSR_BREAK) { 860 + port->icount.brk++; 861 + *flag = TTY_BREAK; 862 + } else if (lsr & CP210X_LSR_PARITY) { 863 + port->icount.parity++; 864 + *flag = TTY_PARITY; 865 + } else if (lsr & CP210X_LSR_FRAME) { 866 + port->icount.frame++; 867 + *flag = TTY_FRAME; 868 + } 869 + 870 + if (lsr & CP210X_LSR_OVERRUN) { 871 + port->icount.overrun++; 872 + tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 873 + } 874 + } 875 + 876 + static bool cp210x_process_char(struct usb_serial_port *port, unsigned char *ch, char *flag) 877 + { 878 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 879 + 880 + switch (port_priv->event_state) { 881 + case ES_DATA: 882 + if (*ch == CP210X_ESCCHAR) { 883 + port_priv->event_state = ES_ESCAPE; 884 + break; 885 + } 886 + return false; 887 + case ES_ESCAPE: 888 + switch (*ch) { 889 + case 0: 890 + dev_dbg(&port->dev, "%s - escape char\n", __func__); 891 + *ch = CP210X_ESCCHAR; 892 + port_priv->event_state = ES_DATA; 893 + return false; 894 + case 1: 895 + port_priv->event_state = ES_LSR_DATA_0; 896 + break; 897 + case 2: 898 + port_priv->event_state = ES_LSR; 899 + break; 900 + case 3: 901 + port_priv->event_state = ES_MSR; 902 + break; 903 + default: 904 + dev_err(&port->dev, "malformed event 0x%02x\n", *ch); 905 + port_priv->event_state = ES_DATA; 906 + break; 907 + } 908 + break; 909 + case ES_LSR_DATA_0: 910 + port_priv->lsr = *ch; 911 + port_priv->event_state = ES_LSR_DATA_1; 912 + break; 913 + case ES_LSR_DATA_1: 914 + dev_dbg(&port->dev, "%s - lsr = 0x%02x, data = 0x%02x\n", 915 + __func__, port_priv->lsr, *ch); 916 + cp210x_process_lsr(port, port_priv->lsr, flag); 917 + port_priv->event_state = ES_DATA; 918 + return false; 919 + case ES_LSR: 920 + dev_dbg(&port->dev, "%s - lsr = 0x%02x\n", __func__, *ch); 921 + port_priv->lsr = *ch; 922 + cp210x_process_lsr(port, port_priv->lsr, flag); 923 + port_priv->event_state = ES_DATA; 924 + break; 925 + case ES_MSR: 926 + dev_dbg(&port->dev, "%s - msr = 0x%02x\n", __func__, *ch); 927 + /* unimplemented */ 928 + port_priv->event_state = ES_DATA; 929 + break; 930 + } 931 + 932 + return true; 933 + } 934 + 935 + static void cp210x_process_read_urb(struct urb *urb) 936 + { 937 + struct usb_serial_port *port = urb->context; 938 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 939 + unsigned char *ch = urb->transfer_buffer; 940 + char flag; 941 + int i; 942 + 943 + if (!urb->actual_length) 944 + return; 945 + 946 + if (port_priv->event_mode) { 947 + for (i = 0; i < urb->actual_length; i++, ch++) { 948 + flag = TTY_NORMAL; 949 + 950 + if (cp210x_process_char(port, ch, &flag)) 951 + continue; 952 + 953 + tty_insert_flip_char(&port->port, *ch, flag); 954 + } 955 + } else { 956 + tty_insert_flip_string(&port->port, ch, urb->actual_length); 957 + } 958 + tty_flip_buffer_push(&port->port); 865 959 } 866 960 867 961 /* ··· 1067 915 u32 baud; 1068 916 u16 bits; 1069 917 u32 ctl_hs; 918 + u32 flow_repl; 1070 919 1071 920 cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud); 1072 921 ··· 1168 1015 ctl_hs = le32_to_cpu(flow_ctl.ulControlHandshake); 1169 1016 if (ctl_hs & CP210X_SERIAL_CTS_HANDSHAKE) { 1170 1017 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); 1018 + /* 1019 + * When the port is closed, the CP210x hardware disables 1020 + * auto-RTS and RTS is deasserted but it leaves auto-CTS when 1021 + * in hardware flow control mode. When re-opening the port, if 1022 + * auto-CTS is enabled on the cp210x, then auto-RTS must be 1023 + * re-enabled in the driver. 1024 + */ 1025 + flow_repl = le32_to_cpu(flow_ctl.ulFlowReplace); 1026 + flow_repl &= ~CP210X_SERIAL_RTS_MASK; 1027 + flow_repl |= CP210X_SERIAL_RTS_SHIFT(CP210X_SERIAL_RTS_FLOW_CTL); 1028 + flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl); 1029 + cp210x_write_reg_block(port, 1030 + CP210X_SET_FLOW, 1031 + &flow_ctl, 1032 + sizeof(flow_ctl)); 1033 + 1171 1034 cflag |= CRTSCTS; 1172 1035 } else { 1173 1036 dev_dbg(dev, "%s - flow control = NONE\n", __func__); ··· 1317 1148 tty_encode_baud_rate(tty, baud, baud); 1318 1149 } 1319 1150 1151 + static void cp210x_enable_event_mode(struct usb_serial_port *port) 1152 + { 1153 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 1154 + int ret; 1155 + 1156 + if (port_priv->event_mode) 1157 + return; 1158 + 1159 + port_priv->event_state = ES_DATA; 1160 + port_priv->event_mode = true; 1161 + 1162 + ret = cp210x_write_u16_reg(port, CP210X_EMBED_EVENTS, CP210X_ESCCHAR); 1163 + if (ret) { 1164 + dev_err(&port->dev, "failed to enable events: %d\n", ret); 1165 + port_priv->event_mode = false; 1166 + } 1167 + } 1168 + 1169 + static void cp210x_disable_event_mode(struct usb_serial_port *port) 1170 + { 1171 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 1172 + int ret; 1173 + 1174 + if (!port_priv->event_mode) 1175 + return; 1176 + 1177 + ret = cp210x_write_u16_reg(port, CP210X_EMBED_EVENTS, 0); 1178 + if (ret) { 1179 + dev_err(&port->dev, "failed to disable events: %d\n", ret); 1180 + return; 1181 + } 1182 + 1183 + port_priv->event_mode = false; 1184 + } 1185 + 1320 1186 static void cp210x_set_termios(struct tty_struct *tty, 1321 1187 struct usb_serial_port *port, struct ktermios *old_termios) 1322 1188 { ··· 1474 1270 sizeof(flow_ctl)); 1475 1271 } 1476 1272 1273 + /* 1274 + * Enable event-insertion mode only if input parity checking is 1275 + * enabled for now. 1276 + */ 1277 + if (I_INPCK(tty)) 1278 + cp210x_enable_event_mode(port); 1279 + else 1280 + cp210x_disable_event_mode(port); 1477 1281 } 1478 1282 1479 1283 static int cp210x_tiocmset(struct tty_struct *tty,
+2 -2
drivers/usb/serial/cypress_m8.c
··· 1048 1048 return; 1049 1049 case -EPIPE: 1050 1050 /* Can't call usb_clear_halt while in_interrupt */ 1051 - /* FALLS THROUGH */ 1051 + fallthrough; 1052 1052 default: 1053 1053 /* something ugly is going on... */ 1054 1054 dev_err(dev, "%s - unexpected nonzero read status received: %d\n", ··· 1197 1197 return; 1198 1198 case -EPIPE: 1199 1199 /* Cannot call usb_clear_halt while in_interrupt */ 1200 - /* FALLTHROUGH */ 1200 + fallthrough; 1201 1201 default: 1202 1202 dev_err(dev, "%s - unexpected nonzero write status received: %d\n", 1203 1203 __func__, status);
+2 -2
drivers/usb/serial/f81232.c
··· 424 424 lsr = data[i]; 425 425 tty_flag = f81232_handle_lsr(port, lsr); 426 426 427 - if (port->port.console && port->sysrq) { 427 + if (port->sysrq) { 428 428 if (usb_serial_handle_sysrq_char(port, data[i + 1])) 429 429 continue; 430 430 } ··· 461 461 lsr = data[len - 1]; 462 462 tty_flag = f81232_handle_lsr(port, lsr); 463 463 464 - if (port->port.console && port->sysrq) { 464 + if (port->sysrq) { 465 465 for (i = 1; i < len - 1; ++i) { 466 466 if (!usb_serial_handle_sysrq_char(port, data[i])) { 467 467 tty_insert_flip_char(&port->port, data[i],
+1 -1
drivers/usb/serial/f81534.c
··· 1238 1238 schedule_work(&port_priv->lsr_work); 1239 1239 } 1240 1240 1241 - if (port->port.console && port->sysrq) { 1241 + if (port->sysrq) { 1242 1242 if (usb_serial_handle_sysrq_char(port, data[i])) 1243 1243 continue; 1244 1244 }
+34 -25
drivers/usb/serial/ftdi_sio.c
··· 2480 2480 #define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE) 2481 2481 2482 2482 static int ftdi_process_packet(struct usb_serial_port *port, 2483 - struct ftdi_private *priv, char *packet, int len) 2483 + struct ftdi_private *priv, unsigned char *buf, int len) 2484 2484 { 2485 + unsigned char status; 2486 + bool brkint = false; 2485 2487 int i; 2486 - char status; 2487 2488 char flag; 2488 - char *ch; 2489 2489 2490 2490 if (len < 2) { 2491 2491 dev_dbg(&port->dev, "malformed packet\n"); ··· 2495 2495 /* Compare new line status to the old one, signal if different/ 2496 2496 N.B. packet may be processed more than once, but differences 2497 2497 are only processed once. */ 2498 - status = packet[0] & FTDI_STATUS_B0_MASK; 2498 + status = buf[0] & FTDI_STATUS_B0_MASK; 2499 2499 if (status != priv->prev_status) { 2500 2500 char diff_status = status ^ priv->prev_status; 2501 2501 ··· 2521 2521 } 2522 2522 2523 2523 /* save if the transmitter is empty or not */ 2524 - if (packet[1] & FTDI_RS_TEMT) 2524 + if (buf[1] & FTDI_RS_TEMT) 2525 2525 priv->transmit_empty = 1; 2526 2526 else 2527 2527 priv->transmit_empty = 0; 2528 2528 2529 - len -= 2; 2530 - if (!len) 2529 + if (len == 2) 2531 2530 return 0; /* status only */ 2532 2531 2533 2532 /* ··· 2534 2535 * data payload to avoid over-reporting. 2535 2536 */ 2536 2537 flag = TTY_NORMAL; 2537 - if (packet[1] & FTDI_RS_ERR_MASK) { 2538 - /* Break takes precedence over parity, which takes precedence 2539 - * over framing errors */ 2540 - if (packet[1] & FTDI_RS_BI) { 2541 - flag = TTY_BREAK; 2538 + if (buf[1] & FTDI_RS_ERR_MASK) { 2539 + /* 2540 + * Break takes precedence over parity, which takes precedence 2541 + * over framing errors. Note that break is only associated 2542 + * with the last character in the buffer and only when it's a 2543 + * NUL. 2544 + */ 2545 + if (buf[1] & FTDI_RS_BI && buf[len - 1] == '\0') { 2542 2546 port->icount.brk++; 2543 - usb_serial_handle_break(port); 2544 - } else if (packet[1] & FTDI_RS_PE) { 2547 + brkint = true; 2548 + } 2549 + if (buf[1] & FTDI_RS_PE) { 2545 2550 flag = TTY_PARITY; 2546 2551 port->icount.parity++; 2547 - } else if (packet[1] & FTDI_RS_FE) { 2552 + } else if (buf[1] & FTDI_RS_FE) { 2548 2553 flag = TTY_FRAME; 2549 2554 port->icount.frame++; 2550 2555 } 2551 2556 /* Overrun is special, not associated with a char */ 2552 - if (packet[1] & FTDI_RS_OE) { 2557 + if (buf[1] & FTDI_RS_OE) { 2553 2558 port->icount.overrun++; 2554 2559 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 2555 2560 } 2556 2561 } 2557 2562 2558 - port->icount.rx += len; 2559 - ch = packet + 2; 2563 + port->icount.rx += len - 2; 2560 2564 2561 - if (port->port.console && port->sysrq) { 2562 - for (i = 0; i < len; i++, ch++) { 2563 - if (!usb_serial_handle_sysrq_char(port, *ch)) 2564 - tty_insert_flip_char(&port->port, *ch, flag); 2565 + if (brkint || port->sysrq) { 2566 + for (i = 2; i < len; i++) { 2567 + if (brkint && i == len - 1) { 2568 + if (usb_serial_handle_break(port)) 2569 + return len - 3; 2570 + flag = TTY_BREAK; 2571 + } 2572 + if (usb_serial_handle_sysrq_char(port, buf[i])) 2573 + continue; 2574 + tty_insert_flip_char(&port->port, buf[i], flag); 2565 2575 } 2566 2576 } else { 2567 - tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); 2577 + tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, 2578 + len - 2); 2568 2579 } 2569 2580 2570 - return len; 2581 + return len - 2; 2571 2582 } 2572 2583 2573 2584 static void ftdi_process_read_urb(struct urb *urb) 2574 2585 { 2575 2586 struct usb_serial_port *port = urb->context; 2576 2587 struct ftdi_private *priv = usb_get_serial_port_data(port); 2577 - char *data = (char *)urb->transfer_buffer; 2588 + char *data = urb->transfer_buffer; 2578 2589 int i; 2579 2590 int len; 2580 2591 int count = 0;
+8 -5
drivers/usb/serial/garmin_gps.c
··· 179 179 = { 0, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0 }; 180 180 static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[] 181 181 = { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0 }; 182 + static unsigned char const GARMIN_STOP_TRANSFER_REQ[] 183 + = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 0, 0 }; 184 + static unsigned char const GARMIN_STOP_TRANSFER_REQ_V2[] 185 + = { 20, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0 }; 186 + 187 + /* packets currently unused, left as documentation */ 188 + #if 0 182 189 static unsigned char const GARMIN_APP_LAYER_REPLY[] 183 190 = { 0x14, 0, 0, 0 }; 184 191 static unsigned char const GARMIN_START_PVT_REQ[] 185 192 = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 49, 0 }; 186 193 static unsigned char const GARMIN_STOP_PVT_REQ[] 187 194 = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 50, 0 }; 188 - static unsigned char const GARMIN_STOP_TRANSFER_REQ[] 189 - = { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 0, 0 }; 190 - static unsigned char const GARMIN_STOP_TRANSFER_REQ_V2[] 191 - = { 20, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0 }; 192 195 static unsigned char const PRIVATE_REQ[] 193 196 = { 0x4B, 0x6E, 0x10, 0x01, 0xFF, 0, 0, 0, 0xFF, 0, 0, 0 }; 194 - 197 + #endif 195 198 196 199 197 200 static const struct usb_device_id id_table[] = {
+10 -12
drivers/usb/serial/generic.c
··· 345 345 void usb_serial_generic_process_read_urb(struct urb *urb) 346 346 { 347 347 struct usb_serial_port *port = urb->context; 348 - char *ch = (char *)urb->transfer_buffer; 348 + char *ch = urb->transfer_buffer; 349 349 int i; 350 350 351 351 if (!urb->actual_length) ··· 355 355 * stuff like 3G modems, so shortcircuit it in the 99.9999999% of 356 356 * cases where the USB serial is not a console anyway. 357 357 */ 358 - if (!port->port.console || !port->sysrq) { 359 - tty_insert_flip_string(&port->port, ch, urb->actual_length); 360 - } else { 358 + if (port->sysrq) { 361 359 for (i = 0; i < urb->actual_length; i++, ch++) { 362 360 if (!usb_serial_handle_sysrq_char(port, *ch)) 363 361 tty_insert_flip_char(&port->port, *ch, TTY_NORMAL); 364 362 } 363 + } else { 364 + tty_insert_flip_string(&port->port, ch, urb->actual_length); 365 365 } 366 366 tty_flip_buffer_push(&port->port); 367 367 } ··· 571 571 } 572 572 EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount); 573 573 574 - #ifdef CONFIG_MAGIC_SYSRQ 574 + #if defined(CONFIG_USB_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 575 575 int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) 576 576 { 577 - if (port->sysrq && port->port.console) { 577 + if (port->sysrq) { 578 578 if (ch && time_before(jiffies, port->sysrq)) { 579 579 handle_sysrq(ch); 580 580 port->sysrq = 0; ··· 584 584 } 585 585 return 0; 586 586 } 587 - #else 588 - int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) 589 - { 590 - return 0; 591 - } 592 - #endif 593 587 EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char); 594 588 595 589 int usb_serial_handle_break(struct usb_serial_port *port) 596 590 { 591 + if (!port->port.console) 592 + return 0; 593 + 597 594 if (!port->sysrq) { 598 595 port->sysrq = jiffies + HZ*5; 599 596 return 1; ··· 599 602 return 0; 600 603 } 601 604 EXPORT_SYMBOL_GPL(usb_serial_handle_break); 605 + #endif 602 606 603 607 /** 604 608 * usb_serial_handle_dcd_change - handle a change of carrier detect state
+2 -2
drivers/usb/serial/io_edgeport.c
··· 1752 1752 edge_serial->rxState = EXPECT_HDR2; 1753 1753 break; 1754 1754 } 1755 - /* Fall through */ 1755 + fallthrough; 1756 1756 case EXPECT_HDR2: 1757 1757 edge_serial->rxHeader2 = *buffer; 1758 1758 ++buffer; ··· 1804 1804 edge_serial->rxState = EXPECT_DATA; 1805 1805 break; 1806 1806 } 1807 - /* Fall through */ 1807 + fallthrough; 1808 1808 case EXPECT_DATA: /* Expect data */ 1809 1809 if (bufferLength < edge_serial->rxBytesRemaining) { 1810 1810 rxLen = bufferLength;
+12 -14
drivers/usb/serial/iuu_phoenix.c
··· 158 158 static void iuu_rxcmd(struct urb *urb) 159 159 { 160 160 struct usb_serial_port *port = urb->context; 161 - int result; 162 161 int status = urb->status; 163 162 164 163 if (status) { ··· 173 174 port->bulk_out_endpointAddress), 174 175 port->write_urb->transfer_buffer, 1, 175 176 read_rxcmd_callback, port); 176 - result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 177 + usb_submit_urb(port->write_urb, GFP_ATOMIC); 177 178 } 178 179 179 180 static int iuu_reset(struct usb_serial_port *port, u8 wt) ··· 240 241 static void iuu_status_callback(struct urb *urb) 241 242 { 242 243 struct usb_serial_port *port = urb->context; 243 - int result; 244 244 int status = urb->status; 245 245 246 246 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status); ··· 248 250 port->bulk_in_endpointAddress), 249 251 port->read_urb->transfer_buffer, 256, 250 252 iuu_update_status_callback, port); 251 - result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 253 + usb_submit_urb(port->read_urb, GFP_ATOMIC); 252 254 } 253 255 254 256 static int iuu_status(struct usb_serial_port *port) ··· 349 351 static void iuu_led_activity_on(struct urb *urb) 350 352 { 351 353 struct usb_serial_port *port = urb->context; 352 - int result; 353 354 char *buf_ptr = port->write_urb->transfer_buffer; 354 - *buf_ptr++ = IUU_SET_LED; 355 + 355 356 if (xmas) { 356 - get_random_bytes(buf_ptr, 6); 357 - *(buf_ptr+7) = 1; 357 + buf_ptr[0] = IUU_SET_LED; 358 + get_random_bytes(buf_ptr + 1, 6); 359 + buf_ptr[7] = 1; 358 360 } else { 359 361 iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255); 360 362 } ··· 364 366 port->bulk_out_endpointAddress), 365 367 port->write_urb->transfer_buffer, 8 , 366 368 iuu_rxcmd, port); 367 - result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 369 + usb_submit_urb(port->write_urb, GFP_ATOMIC); 368 370 } 369 371 370 372 static void iuu_led_activity_off(struct urb *urb) 371 373 { 372 374 struct usb_serial_port *port = urb->context; 373 - int result; 374 375 char *buf_ptr = port->write_urb->transfer_buffer; 376 + 375 377 if (xmas) { 376 378 iuu_rxcmd(urb); 377 379 return; 378 - } else { 379 - *buf_ptr++ = IUU_SET_LED; 380 - iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255); 381 380 } 381 + 382 + iuu_rgbf_fill_buffer(buf_ptr, 0, 0, 255, 255, 0, 0, 255); 383 + 382 384 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 383 385 usb_sndbulkpipe(port->serial->dev, 384 386 port->bulk_out_endpointAddress), 385 387 port->write_urb->transfer_buffer, 8 , 386 388 iuu_rxcmd, port); 387 - result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 389 + usb_submit_urb(port->write_urb, GFP_ATOMIC); 388 390 } 389 391 390 392
+1 -2
drivers/usb/serial/keyspan_pda.c
··· 664 664 /* download the firmware to a "fake" device (pre-renumeration) */ 665 665 static int keyspan_pda_fake_startup(struct usb_serial *serial) 666 666 { 667 - int response; 668 667 const char *fw_name; 669 668 670 669 /* download the firmware here ... */ 671 - response = ezusb_fx1_set_reset(serial->dev, 1); 670 + ezusb_fx1_set_reset(serial->dev, 1); 672 671 673 672 if (0) { ; } 674 673 #ifdef KEYSPAN
+5 -1
drivers/usb/serial/kobil_sct.c
··· 499 499 break; 500 500 default: 501 501 speed = 9600; 502 - /* fall through */ 502 + fallthrough; 503 503 case 9600: 504 504 urb_val = SUSBCR_SBR_9600; 505 505 break; ··· 526 526 0, 527 527 KOBIL_TIMEOUT 528 528 ); 529 + if (result) { 530 + dev_err(&port->dev, "failed to update line settings: %d\n", 531 + result); 532 + } 529 533 } 530 534 531 535 static int kobil_ioctl(struct tty_struct *tty,
+3 -3
drivers/usb/serial/mxuport.c
··· 327 327 { 328 328 int i; 329 329 330 - if (!port->port.console || !port->sysrq) { 331 - tty_insert_flip_string(&port->port, data, size); 332 - } else { 330 + if (port->sysrq) { 333 331 for (i = 0; i < size; i++, data++) { 334 332 if (!usb_serial_handle_sysrq_char(port, *data)) 335 333 tty_insert_flip_char(&port->port, *data, 336 334 TTY_NORMAL); 337 335 } 336 + } else { 337 + tty_insert_flip_string(&port->port, data, size); 338 338 } 339 339 tty_flip_buffer_push(&port->port); 340 340 }
+1 -2
drivers/usb/serial/option.c
··· 2157 2157 dev_dbg(dev, "%s: urb %p port %p has data %p\n", __func__, urb, port, portdata); 2158 2158 2159 2159 if (status == 0) { 2160 - struct usb_ctrlrequest *req_pkt = 2161 - (struct usb_ctrlrequest *)urb->transfer_buffer; 2160 + struct usb_ctrlrequest *req_pkt = urb->transfer_buffer; 2162 2161 2163 2162 if (!req_pkt) { 2164 2163 dev_dbg(dev, "%s: NULL req_pkt\n", __func__);
+1 -1
drivers/usb/serial/pl2303.c
··· 1101 1101 if (line_status & UART_OVERRUN_ERROR) 1102 1102 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 1103 1103 1104 - if (port->port.console && port->sysrq) { 1104 + if (port->sysrq) { 1105 1105 for (i = 0; i < urb->actual_length; ++i) 1106 1106 if (!usb_serial_handle_sysrq_char(port, data[i])) 1107 1107 tty_insert_flip_char(&port->port, data[i],
+1
drivers/usb/serial/qcserial.c
··· 155 155 {DEVICE_SWI(0x1199, 0x9056)}, /* Sierra Wireless Modem */ 156 156 {DEVICE_SWI(0x1199, 0x9060)}, /* Sierra Wireless Modem */ 157 157 {DEVICE_SWI(0x1199, 0x9061)}, /* Sierra Wireless Modem */ 158 + {DEVICE_SWI(0x1199, 0x9062)}, /* Sierra Wireless EM7305 QDL */ 158 159 {DEVICE_SWI(0x1199, 0x9063)}, /* Sierra Wireless EM7305 */ 159 160 {DEVICE_SWI(0x1199, 0x9070)}, /* Sierra Wireless MC74xx */ 160 161 {DEVICE_SWI(0x1199, 0x9071)}, /* Sierra Wireless MC74xx */
+1 -17
drivers/usb/serial/quatech2.c
··· 480 480 } 481 481 } 482 482 483 - /* not needed, kept to document functionality */ 484 - static void qt2_process_xmit_empty(struct usb_serial_port *port, 485 - unsigned char *ch) 486 - { 487 - int bytes_written; 488 - 489 - bytes_written = (int)(*ch) + (int)(*(ch + 1) << 4); 490 - } 491 - 492 - /* not needed, kept to document functionality */ 493 - static void qt2_process_flush(struct usb_serial_port *port, unsigned char *ch) 494 - { 495 - return; 496 - } 497 - 498 483 static void qt2_process_read_urb(struct urb *urb) 499 484 { 500 485 struct usb_serial *serial; ··· 525 540 __func__); 526 541 break; 527 542 } 528 - qt2_process_xmit_empty(port, ch + 3); 543 + /* bytes_written = (ch[1] << 4) + ch[0]; */ 529 544 i += 4; 530 545 escapeflag = true; 531 546 break; ··· 554 569 break; 555 570 case QT2_REC_FLUSH: 556 571 case QT2_XMIT_FLUSH: 557 - qt2_process_flush(port, ch + 2); 558 572 i += 2; 559 573 escapeflag = true; 560 574 break;
+30 -31
drivers/usb/serial/sierra.c
··· 45 45 46 46 static bool nmea; 47 47 48 - /* Used in interface quirks */ 49 - struct sierra_iface_quirk { 50 - const u32 infolen; /* number of interface numbers on the list */ 51 - const u8 *ifaceinfo; /* pointer to the array holding the numbers */ 48 + struct sierra_iface_list { 49 + const u8 *nums; /* array of interface numbers */ 50 + size_t count; /* number of elements in array */ 52 51 }; 53 52 54 53 struct sierra_intf_private { ··· 100 101 return num_ports; 101 102 } 102 103 103 - static int is_quirk(const u8 ifnum, const struct sierra_iface_quirk *quirk) 104 + static bool is_listed(const u8 ifnum, const struct sierra_iface_list *list) 104 105 { 105 - const u8 *info; 106 106 int i; 107 107 108 - if (quirk) { 109 - info = quirk->ifaceinfo; 108 + if (!list) 109 + return false; 110 110 111 - for (i = 0; i < quirk->infolen; i++) { 112 - if (info[i] == ifnum) 113 - return 1; 114 - } 111 + for (i = 0; i < list->count; i++) { 112 + if (list->nums[i] == ifnum) 113 + return true; 115 114 } 116 - return 0; 115 + 116 + return false; 117 117 } 118 118 119 119 static u8 sierra_interface_num(struct usb_serial *serial) ··· 123 125 static int sierra_probe(struct usb_serial *serial, 124 126 const struct usb_device_id *id) 125 127 { 128 + const struct sierra_iface_list *ignore_list; 126 129 int result = 0; 127 130 struct usb_device *udev; 128 131 u8 ifnum; ··· 142 143 usb_set_interface(udev, ifnum, 1); 143 144 } 144 145 145 - if (is_quirk(ifnum, (struct sierra_iface_quirk *)id->driver_info)) { 146 - dev_dbg(&serial->dev->dev, 147 - "Ignoring interface #%d\n", ifnum); 146 + ignore_list = (const struct sierra_iface_list *)id->driver_info; 147 + 148 + if (is_listed(ifnum, ignore_list)) { 149 + dev_dbg(&serial->dev->dev, "Ignoring interface #%d\n", ifnum); 148 150 return -ENODEV; 149 151 } 150 152 ··· 154 154 155 155 /* interfaces with higher memory requirements */ 156 156 static const u8 hi_memory_typeA_ifaces[] = { 0, 2 }; 157 - static const struct sierra_iface_quirk typeA_interface_list = { 158 - .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces), 159 - .ifaceinfo = hi_memory_typeA_ifaces, 157 + static const struct sierra_iface_list typeA_interface_list = { 158 + .nums = hi_memory_typeA_ifaces, 159 + .count = ARRAY_SIZE(hi_memory_typeA_ifaces), 160 160 }; 161 161 162 162 static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 }; 163 - static const struct sierra_iface_quirk typeB_interface_list = { 164 - .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces), 165 - .ifaceinfo = hi_memory_typeB_ifaces, 163 + static const struct sierra_iface_list typeB_interface_list = { 164 + .nums = hi_memory_typeB_ifaces, 165 + .count = ARRAY_SIZE(hi_memory_typeB_ifaces), 166 166 }; 167 167 168 168 /* 'ignorelist' of interfaces not served by this driver */ 169 169 static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 }; 170 - static const struct sierra_iface_quirk direct_ip_interface_ignore = { 171 - .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces), 172 - .ifaceinfo = direct_ip_non_serial_ifaces, 170 + static const struct sierra_iface_list direct_ip_interface_ignore = { 171 + .nums = direct_ip_non_serial_ifaces, 172 + .count = ARRAY_SIZE(direct_ip_non_serial_ifaces), 173 173 }; 174 174 175 175 static const struct usb_device_id id_table[] = { ··· 570 570 urb, port, portdata); 571 571 572 572 if (status == 0) { 573 - struct usb_ctrlrequest *req_pkt = 574 - (struct usb_ctrlrequest *)urb->transfer_buffer; 573 + struct usb_ctrlrequest *req_pkt = urb->transfer_buffer; 575 574 576 575 if (!req_pkt) { 577 576 dev_dbg(&port->dev, "%s: NULL req_pkt\n", ··· 859 860 { 860 861 struct usb_serial *serial = port->serial; 861 862 struct sierra_port_private *portdata; 862 - const struct sierra_iface_quirk *himemoryp; 863 + const struct sierra_iface_list *himemory_list; 863 864 u8 ifnum; 864 865 865 866 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); ··· 878 879 if (serial->num_ports == 1) { 879 880 /* Get interface number for composite device */ 880 881 ifnum = sierra_interface_num(serial); 881 - himemoryp = &typeB_interface_list; 882 + himemory_list = &typeB_interface_list; 882 883 } else { 883 884 /* This is really the usb-serial port number of the interface 884 885 * rather than the interface number. 885 886 */ 886 887 ifnum = port->port_number; 887 - himemoryp = &typeA_interface_list; 888 + himemory_list = &typeA_interface_list; 888 889 } 889 890 890 - if (is_quirk(ifnum, himemoryp)) { 891 + if (is_listed(ifnum, himemory_list)) { 891 892 portdata->num_out_urbs = N_OUT_URB_HM; 892 893 portdata->num_in_urbs = N_IN_URB_HM; 893 894 }
+4 -3
drivers/usb/serial/ssu100.c
··· 495 495 static void ssu100_process_read_urb(struct urb *urb) 496 496 { 497 497 struct usb_serial_port *port = urb->context; 498 - char *packet = (char *)urb->transfer_buffer; 498 + char *packet = urb->transfer_buffer; 499 499 char flag = TTY_NORMAL; 500 500 u32 len = urb->actual_length; 501 501 int i; ··· 517 517 if (!len) 518 518 return; /* status only */ 519 519 520 - if (port->port.console && port->sysrq) { 520 + if (port->sysrq) { 521 521 for (i = 0; i < len; i++, ch++) { 522 522 if (!usb_serial_handle_sysrq_char(port, *ch)) 523 523 tty_insert_flip_char(&port->port, *ch, flag); 524 524 } 525 - } else 525 + } else { 526 526 tty_insert_flip_string_fixed_flag(&port->port, ch, flag, len); 527 + } 527 528 528 529 tty_flip_buffer_push(&port->port); 529 530 }
+1 -1
drivers/usb/serial/upd78f0730.c
··· 332 332 tty->termios.c_cflag &= ~CSIZE; 333 333 tty->termios.c_cflag |= CS8; 334 334 dev_warn(dev, "data size is not supported, using 8 bits\n"); 335 - /* fall through */ 335 + fallthrough; 336 336 case CS8: 337 337 request.params |= UPD78F0730_DATA_SIZE_8_BITS; 338 338 dev_dbg(dev, "%s - 8 data bits\n", __func__);
+49 -46
include/linux/usb/serial.h
··· 17 17 #include <linux/kref.h> 18 18 #include <linux/mutex.h> 19 19 #include <linux/serial.h> 20 - #include <linux/sysrq.h> 21 20 #include <linux/kfifo.h> 22 21 23 22 /* The maximum number of ports one device can grab at once */ ··· 315 316 #define to_usb_serial_driver(d) \ 316 317 container_of(d, struct usb_serial_driver, driver) 317 318 318 - extern int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[], 319 + int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[], 319 320 const char *name, const struct usb_device_id *id_table); 320 - extern void usb_serial_deregister_drivers(struct usb_serial_driver *const serial_drivers[]); 321 - extern void usb_serial_port_softint(struct usb_serial_port *port); 321 + void usb_serial_deregister_drivers(struct usb_serial_driver *const serial_drivers[]); 322 + void usb_serial_port_softint(struct usb_serial_port *port); 322 323 323 - extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 324 - extern int usb_serial_resume(struct usb_interface *intf); 324 + int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 325 + int usb_serial_resume(struct usb_interface *intf); 325 326 326 327 /* USB Serial console functions */ 327 328 #ifdef CONFIG_USB_SERIAL_CONSOLE 328 - extern void usb_serial_console_init(int minor); 329 - extern void usb_serial_console_exit(void); 330 - extern void usb_serial_console_disconnect(struct usb_serial *serial); 329 + void usb_serial_console_init(int minor); 330 + void usb_serial_console_exit(void); 331 + void usb_serial_console_disconnect(struct usb_serial *serial); 331 332 #else 332 333 static inline void usb_serial_console_init(int minor) { } 333 334 static inline void usb_serial_console_exit(void) { } ··· 335 336 #endif 336 337 337 338 /* Functions needed by other parts of the usbserial core */ 338 - extern struct usb_serial_port *usb_serial_port_get_by_minor(unsigned int minor); 339 - extern void usb_serial_put(struct usb_serial *serial); 340 - extern int usb_serial_generic_open(struct tty_struct *tty, 341 - struct usb_serial_port *port); 342 - extern int usb_serial_generic_write_start(struct usb_serial_port *port, 343 - gfp_t mem_flags); 344 - extern int usb_serial_generic_write(struct tty_struct *tty, 345 - struct usb_serial_port *port, const unsigned char *buf, int count); 346 - extern void usb_serial_generic_close(struct usb_serial_port *port); 347 - extern int usb_serial_generic_resume(struct usb_serial *serial); 348 - extern int usb_serial_generic_write_room(struct tty_struct *tty); 349 - extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty); 350 - extern void usb_serial_generic_wait_until_sent(struct tty_struct *tty, 351 - long timeout); 352 - extern void usb_serial_generic_read_bulk_callback(struct urb *urb); 353 - extern void usb_serial_generic_write_bulk_callback(struct urb *urb); 354 - extern void usb_serial_generic_throttle(struct tty_struct *tty); 355 - extern void usb_serial_generic_unthrottle(struct tty_struct *tty); 356 - extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty, 357 - unsigned long arg); 358 - extern int usb_serial_generic_get_icount(struct tty_struct *tty, 359 - struct serial_icounter_struct *icount); 360 - extern int usb_serial_generic_register(void); 361 - extern void usb_serial_generic_deregister(void); 362 - extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, 363 - gfp_t mem_flags); 364 - extern void usb_serial_generic_process_read_urb(struct urb *urb); 365 - extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, 366 - void *dest, size_t size); 367 - extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port, 368 - unsigned int ch); 369 - extern int usb_serial_handle_break(struct usb_serial_port *port); 370 - extern void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, 371 - struct tty_struct *tty, 372 - unsigned int status); 339 + struct usb_serial_port *usb_serial_port_get_by_minor(unsigned int minor); 340 + void usb_serial_put(struct usb_serial *serial); 341 + int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port); 342 + int usb_serial_generic_write_start(struct usb_serial_port *port, gfp_t mem_flags); 343 + int usb_serial_generic_write(struct tty_struct *tty, struct usb_serial_port *port, 344 + const unsigned char *buf, int count); 345 + void usb_serial_generic_close(struct usb_serial_port *port); 346 + int usb_serial_generic_resume(struct usb_serial *serial); 347 + int usb_serial_generic_write_room(struct tty_struct *tty); 348 + int usb_serial_generic_chars_in_buffer(struct tty_struct *tty); 349 + void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout); 350 + void usb_serial_generic_read_bulk_callback(struct urb *urb); 351 + void usb_serial_generic_write_bulk_callback(struct urb *urb); 352 + void usb_serial_generic_throttle(struct tty_struct *tty); 353 + void usb_serial_generic_unthrottle(struct tty_struct *tty); 354 + int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg); 355 + int usb_serial_generic_get_icount(struct tty_struct *tty, struct serial_icounter_struct *icount); 356 + int usb_serial_generic_register(void); 357 + void usb_serial_generic_deregister(void); 358 + int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, gfp_t mem_flags); 359 + void usb_serial_generic_process_read_urb(struct urb *urb); 360 + int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port, void *dest, size_t size); 361 + 362 + #if defined(CONFIG_USB_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 363 + int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch); 364 + int usb_serial_handle_break(struct usb_serial_port *port); 365 + #else 366 + static inline int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) 367 + { 368 + return 0; 369 + } 370 + static inline int usb_serial_handle_break(struct usb_serial_port *port) 371 + { 372 + return 0; 373 + } 374 + #endif 375 + 376 + void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port, 377 + struct tty_struct *tty, unsigned int status); 373 378 374 379 375 - extern int usb_serial_bus_register(struct usb_serial_driver *device); 376 - extern void usb_serial_bus_deregister(struct usb_serial_driver *device); 380 + int usb_serial_bus_register(struct usb_serial_driver *device); 381 + void usb_serial_bus_deregister(struct usb_serial_driver *device); 377 382 378 383 extern struct bus_type usb_serial_bus_type; 379 384 extern struct tty_driver *usb_serial_tty_driver;