TTY: isdn, define local tty_port

In some functions we use tty_port much. So let us have a local pointer
to that variable instead of having info->port all over the code.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Karsten Keil <isdn@linux-pingi.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby 2012-04-02 13:53:59 +02:00 committed by Greg Kroah-Hartman
parent 82e46b3190
commit 265d6f00e7

View file

@ -1003,20 +1003,21 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine)
static void static void
isdn_tty_change_speed(modem_info *info) isdn_tty_change_speed(modem_info *info)
{ {
struct tty_port *port = &info->port;
uint cflag, uint cflag,
cval, cval,
quot; quot;
int i; int i;
if (!info->port.tty || !info->port.tty->termios) if (!port->tty || !port->tty->termios)
return; return;
cflag = info->port.tty->termios->c_cflag; cflag = port->tty->termios->c_cflag;
quot = i = cflag & CBAUD; quot = i = cflag & CBAUD;
if (i & CBAUDEX) { if (i & CBAUDEX) {
i &= ~CBAUDEX; i &= ~CBAUDEX;
if (i < 1 || i > 2) if (i < 1 || i > 2)
info->port.tty->termios->c_cflag &= ~CBAUDEX; port->tty->termios->c_cflag &= ~CBAUDEX;
else else
i += 15; i += 15;
} }
@ -1046,13 +1047,13 @@ isdn_tty_change_speed(modem_info *info)
/* CTS flow control flag and modem status interrupts */ /* CTS flow control flag and modem status interrupts */
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
info->port.flags |= ASYNC_CTS_FLOW; port->flags |= ASYNC_CTS_FLOW;
} else } else
info->port.flags &= ~ASYNC_CTS_FLOW; port->flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->port.flags &= ~ASYNC_CHECK_CD; port->flags &= ~ASYNC_CHECK_CD;
else { else {
info->port.flags |= ASYNC_CHECK_CD; port->flags |= ASYNC_CHECK_CD;
} }
} }
@ -1487,6 +1488,7 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
static int static int
isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info) isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info)
{ {
struct tty_port *port = &info->port;
DECLARE_WAITQUEUE(wait, NULL); DECLARE_WAITQUEUE(wait, NULL);
int do_clocal = 0; int do_clocal = 0;
int retval; int retval;
@ -1496,11 +1498,11 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *
* until it's done, and then try again. * until it's done, and then try again.
*/ */
if (tty_hung_up_p(filp) || if (tty_hung_up_p(filp) ||
(info->port.flags & ASYNC_CLOSING)) { (port->flags & ASYNC_CLOSING)) {
if (info->port.flags & ASYNC_CLOSING) if (port->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->port.close_wait); interruptible_sleep_on(&port->close_wait);
#ifdef MODEM_DO_RESTART #ifdef MODEM_DO_RESTART
if (info->port.flags & ASYNC_HUP_NOTIFY) if (port->flags & ASYNC_HUP_NOTIFY)
return -EAGAIN; return -EAGAIN;
else else
return -ERESTARTSYS; return -ERESTARTSYS;
@ -1514,7 +1516,7 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *
*/ */
if ((filp->f_flags & O_NONBLOCK) || if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) { (tty->flags & (1 << TTY_IO_ERROR))) {
info->port.flags |= ASYNC_NORMAL_ACTIVE; port->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
if (tty->termios->c_cflag & CLOCAL) if (tty->termios->c_cflag & CLOCAL)
@ -1527,20 +1529,20 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *
* exit, either normal or abnormal. * exit, either normal or abnormal.
*/ */
retval = 0; retval = 0;
add_wait_queue(&info->port.open_wait, &wait); add_wait_queue(&port->open_wait, &wait);
#ifdef ISDN_DEBUG_MODEM_OPEN #ifdef ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG "isdn_tty_block_til_ready before block: ttyi%d, count = %d\n", printk(KERN_DEBUG "isdn_tty_block_til_ready before block: ttyi%d, count = %d\n",
info->line, info->count); info->line, info->count);
#endif #endif
if (!(tty_hung_up_p(filp))) if (!(tty_hung_up_p(filp)))
info->port.count--; port->count--;
info->port.blocked_open++; port->blocked_open++;
while (1) { while (1) {
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) || if (tty_hung_up_p(filp) ||
!(info->port.flags & ASYNC_INITIALIZED)) { !(port->flags & ASYNC_INITIALIZED)) {
#ifdef MODEM_DO_RESTART #ifdef MODEM_DO_RESTART
if (info->port.flags & ASYNC_HUP_NOTIFY) if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN; retval = -EAGAIN;
else else
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
@ -1549,7 +1551,7 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *
#endif #endif
break; break;
} }
if (!(info->port.flags & ASYNC_CLOSING) && if (!(port->flags & ASYNC_CLOSING) &&
(do_clocal || (info->msr & UART_MSR_DCD))) { (do_clocal || (info->msr & UART_MSR_DCD))) {
break; break;
} }
@ -1559,22 +1561,22 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *
} }
#ifdef ISDN_DEBUG_MODEM_OPEN #ifdef ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG "isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n", printk(KERN_DEBUG "isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n",
info->line, info->port.count); info->line, port->count);
#endif #endif
schedule(); schedule();
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(&info->port.open_wait, &wait); remove_wait_queue(&port->open_wait, &wait);
if (!tty_hung_up_p(filp)) if (!tty_hung_up_p(filp))
info->port.count++; port->count++;
info->port.blocked_open--; port->blocked_open--;
#ifdef ISDN_DEBUG_MODEM_OPEN #ifdef ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG "isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n", printk(KERN_DEBUG "isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n",
info->line, info->port.count); info->line, port->count);
#endif #endif
if (retval) if (retval)
return retval; return retval;
info->port.flags |= ASYNC_NORMAL_ACTIVE; port->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
@ -1587,20 +1589,22 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *
static int static int
isdn_tty_open(struct tty_struct *tty, struct file *filp) isdn_tty_open(struct tty_struct *tty, struct file *filp)
{ {
struct tty_port *port;
modem_info *info; modem_info *info;
int retval; int retval;
info = &dev->mdm.info[tty->index]; info = &dev->mdm.info[tty->index];
if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open")) if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open"))
return -ENODEV; return -ENODEV;
port = &info->port;
#ifdef ISDN_DEBUG_MODEM_OPEN #ifdef ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
info->port.count); port->count);
#endif #endif
info->port.count++; port->count++;
tty->driver_data = info; tty->driver_data = info;
info->port.tty = tty; port->tty = tty;
tty->port = &info->port; tty->port = port;
/* /*
* Start up serial port * Start up serial port
*/ */
@ -1632,6 +1636,7 @@ static void
isdn_tty_close(struct tty_struct *tty, struct file *filp) isdn_tty_close(struct tty_struct *tty, struct file *filp)
{ {
modem_info *info = (modem_info *) tty->driver_data; modem_info *info = (modem_info *) tty->driver_data;
struct tty_port *port = &info->port;
ulong timeout; ulong timeout;
if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close"))
@ -1642,7 +1647,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
#endif #endif
return; return;
} }
if ((tty->count == 1) && (info->port.count != 1)) { if ((tty->count == 1) && (port->count != 1)) {
/* /*
* Uh, oh. tty->count is 1, which means that the tty * Uh, oh. tty->count is 1, which means that the tty
* structure will be freed. Info->count should always * structure will be freed. Info->count should always
@ -1651,21 +1656,21 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
* serial port won't be shutdown. * serial port won't be shutdown.
*/ */
printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
"info->count is %d\n", info->port.count); "info->count is %d\n", port->count);
info->port.count = 1; port->count = 1;
} }
if (--info->port.count < 0) { if (--port->count < 0) {
printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n", printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
info->line, info->port.count); info->line, port->count);
info->port.count = 0; port->count = 0;
} }
if (info->port.count) { if (port->count) {
#ifdef ISDN_DEBUG_MODEM_OPEN #ifdef ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
#endif #endif
return; return;
} }
info->port.flags |= ASYNC_CLOSING; port->flags |= ASYNC_CLOSING;
tty->closing = 1; tty->closing = 1;
/* /*
@ -1674,7 +1679,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
* interrupt driver to stop checking the data ready bit in the * interrupt driver to stop checking the data ready bit in the
* line status register. * line status register.
*/ */
if (info->port.flags & ASYNC_INITIALIZED) { if (port->flags & ASYNC_INITIALIZED) {
tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */
/* /*
* Before we drop DTR, make sure the UART transmitter * Before we drop DTR, make sure the UART transmitter
@ -1692,15 +1697,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
isdn_tty_shutdown(info); isdn_tty_shutdown(info);
isdn_tty_flush_buffer(tty); isdn_tty_flush_buffer(tty);
tty_ldisc_flush(tty); tty_ldisc_flush(tty);
info->port.tty = NULL; port->tty = NULL;
info->ncarrier = 0; info->ncarrier = 0;
tty->closing = 0; tty->closing = 0;
if (info->port.blocked_open) { if (port->blocked_open) {
msleep_interruptible(500); msleep_interruptible(500);
wake_up_interruptible(&info->port.open_wait); wake_up_interruptible(&port->open_wait);
} }
info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
wake_up_interruptible(&info->port.close_wait); wake_up_interruptible(&port->close_wait);
#ifdef ISDN_DEBUG_MODEM_OPEN #ifdef ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG "isdn_tty_close normal exit\n"); printk(KERN_DEBUG "isdn_tty_close normal exit\n");
#endif #endif
@ -1713,14 +1718,15 @@ static void
isdn_tty_hangup(struct tty_struct *tty) isdn_tty_hangup(struct tty_struct *tty)
{ {
modem_info *info = (modem_info *) tty->driver_data; modem_info *info = (modem_info *) tty->driver_data;
struct tty_port *port = &info->port;
if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
return; return;
isdn_tty_shutdown(info); isdn_tty_shutdown(info);
info->port.count = 0; port->count = 0;
info->port.flags &= ~ASYNC_NORMAL_ACTIVE; port->flags &= ~ASYNC_NORMAL_ACTIVE;
info->port.tty = NULL; port->tty = NULL;
wake_up_interruptible(&info->port.open_wait); wake_up_interruptible(&port->open_wait);
} }
/* This routine initializes all emulator-data. /* This routine initializes all emulator-data.