[PATCH 13/20] tty: serial - fix tty referencing in set_ldisc

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alan Cox
Date: Wednesday, May 5, 2010 - 3:02 am

Pass down the ldisc number so that the drivers don't have to peek into the
tty object themselves. This lets us get rid of another case of back referencing
port to tty which we don't want (because of races versus hangup/close).

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

 drivers/serial/bfin_5xx.c    |    7 ++-----
 drivers/serial/serial_core.c |    2 +-
 include/linux/serial_core.h  |    2 +-
 3 files changed, 4 insertions(+), 7 deletions(-)


diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 96f7e74..e0d25ca 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -952,15 +952,12 @@ bfin_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
  * Enable the IrDA function if tty->ldisc.num is N_IRDA.
  * In other cases, disable IrDA function.
  */
-static void bfin_serial_set_ldisc(struct uart_port *port)
+static void bfin_serial_set_ldisc(struct uart_port *port, int ld)
 {
 	int line = port->line;
 	unsigned short val;
 
-	if (line >= port->state->port.tty->driver->num)
-		return;
-
-	switch (port->state->port.tty->termios->c_line) {
+	switch (ld) {
 	case N_IRDA:
 		val = UART_GET_GCTL(&bfin_serial_ports[line]);
 		val |= (IREN | RPOLC);
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 12ee7e0..570dca2 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1194,7 +1194,7 @@ static void uart_set_ldisc(struct tty_struct *tty)
 	struct uart_port *uport = state->uart_port;
 
 	if (uport->ops->set_ldisc)
-		uport->ops->set_ldisc(uport);
+		uport->ops->set_ldisc(uport, tty->termios->c_line);
 }
 
 static void uart_set_termios(struct tty_struct *tty,
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index ad83996..5c4cbe6 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -216,7 +216,7 @@ struct uart_ops {
 	void		(*flush_buffer)(struct uart_port *);
 	void		(*set_termios)(struct uart_port *, struct ktermios *new,
 				       struct ktermios *old);
-	void		(*set_ldisc)(struct uart_port *);
+	void		(*set_ldisc)(struct uart_port *, int new);
 	void		(*pm)(struct uart_port *, unsigned int state,
 			      unsigned int oldstate);
 	int		(*set_wake)(struct uart_port *, unsigned int state);

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

Messages in current thread:
[PATCH 01/20] stallion: prune lock_kernel calls, Alan Cox, (Wed May 5, 3:01 am)
[PATCH 03/20] riscom8: kill use of lock_kernel, Alan Cox, (Wed May 5, 3:01 am)
[PATCH 04/20] isicom: kill off the BKL, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 05/20] rocket: kill BKL, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 06/20] synclink: kill the big kernel lock, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 07/20] cyclades: Kill off BKL usage, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 08/20] epca: Kill the big kernel lock, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 09/20] specialix; Kill the BKL, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 10/20] synclink: reworking locking a bit, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 13/20] tty: serial - fix tty referencing in set_ldisc, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 14/20] vc: Locking clean up, Alan Cox, (Wed May 5, 3:02 am)
[PATCH 15/20] tty: Make vt's have a tty_port, Alan Cox, (Wed May 5, 3:03 am)
[PATCH 18/20] serial: add port helpers, Alan Cox, (Wed May 5, 3:03 am)
[PATCH 20/20] serial: Use block_til_ready helper, Alan Cox, (Wed May 5, 3:03 am)