[PATCH V6 09/10] USB: f81232: implement delta change for MSR count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Peter Hung <hpeter+linux_kernel@xxxxxxxxx>
---
 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-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux