TTY: amiserial, define local tty_port pointer

And use it to make the code more readable.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jiri Slaby 2012-03-05 14:52:43 +01:00 коммит произвёл Greg Kroah-Hartman
Родитель 6e9ebcfa20
Коммит 7188dc202a
1 изменённых файлов: 42 добавлений и 39 удалений

Просмотреть файл

@ -361,6 +361,7 @@ static void transmit_chars(struct serial_state *info)
static void check_modem_status(struct serial_state *info) static void check_modem_status(struct serial_state *info)
{ {
struct tty_port *port = &info->tport;
unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
unsigned char dstatus; unsigned char dstatus;
struct async_icount *icount; struct async_icount *icount;
@ -377,45 +378,45 @@ static void check_modem_status(struct serial_state *info)
if (dstatus & SER_DCD) { if (dstatus & SER_DCD) {
icount->dcd++; icount->dcd++;
#ifdef CONFIG_HARD_PPS #ifdef CONFIG_HARD_PPS
if ((info->tport.flags & ASYNC_HARDPPS_CD) && if ((port->flags & ASYNC_HARDPPS_CD) &&
!(status & SER_DCD)) !(status & SER_DCD))
hardpps(); hardpps();
#endif #endif
} }
if (dstatus & SER_CTS) if (dstatus & SER_CTS)
icount->cts++; icount->cts++;
wake_up_interruptible(&info->tport.delta_msr_wait); wake_up_interruptible(&port->delta_msr_wait);
} }
if ((info->tport.flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) { if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line, printk("ttyS%d CD now %s...", info->line,
(!(status & SER_DCD)) ? "on" : "off"); (!(status & SER_DCD)) ? "on" : "off");
#endif #endif
if (!(status & SER_DCD)) if (!(status & SER_DCD))
wake_up_interruptible(&info->tport.open_wait); wake_up_interruptible(&port->open_wait);
else { else {
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("doing serial hangup..."); printk("doing serial hangup...");
#endif #endif
if (info->tport.tty) if (port->tty)
tty_hangup(info->tport.tty); tty_hangup(port->tty);
} }
} }
if (info->tport.flags & ASYNC_CTS_FLOW) { if (port->flags & ASYNC_CTS_FLOW) {
if (info->tport.tty->hw_stopped) { if (port->tty->hw_stopped) {
if (!(status & SER_CTS)) { if (!(status & SER_CTS)) {
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
printk("CTS tx start..."); printk("CTS tx start...");
#endif #endif
info->tport.tty->hw_stopped = 0; port->tty->hw_stopped = 0;
info->IER |= UART_IER_THRI; info->IER |= UART_IER_THRI;
custom.intena = IF_SETCLR | IF_TBE; custom.intena = IF_SETCLR | IF_TBE;
mb(); mb();
/* set a pending Tx Interrupt, transmitter should restart now */ /* set a pending Tx Interrupt, transmitter should restart now */
custom.intreq = IF_SETCLR | IF_TBE; custom.intreq = IF_SETCLR | IF_TBE;
mb(); mb();
tty_wakeup(info->tport.tty); tty_wakeup(port->tty);
return; return;
} }
} else { } else {
@ -423,7 +424,7 @@ static void check_modem_status(struct serial_state *info)
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
printk("CTS tx stop..."); printk("CTS tx stop...");
#endif #endif
info->tport.tty->hw_stopped = 1; port->tty->hw_stopped = 1;
info->IER &= ~UART_IER_THRI; info->IER &= ~UART_IER_THRI;
/* disable Tx interrupt and remove any pending interrupts */ /* disable Tx interrupt and remove any pending interrupts */
custom.intena = IF_TBE; custom.intena = IF_TBE;
@ -1371,6 +1372,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
static void rs_close(struct tty_struct *tty, struct file * filp) static void rs_close(struct tty_struct *tty, struct file * filp)
{ {
struct serial_state *state = tty->driver_data; struct serial_state *state = tty->driver_data;
struct tty_port *port = &state->tport;
unsigned long flags; unsigned long flags;
if (!state || serial_paranoia_check(state, tty->name, "rs_close")) if (!state || serial_paranoia_check(state, tty->name, "rs_close"))
@ -1385,38 +1387,38 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
} }
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("rs_close ttys%d, count = %d\n", state->line, state->tport.count); printk("rs_close ttys%d, count = %d\n", state->line, port->count);
#endif #endif
if ((tty->count == 1) && (state->tport.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. state->tport.count should always * structure will be freed. port->count should always
* be one in these conditions. If it's greater than * be one in these conditions. If it's greater than
* one, we've got real problems, since it means the * one, we've got real problems, since it means the
* serial port won't be shutdown. * serial port won't be shutdown.
*/ */
printk("rs_close: bad serial port count; tty->count is 1, " printk("rs_close: bad serial port count; tty->count is 1, "
"state->tport.count is %d\n", state->tport.count); "port->count is %d\n", state->tport.count);
state->tport.count = 1; port->count = 1;
} }
if (--state->tport.count < 0) { if (--port->count < 0) {
printk("rs_close: bad serial port count for ttys%d: %d\n", printk("rs_close: bad serial port count for ttys%d: %d\n",
state->line, state->tport.count); state->line, port->count);
state->tport.count = 0; port->count = 0;
} }
if (state->tport.count) { if (port->count) {
DBG_CNT("before DEC-2"); DBG_CNT("before DEC-2");
local_irq_restore(flags); local_irq_restore(flags);
return; return;
} }
state->tport.flags |= ASYNC_CLOSING; port->flags |= ASYNC_CLOSING;
/* /*
* Now we wait for the transmit buffer to clear; and we notify * Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters. * the line discipline to only process XON/XOFF characters.
*/ */
tty->closing = 1; tty->closing = 1;
if (state->tport.closing_wait != ASYNC_CLOSING_WAIT_NONE) if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, state->tport.closing_wait); tty_wait_until_sent(tty, port->closing_wait);
/* /*
* At this point we stop accepting input. To do this, we * At this point we stop accepting input. To do this, we
* disable the receive line status interrupts, and tell the * disable the receive line status interrupts, and tell the
@ -1424,7 +1426,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* line status register. * line status register.
*/ */
state->read_status_mask &= ~UART_LSR_DR; state->read_status_mask &= ~UART_LSR_DR;
if (state->tport.flags & ASYNC_INITIALIZED) { if (port->flags & ASYNC_INITIALIZED) {
/* disable receive interrupts */ /* disable receive interrupts */
custom.intena = IF_RBF; custom.intena = IF_RBF;
mb(); mb();
@ -1444,15 +1446,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty_ldisc_flush(tty); tty_ldisc_flush(tty);
tty->closing = 0; tty->closing = 0;
state->tport.tty = NULL; port->tty = NULL;
if (state->tport.blocked_open) { if (port->blocked_open) {
if (state->tport.close_delay) { if (port->close_delay) {
msleep_interruptible(jiffies_to_msecs(state->tport.close_delay)); msleep_interruptible(jiffies_to_msecs(port->close_delay));
} }
wake_up_interruptible(&state->tport.open_wait); wake_up_interruptible(&port->open_wait);
} }
state->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&state->tport.close_wait); wake_up_interruptible(&port->close_wait);
local_irq_restore(flags); local_irq_restore(flags);
} }
@ -1661,29 +1663,30 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
static int rs_open(struct tty_struct *tty, struct file * filp) static int rs_open(struct tty_struct *tty, struct file * filp)
{ {
struct serial_state *info = rs_table + tty->index; struct serial_state *info = rs_table + tty->index;
struct tty_port *port = &info->tport;
int retval; int retval;
info->tport.count++; port->count++;
info->tport.tty = tty; port->tty = tty;
tty->driver_data = info; tty->driver_data = info;
tty->port = &info->tport; tty->port = port;
if (serial_paranoia_check(info, tty->name, "rs_open")) if (serial_paranoia_check(info, tty->name, "rs_open"))
return -ENODEV; return -ENODEV;
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("rs_open %s, count = %d\n", tty->name, info->count); printk("rs_open %s, count = %d\n", tty->name, info->count);
#endif #endif
tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/* /*
* If the port is the middle of closing, bail out now * If the port is the middle of closing, bail out now
*/ */
if (tty_hung_up_p(filp) || if (tty_hung_up_p(filp) ||
(info->tport.flags & ASYNC_CLOSING)) { (port->flags & ASYNC_CLOSING)) {
if (info->tport.flags & ASYNC_CLOSING) if (port->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->tport.close_wait); interruptible_sleep_on(&port->close_wait);
#ifdef SERIAL_DO_RESTART #ifdef SERIAL_DO_RESTART
return ((info->tport.flags & ASYNC_HUP_NOTIFY) ? return ((port->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
#else #else
return -EAGAIN; return -EAGAIN;