We implement delta change for MSR counting. This patch is referenced
from ftdi_sio.c

Signed-off-by: Peter Hung <hpeter+linux_ker...@gmail.com>
---
 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to