From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932218AbcELIut (ORCPT ); Thu, 12 May 2016 04:50:49 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36026 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932181AbcELIug (ORCPT ); Thu, 12 May 2016 04:50:36 -0400 From: Mathieu OTHACEHE To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Mathieu OTHACEHE Subject: [PATCH 25/36] usb: serial: ti_usb_3410_5052: Check old_termios parameter in set_termios Date: Thu, 12 May 2016 10:48:57 +0200 Message-Id: <1463042948-12205-26-git-send-email-m.othacehe@gmail.com> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1463042948-12205-1-git-send-email-m.othacehe@gmail.com> References: <1463042948-12205-1-git-send-email-m.othacehe@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The old_termios parameter is never used in set_termios callback. Add a check to old_termios to see if we can return right away because there is nothing to change. Add a check to old_termios CBAUD to see if we can set DTR/RTS because last speed was B0. Also pass NULL for old_termios in open callback because it is the initial call to set_termios. Signed-off-by: Mathieu OTHACEHE --- drivers/usb/serial/ti_usb_3410_5052.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 4769c80..b50f52f 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -710,7 +710,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) } if (tty) - ti_set_termios(tty, port, &tty->termios); + ti_set_termios(tty, port, NULL); status = ti_send_ctrl_urb(serial, TI_OPEN_PORT, open_settings, TI_UART1_PORT + port_number); @@ -750,7 +750,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) usb_clear_halt(serial->dev, port->read_urb->pipe); if (tty) - ti_set_termios(tty, port, &tty->termios); + ti_set_termios(tty, port, NULL); status = ti_send_ctrl_urb(serial, TI_OPEN_PORT, open_settings, TI_UART1_PORT + port_number); @@ -913,6 +913,13 @@ static void ti_set_termios(struct tty_struct *tty, cflag = tty->termios.c_cflag; iflag = tty->termios.c_iflag; + if (old_termios && + !tty_termios_hw_change(&tty->termios, old_termios) && + tty->termios.c_iflag == old_termios->c_iflag) { + dev_dbg(&port->dev, "%s - nothing to change\n", __func__); + return; + } + dev_dbg(&port->dev, "%s - cflag 0x%08x, iflag 0x%08x\n", __func__, cflag, iflag); @@ -1020,6 +1027,9 @@ static void ti_set_termios(struct tty_struct *tty, /* if baud rate is B0, clear RTS and DTR */ if (C_BAUD(tty) == B0) mcr &= ~(TI_MCR_DTR | TI_MCR_RTS); + else if (old_termios && (old_termios->c_cflag & CBAUD) == B0) + mcr |= TI_MCR_DTR | TI_MCR_RTS; + status = ti_set_mcr(tport, mcr); if (status) dev_err(&port->dev, -- 2.8.2