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

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

Merge usb-serial updates from Johan:

USB-serial updates for 6.14-rc1

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

- fix a long-standing NULL-deref issue in quatech2
- add support for hardware flow control to ch341

Included is also a related clean up.

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

* tag 'usb-serial-6.14-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb()
USB: serial: ch341: use fix-width types consistently
USB: serial: ch341: add hardware flow control RTS/CTS

+32 -5
+31 -4
drivers/usb/serial/ch341.c
··· 63 63 #define CH341_REG_DIVISOR 0x13 64 64 #define CH341_REG_LCR 0x18 65 65 #define CH341_REG_LCR2 0x25 66 + #define CH341_REG_FLOW_CTL 0x27 66 67 67 68 #define CH341_NBREAK_BITS 0x01 68 69 ··· 77 76 #define CH341_LCR_CS7 0x02 78 77 #define CH341_LCR_CS6 0x01 79 78 #define CH341_LCR_CS5 0x00 79 + 80 + #define CH341_FLOW_CTL_NONE 0x00 81 + #define CH341_FLOW_CTL_RTSCTS 0x01 80 82 81 83 #define CH341_QUIRK_LIMITED_PRESCALER BIT(0) 82 84 #define CH341_QUIRK_SIMULATE_BREAK BIT(1) ··· 482 478 return r; 483 479 } 484 480 481 + static void ch341_set_flow_control(struct tty_struct *tty, 482 + struct usb_serial_port *port, 483 + const struct ktermios *old_termios) 484 + { 485 + u16 flow_ctl; 486 + int r; 487 + 488 + if (C_CRTSCTS(tty)) 489 + flow_ctl = CH341_FLOW_CTL_RTSCTS; 490 + else 491 + flow_ctl = CH341_FLOW_CTL_NONE; 492 + 493 + r = ch341_control_out(port->serial->dev, 494 + CH341_REQ_WRITE_REG, 495 + (CH341_REG_FLOW_CTL << 8) | CH341_REG_FLOW_CTL, 496 + (flow_ctl << 8) | flow_ctl); 497 + if (r < 0 && old_termios) { 498 + tty->termios.c_cflag &= ~CRTSCTS; 499 + tty->termios.c_cflag |= (old_termios->c_cflag & CRTSCTS); 500 + } 501 + } 502 + 485 503 /* Old_termios contains the original termios settings and 486 504 * tty->termios contains the new setting to be used. 487 505 */ ··· 572 546 spin_unlock_irqrestore(&priv->lock, flags); 573 547 574 548 ch341_set_handshake(port->serial->dev, priv->mcr); 549 + 550 + ch341_set_flow_control(tty, port, old_termios); 575 551 } 576 552 577 553 /* ··· 660 632 661 633 static int ch341_break_ctl(struct tty_struct *tty, int break_state) 662 634 { 663 - const uint16_t ch341_break_reg = 664 - ((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK; 635 + const u16 ch341_break_reg = (CH341_REG_LCR << 8) | CH341_REG_BREAK; 665 636 struct usb_serial_port *port = tty->driver_data; 666 637 struct ch341_private *priv = usb_get_serial_port_data(port); 638 + u16 reg_contents; 639 + u8 break_reg[2]; 667 640 int r; 668 - uint16_t reg_contents; 669 - uint8_t break_reg[2]; 670 641 671 642 if (priv->quirks & CH341_QUIRK_SIMULATE_BREAK) 672 643 return ch341_simulate_break(tty, break_state);
+1 -1
drivers/usb/serial/quatech2.c
··· 503 503 504 504 newport = *(ch + 3); 505 505 506 - if (newport > serial->num_ports) { 506 + if (newport >= serial->num_ports) { 507 507 dev_err(&port->dev, 508 508 "%s - port change to invalid port: %i\n", 509 509 __func__, newport);