Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755637AbbBPH6z (ORCPT ); Mon, 16 Feb 2015 02:58:55 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:33003 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755577AbbBPH6v (ORCPT ); Mon, 16 Feb 2015 02:58:51 -0500 From: Peter Hung X-Google-Original-From: Peter Hung To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, tom_tsai@fintek.com.tw, peter_hong@fintek.com.tw, Peter Hung Subject: [PATCH V6 09/10] USB: f81232: implement delta change for MSR count Date: Mon, 16 Feb 2015 15:58:01 +0800 Message-Id: <1424073482-18164-10-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424073482-18164-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1424073482-18164-1-git-send-email-hpeter+linux_kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1898 Lines: 64 We implement delta change for MSR counting. This patch is referenced from ftdi_sio.c Signed-off-by: Peter Hung --- drivers/usb/serial/f81232.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 94c05d7..5134a19 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -112,6 +112,7 @@ static void f81232_read_msr(struct usb_serial_port *port) unsigned long flags; u8 current_msr, prev_msr; u8 msr_mask = ~UART_MSR_ANY_DELTA; + u8 msr_changed_bit; struct tty_struct *tty; struct f81232_private *priv = usb_get_serial_port_data(port); @@ -141,14 +142,30 @@ static void f81232_read_msr(struct usb_serial_port *port) !((prev_msr ^ current_msr) & msr_mask)) return; - tty = tty_port_tty_get(&port->port); - if (tty) { - if (current_msr & UART_MSR_DDCD) { + /* find checked delta bits set */ + msr_changed_bit = + (current_msr & UART_MSR_ANY_DELTA) << 4; + + /* append with not delta but changed bits */ + msr_changed_bit |= (prev_msr ^ current_msr) & msr_mask; + + if (msr_changed_bit & UART_MSR_CTS) + port->icount.cts++; + if (msr_changed_bit & UART_MSR_DSR) + port->icount.dsr++; + if (msr_changed_bit & UART_MSR_RI) + port->icount.rng++; + if (msr_changed_bit & UART_MSR_DCD) { + + port->icount.dcd++; + tty = tty_port_tty_get(&port->port); + if (tty) { + usb_serial_handle_dcd_change(port, tty, current_msr & UART_MSR_DCD); - } - tty_kref_put(tty); + tty_kref_put(tty); + } } wake_up_interruptible(&port->port.delta_msr_wait); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/