linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Shiyan <shc_work@mail.ru>
To: linux-serial@vger.kernel.org
Cc: Alan Cox <alan@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Alexander Shiyan <shc_work@mail.ru>
Subject: [PATCH 08/12] serial: clps711x: Check for valid TTY in RX-interrupt
Date: Sun, 14 Oct 2012 11:05:30 +0400	[thread overview]
Message-ID: <1350198334-18737-8-git-send-email-shc_work@mail.ru> (raw)
In-Reply-To: <1350198334-18737-1-git-send-email-shc_work@mail.ru>


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/tty/serial/clps711x.c |   59 ++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index 73505c1..6039ebe 100644
--- a/drivers/tty/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
@@ -55,8 +55,6 @@
 #define TX_IRQ(port)		((port)->line ? IRQ_UTXINT2 : IRQ_UTXINT1)
 #define RX_IRQ(port)		((port)->line ? IRQ_URXINT2 : IRQ_URXINT1)
 
-#define UART_ANY_ERR		(UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR)
-
 struct clps711x_port {
 	struct uart_driver	uart;
 	struct clk		*uart_clk;
@@ -99,54 +97,55 @@ static void clps711xuart_enable_ms(struct uart_port *port)
 static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id)
 {
 	struct uart_port *port = dev_id;
-	struct tty_struct *tty = port->state->port.tty;
+	struct tty_struct *tty = tty_port_tty_get(&port->state->port);
 	unsigned int status, ch, flg;
 
-	status = clps_readl(SYSFLG(port));
-	while (!(status & SYSFLG_URXFE)) {
-		ch = clps_readl(UARTDR(port));
+	if (!tty)
+		return IRQ_HANDLED;
 
-		port->icount.rx++;
+	for (;;) {
+		status = clps_readl(SYSFLG(port));
+		if (status & SYSFLG_URXFE)
+			break;
 
+		ch = clps_readw(UARTDR(port));
+		status = ch & (UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR);
+		ch &= 0xff;
+
+		port->icount.rx++;
 		flg = TTY_NORMAL;
 
-		/*
-		 * Note that the error handling code is
-		 * out of the main execution path
-		 */
-		if (unlikely(ch & UART_ANY_ERR)) {
-			if (ch & UARTDR_PARERR)
+		if (unlikely(status)) {
+			if (status & UARTDR_PARERR)
 				port->icount.parity++;
-			else if (ch & UARTDR_FRMERR)
+			else if (status & UARTDR_FRMERR)
 				port->icount.frame++;
-			if (ch & UARTDR_OVERR)
+			else if (status & UARTDR_OVERR)
 				port->icount.overrun++;
 
-			ch &= port->read_status_mask;
+			status &= port->read_status_mask;
 
-			if (ch & UARTDR_PARERR)
+			if (status & UARTDR_PARERR)
 				flg = TTY_PARITY;
-			else if (ch & UARTDR_FRMERR)
+			else if (status & UARTDR_FRMERR)
 				flg = TTY_FRAME;
-
-#ifdef SUPPORT_SYSRQ
-			port->sysrq = 0;
-#endif
+			else if (status & UARTDR_OVERR)
+				flg = TTY_OVERRUN;
 		}
 
 		if (uart_handle_sysrq_char(port, ch))
-			goto ignore_char;
+			continue;
 
-		/*
-		 * CHECK: does overrun affect the current character?
-		 * ASSUMPTION: it does not.
-		 */
-		uart_insert_char(port, ch, UARTDR_OVERR, ch, flg);
+		if (status & port->ignore_status_mask)
+			continue;
 
-	ignore_char:
-		status = clps_readl(SYSFLG(port));
+		uart_insert_char(port, status, UARTDR_OVERR, ch, flg);
 	}
+
 	tty_flip_buffer_push(tty);
+
+	tty_kref_put(tty);
+
 	return IRQ_HANDLED;
 }
 
-- 
1.7.8.6


  parent reply	other threads:[~2012-10-14  7:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-14  7:05 [PATCH 01/12] serial: clps711x: Add platform_driver interface to clps711x driver Alexander Shiyan
2012-10-14  7:05 ` [PATCH 02/12] serial: clps711x: Convert all static variables to dynamic Alexander Shiyan
2012-10-14  7:05 ` [PATCH 03/12] serial: clps711x: Do not use "uart_port->unused" field Alexander Shiyan
2012-10-14  7:05 ` [PATCH 04/12] serial: clps711x: Using CPU clock subsystem for getting base UART speed Alexander Shiyan
2012-10-14  7:05 ` [PATCH 05/12] serial: clps711x: Improved TX FIFO handling Alexander Shiyan
2012-10-14  7:05 ` [PATCH 06/12] serial: clps711x: Return valid modem controls for port that not support it Alexander Shiyan
2012-10-14  7:05 ` [PATCH 07/12] serial: clps711x: Fix break control handling Alexander Shiyan
2012-10-14  7:05 ` Alexander Shiyan [this message]
2012-10-14  7:05 ` [PATCH 09/12] serial: clps711x: Using resource-managed functions Alexander Shiyan
2012-10-14  7:05 ` [PATCH 10/12] serial: clps711x: Disable "break"-state before port startup Alexander Shiyan
2012-10-14  7:05 ` [PATCH 11/12] serial: clps711x: Fix TERMIOS-flags handling Alexander Shiyan
2012-10-14  7:05 ` [PATCH 12/12] serial: clps711x: Cleanup driver Alexander Shiyan
2012-10-14  7:54 ` [PATCH 01/12] serial: clps711x: Add platform_driver interface to clps711x driver Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350198334-18737-8-git-send-email-shc_work@mail.ru \
    --to=shc_work@mail.ru \
    --cc=alan@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).