lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1323450440-414-4-git-send-email-w.sang@pengutronix.de>
Date:	Fri,  9 Dec 2011 18:07:15 +0100
From:	Wolfram Sang <w.sang@...gutronix.de>
To:	linux-serial@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, Greg KH <gregkh@...e.de>,
	Alan Cox <alan@...ux.intel.com>,
	Claudio Scordino <claudio@...dence.eu.com>,
	Wolfram Sang <w.sang@...gutronix.de>
Subject: [PATCH RESEND 3/8] serial: 8250: save rs485_flags per instance

When set, save RS485 related flags in the private struct. This avoids
mangling with chip registers when reading back the RS485 config. Also,
features can check their configuration at runtime which will be needed
for a later patch.

Signed-off-by: Wolfram Sang <w.sang@...gutronix.de>
---
 drivers/tty/serial/8250.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index 920b4df..b5d3248 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -154,6 +154,7 @@ struct uart_8250_port {
 	unsigned char		lsr_saved_flags;
 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
 	unsigned char		msr_saved_flags;
+	__u32			rs485_flags;	/* copied from IOCTL */
 };
 
 struct irq_info {
@@ -2729,28 +2730,21 @@ static int serial8250_ioctl_port(struct uart_port *port,
 		serial_outp(up, UART_FCTR, fctr);
 		serial_outp(up, UART_LCR, lcr);
 		spin_unlock_irqrestore(&up->port.lock, flags);
+
+		up->rs485_flags = rs485ctrl.flags;
+
 		return 0;
 	}
 
 	case TIOCGRS485:
 	{
 		struct serial_rs485 rs485ctrl;
-		unsigned char lcr;
 
 		if (port->type != PORT_16850)
 			return -ENOTTY;
 
 		memset(&rs485ctrl, 0, sizeof(rs485ctrl));
-
-		spin_lock_irqsave(&up->port.lock, flags);
-		lcr = serial_inp(up, UART_LCR);
-		serial_outp(up, UART_LCR, UART_LCR_CONF_MODE_B);
-		if (serial_inp(up, UART_FCTR) & UART_FCTR_RS485)
-			rs485ctrl.flags = SER_RS485_ENABLED;
-		else
-			rs485ctrl.flags = 0;
-		serial_outp(up, UART_LCR, lcr);
-		spin_unlock_irqrestore(&up->port.lock, flags);
+		rs485ctrl.flags = up->rs485_flags;
 
 		if (copy_to_user((struct serial_rs485 *)arg, &rs485ctrl,
 				 sizeof(rs485ctrl)))
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ