[PATCH 10/70] riscom8: remove bogus checks

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Date: Friday, June 20, 2008 - 3:59 pm

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

Signed-off-by: Alan Cox <alan@redhat.com>
---

 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;

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/70] tty updates proposed for 2.6.27, Alan Cox, (Fri Jun 20, 3:57 pm)
Re: [PATCH 00/70] tty updates proposed for 2.6.27, Marcel Holtmann, (Sat Jun 21, 9:23 am)
Re: [PATCH 00/70] tty updates proposed for 2.6.27, Johannes Weiner, (Fri Jun 20, 7:39 pm)
[PATCH 70/70] tty-usb-mos7720: Coding style, Alan Cox, (Fri Jun 20, 4:07 pm)
[PATCH 69/70] whiteheat: remove unused variable, Alan Cox, (Fri Jun 20, 4:07 pm)
[PATCH 67/70] omninet: Use string flip functions, Alan Cox, (Fri Jun 20, 4:07 pm)
[PATCH 66/70] tty-usb-omninet: Coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 65/70] tty-usb-option: Coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 64/70] tty-usb-oti6858: Coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 63/70] tty-usb-safe-serial: Coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 62/70] tty-usb-ti-usb: Coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 61/70] tty-usb-spcp8x5: Minor coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 59/70] tty-usb-pl2303: Coding style, Alan Cox, (Fri Jun 20, 4:06 pm)
[PATCH 58/70] mct_u232: Use flip buffer functions, Alan Cox, (Fri Jun 20, 4:05 pm)
[PATCH 57/70] tty-usb-mct-u232: Coding style, Alan Cox, (Fri Jun 20, 4:05 pm)
[PATCH 56/70] kobil_sct: Fix ioctls, Alan Cox, (Fri Jun 20, 4:05 pm)
[PATCH 55/70] tty-usb-kobil-sct: Coding style, Alan Cox, (Fri Jun 20, 4:05 pm)
[PATCH 53/70] tty-usb-kl5kusb105: Coding style, Alan Cox, (Fri Jun 20, 4:05 pm)
[PATCH 52/70] tty-usb-keyspan-pda: Coding style, Alan Cox, (Fri Jun 20, 4:04 pm)
[PATCH 50/70] tty-usb-keyspan: Coding style, Alan Cox, (Fri Jun 20, 4:04 pm)
[PATCH 47/70] tty-usb-ipw: Coding style, Alan Cox, (Fri Jun 20, 4:04 pm)
[PATCH 46/70] ipaq: Coding style, Alan Cox, (Fri Jun 20, 4:04 pm)
[PATCH 45/70] io_ti: Minor coding style, Alan Cox, (Fri Jun 20, 4:04 pm)
[PATCH 44/70] usb-serial: Coding style, Alan Cox, (Fri Jun 20, 4:03 pm)
[PATCH 42/70] tty-usb-io_edgeport: Coding style, Alan Cox, (Fri Jun 20, 4:03 pm)
[PATCH 41/70] tty-usb-visor: Coding style, Alan Cox, (Fri Jun 20, 4:03 pm)
[PATCH 40/70] tty-usb-hp4x: Fix overlong line, Alan Cox, (Fri Jun 20, 4:03 pm)
[PATCH 39/70] tty-usb-generic: Code cleanup, Alan Cox, (Fri Jun 20, 4:03 pm)
[PATCH 38/70] garmin_gps: Coding style, Alan Cox, (Fri Jun 20, 4:03 pm)
[PATCH 37/70] funsoft: Switch to linux/uaccess, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 36/70] ftdi_sio: Coding style, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 35/70] empeg: Coding style, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 34/70] digi_acceleport: coding style, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 32/70] cypress_m8: coding style, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 31/70] cyberjack: Coding style, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 30/70] cp2101: coding style, Alan Cox, (Fri Jun 20, 4:02 pm)
[PATCH 29/70] tty-usb-console: Fix termios, Alan Cox, (Fri Jun 20, 4:01 pm)
[PATCH 27/70] usb-serial-bus: tidy coding style, Alan Cox, (Fri Jun 20, 4:01 pm)
[PATCH 26/70] belkin_sa: clean up code, Alan Cox, (Fri Jun 20, 4:01 pm)
[PATCH 24/70] whiteheat: coding style, Alan Cox, (Fri Jun 20, 4:01 pm)
[PATCH 22/70] tty: add more tty_port fields, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 20/70] cyclades: use tty_port, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 19/70] tty: Clean up tiocmset, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 18/70] synclink: use tty_port, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 17/70] stallion: use tty_port, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 16/70] serial: use tty_port, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 15/70] rocket: use tty_port, Alan Cox, (Fri Jun 20, 4:00 pm)
[PATCH 14/70] mxser: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 13/70] moxa: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 12/70] istallion: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 11/70] isicom: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 10/70] riscom8: remove bogus checks, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 09/70] riscom8: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 08/70] gs: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 07/70] esp: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 06/70] epca: use tty_port, Alan Cox, (Fri Jun 20, 3:59 pm)
[PATCH 05/70] tty.h: clean up, Alan Cox, (Fri Jun 20, 3:58 pm)
[PATCH 02/70] drivers/char/rio/: remove VCS tags, Alan Cox, (Fri Jun 20, 3:58 pm)
[PATCH 01/70] tty: Ldisc revamp, Alan Cox, (Fri Jun 20, 3:58 pm)
Re: [PATCH 01/70] tty: Ldisc revamp, Louis Rilling, (Mon Jun 23, 9:39 am)
Re: [PATCH 01/70] tty: Ldisc revamp, Alan Cox, (Mon Jun 23, 10:11 am)