From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: linux-kernel@vger.kernel.org, akpm@osdl.org, greg@kroah.com
Subject: [PATCH 17/20] riscom8: remove bogus checks
Date: Mon, 19 May 2008 15:51:45 +0100 [thread overview]
Message-ID: <20080519145144.19326.27668.stgit@core> (raw)
In-Reply-To: <20080519144557.19326.74313.stgit@core>
From: Alan Cox <alan@redhat.com>
Chris Malley posted a patch removing a NULL check in the riscom8 driver.
Further analysis shows that even more of the tests are irrelevant so we
can delete lots of stuff
---
drivers/char/riscom8.c | 32 ++++++++------------------------
1 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index b0ba241..3ca8957 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -638,9 +638,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
unsigned char cor1 = 0, cor3 = 0;
unsigned char mcor1 = 0, mcor2 = 0;
- if (tty == NULL || tty->termios == NULL)
- return;
-
port->IER = 0;
port->COR2 = 0;
port->MSVR = MSVR_RTS;
@@ -794,8 +791,7 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
spin_lock_irqsave(&riscom_lock, flags);
- if (port->port.tty)
- clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
+ clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
if (port->port.count == 1)
bp->count++;
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
@@ -807,10 +803,9 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
}
/* Must be called with interrupts disabled */
-static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
+static void rc_shutdown_port(struct tty_struct *tty,
+ struct riscom_board *bp, struct riscom_port *port)
{
- struct tty_struct *tty;
-
if (!(port->port.flags & ASYNC_INITIALIZED))
return;
@@ -830,10 +825,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
}
#endif
tty_port_free_xmit_buf(&port->port);
-
- tty = port->port.tty;
-
- if (tty == NULL || C_HUPCL(tty)) {
+ if (C_HUPCL(tty)) {
/* Drop DTR */
bp->DTR |= (1u << port_No(port));
rc_out(bp, RC_DTR, bp->DTR);
@@ -848,8 +840,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
port->IER = 0;
rc_out(bp, CD180_IER, port->IER);
- if (tty)
- set_bit(TTY_IO_ERROR, &tty->flags);
+ set_bit(TTY_IO_ERROR, &tty->flags);
port->port.flags &= ~ASYNC_INITIALIZED;
if (--bp->count < 0) {
@@ -1067,7 +1058,7 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
break;
}
}
- rc_shutdown_port(bp, port);
+ rc_shutdown_port(tty, bp, port);
rc_flush_buffer(tty);
tty_ldisc_flush(tty);
@@ -1098,9 +1089,6 @@ static int rc_write(struct tty_struct *tty,
bp = port_Board(port);
- if (!tty || !port->port.xmit_buf)
- return 0;
-
while (1) {
spin_lock_irqsave(&riscom_lock, flags);
@@ -1141,9 +1129,6 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)
if (rc_paranoia_check(port, tty->name, "rc_put_char"))
return 0;
- if (!tty || !port->port.xmit_buf)
- return 0;
-
spin_lock_irqsave(&riscom_lock, flags);
if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
@@ -1167,8 +1152,7 @@ static void rc_flush_chars(struct tty_struct *tty)
if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
return;
- if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
- !port->port.xmit_buf)
+ if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped)
return;
spin_lock_irqsave(&riscom_lock, flags);
@@ -1488,7 +1472,7 @@ static void rc_hangup(struct tty_struct *tty)
bp = port_Board(port);
- rc_shutdown_port(bp, port);
+ rc_shutdown_port(tty, bp, port);
port->port.count = 0;
port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
port->port.tty = NULL;
next prev parent reply other threads:[~2008-05-19 15:08 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-19 14:50 [PATCH 00/20] Implment a tty port structure and supporting logic Alan Cox
2008-05-19 14:50 ` [PATCH 01/20] tty: Introduce a tty_port common structure Alan Cox
2008-05-19 17:47 ` Sam Ravnborg
2008-05-19 17:51 ` Greg KH
2008-05-19 19:48 ` Alan Cox
2008-05-19 21:36 ` Greg KH
2008-05-19 14:50 ` [PATCH 02/20] tty: Clean up tiocmset Alan Cox
2008-05-19 14:50 ` [PATCH 03/20] epca: use tty_port Alan Cox
2008-05-19 14:50 ` [PATCH 04/20] isicom: " Alan Cox
2008-05-19 14:50 ` [PATCH 05/20] moxa: " Alan Cox
2008-05-19 14:50 ` [PATCH 06/20] mxser: " Alan Cox
2008-05-19 14:50 ` [PATCH 07/20] riscom8: " Alan Cox
2008-05-19 14:50 ` [PATCH 08/20] rocket: " Alan Cox
2008-05-19 14:50 ` [PATCH 09/20] synclink: " Alan Cox
2008-05-19 14:51 ` [PATCH 10/20] esp: " Alan Cox
2008-05-19 14:51 ` [PATCH 11/20] istallion: " Alan Cox
2008-05-19 14:51 ` [PATCH 12/20] stallion: " Alan Cox
2008-05-19 14:51 ` [PATCH 13/20] cyclades: " Alan Cox
2008-05-19 14:51 ` [PATCH 14/20] gs: " Alan Cox
2008-05-19 14:51 ` [PATCH 15/20] serial: " Alan Cox
2008-05-19 14:51 ` Alan Cox [this message]
2008-05-19 14:51 ` [PATCH 18/20] tty: add more tty_port fields Alan Cox
2008-05-19 14:51 ` [PATCH 19/20] whiteheat: coding style Alan Cox
2008-05-19 14:52 ` [PATCH 20/20] whiteheat: fix bugs found in the tidy and audit Alan Cox
2008-05-19 16:50 ` [PATCH 00/20] Implment a tty port structure and supporting logic Greg KH
2008-05-19 18:27 ` Alan Cox
2008-05-20 8:52 ` Andrew Morton
2008-05-20 17:23 ` Greg KH
2008-05-20 18:53 ` Alan Cox
2008-05-19 22:39 ` Aristeu Rozanski
2008-05-20 8:31 ` Alan Cox
2008-05-27 18:05 ` Greg KH
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=20080519145144.19326.27668.stgit@core \
--to=alan@lxorguk.ukuu.org.uk \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--cc=linux-kernel@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