提交 01bd730d 编写于 作者: J Jiri Slaby 提交者: Greg Kroah-Hartman

TTY: amiserial/simserial, use flags from tty_port

This changes flags' type to ulong which is appropriate for all the
set/clear_bits performed in the drivers..
Signed-off-by: NJiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 12c80354
...@@ -448,7 +448,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) ...@@ -448,7 +448,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
{ {
unsigned long flags; unsigned long flags;
if (!(info->flags & ASYNC_INITIALIZED)) if (!(info->tport.flags & ASYNC_INITIALIZED))
return; return;
#ifdef SIMSERIAL_DEBUG #ifdef SIMSERIAL_DEBUG
...@@ -468,7 +468,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) ...@@ -468,7 +468,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
set_bit(TTY_IO_ERROR, &tty->flags); set_bit(TTY_IO_ERROR, &tty->flags);
info->flags &= ~ASYNC_INITIALIZED; info->tport.flags &= ~ASYNC_INITIALIZED;
} }
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -523,7 +523,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -523,7 +523,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
local_irq_restore(flags); local_irq_restore(flags);
return; return;
} }
info->flags |= ASYNC_CLOSING; info->tport.flags |= ASYNC_CLOSING;
local_irq_restore(flags); local_irq_restore(flags);
/* /*
...@@ -539,7 +539,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -539,7 +539,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
schedule_timeout_interruptible(info->tport.close_delay); schedule_timeout_interruptible(info->tport.close_delay);
wake_up_interruptible(&info->tport.open_wait); wake_up_interruptible(&info->tport.open_wait);
} }
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); info->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->tport.close_wait); wake_up_interruptible(&info->tport.close_wait);
} }
...@@ -563,12 +563,12 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -563,12 +563,12 @@ static void rs_hangup(struct tty_struct *tty)
#endif #endif
rs_flush_buffer(tty); rs_flush_buffer(tty);
if (info->flags & ASYNC_CLOSING) if (info->tport.flags & ASYNC_CLOSING)
return; return;
shutdown(tty, info); shutdown(tty, info);
info->tport.count = 0; info->tport.count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE; info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
info->tport.tty = NULL; info->tport.tty = NULL;
wake_up_interruptible(&info->tport.open_wait); wake_up_interruptible(&info->tport.open_wait);
} }
...@@ -576,6 +576,7 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -576,6 +576,7 @@ static void rs_hangup(struct tty_struct *tty)
static int startup(struct tty_struct *tty, struct serial_state *state) static int startup(struct tty_struct *tty, struct serial_state *state)
{ {
struct tty_port *port = &state->tport;
unsigned long flags; unsigned long flags;
int retval=0; int retval=0;
unsigned long page; unsigned long page;
...@@ -586,7 +587,7 @@ static int startup(struct tty_struct *tty, struct serial_state *state) ...@@ -586,7 +587,7 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
local_irq_save(flags); local_irq_save(flags);
if (state->flags & ASYNC_INITIALIZED) { if (port->flags & ASYNC_INITIALIZED) {
free_page(page); free_page(page);
goto errout; goto errout;
} }
...@@ -630,16 +631,16 @@ static int startup(struct tty_struct *tty, struct serial_state *state) ...@@ -630,16 +631,16 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
/* /*
* Set up the tty->alt_speed kludge * Set up the tty->alt_speed kludge
*/ */
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600; tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
tty->alt_speed = 115200; tty->alt_speed = 115200;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
tty->alt_speed = 230400; tty->alt_speed = 230400;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800; tty->alt_speed = 460800;
state->flags |= ASYNC_INITIALIZED; port->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags); local_irq_restore(flags);
return 0; return 0;
...@@ -669,7 +670,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -669,7 +670,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
#ifdef SIMSERIAL_DEBUG #ifdef SIMSERIAL_DEBUG
printk("rs_open %s, count = %d\n", tty->name, info->tport.count); printk("rs_open %s, count = %d\n", tty->name, info->tport.count);
#endif #endif
tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
if (!tmp_buf) { if (!tmp_buf) {
page = get_zeroed_page(GFP_KERNEL); page = get_zeroed_page(GFP_KERNEL);
...@@ -684,11 +685,11 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -684,11 +685,11 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
/* /*
* 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) || (info->flags & ASYNC_CLOSING)) { if (tty_hung_up_p(filp) || (info->tport.flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING) if (info->tport.flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->tport.close_wait); interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART #ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ? return ((info->tport.flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
#else #else
return -EAGAIN; return -EAGAIN;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s) tty->name, (info->tport.flags), serial_driver->refcount,info->count,tty->count,s)
#else #else
#define DBG_CNT(s) #define DBG_CNT(s)
#endif #endif
...@@ -296,7 +296,7 @@ static void receive_chars(struct serial_state *info) ...@@ -296,7 +296,7 @@ static void receive_chars(struct serial_state *info)
printk("handling break...."); printk("handling break....");
#endif #endif
flag = TTY_BREAK; flag = TTY_BREAK;
if (info->flags & ASYNC_SAK) if (info->tport.flags & ASYNC_SAK)
do_SAK(tty); do_SAK(tty);
} else if (status & UART_LSR_PE) } else if (status & UART_LSR_PE)
flag = TTY_PARITY; flag = TTY_PARITY;
...@@ -377,7 +377,7 @@ static void check_modem_status(struct serial_state *info) ...@@ -377,7 +377,7 @@ 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->flags & ASYNC_HARDPPS_CD) && if ((info->tport.flags & ASYNC_HARDPPS_CD) &&
!(status & SER_DCD)) !(status & SER_DCD))
hardpps(); hardpps();
#endif #endif
...@@ -387,7 +387,7 @@ static void check_modem_status(struct serial_state *info) ...@@ -387,7 +387,7 @@ static void check_modem_status(struct serial_state *info)
wake_up_interruptible(&info->tport.delta_msr_wait); wake_up_interruptible(&info->tport.delta_msr_wait);
} }
if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) { if ((info->tport.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");
...@@ -402,7 +402,7 @@ static void check_modem_status(struct serial_state *info) ...@@ -402,7 +402,7 @@ static void check_modem_status(struct serial_state *info)
tty_hangup(info->tport.tty); tty_hangup(info->tport.tty);
} }
} }
if (info->flags & ASYNC_CTS_FLOW) { if (info->tport.flags & ASYNC_CTS_FLOW) {
if (info->tport.tty->hw_stopped) { if (info->tport.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))
...@@ -503,6 +503,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id) ...@@ -503,6 +503,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
static int startup(struct tty_struct *tty, struct serial_state *info) static int startup(struct tty_struct *tty, struct serial_state *info)
{ {
struct tty_port *port = &info->tport;
unsigned long flags; unsigned long flags;
int retval=0; int retval=0;
unsigned long page; unsigned long page;
...@@ -513,7 +514,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info) ...@@ -513,7 +514,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
local_irq_save(flags); local_irq_save(flags);
if (info->flags & ASYNC_INITIALIZED) { if (port->flags & ASYNC_INITIALIZED) {
free_page(page); free_page(page);
goto errout; goto errout;
} }
...@@ -560,13 +561,13 @@ static int startup(struct tty_struct *tty, struct serial_state *info) ...@@ -560,13 +561,13 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
/* /*
* Set up the tty->alt_speed kludge * Set up the tty->alt_speed kludge
*/ */
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600; tty->alt_speed = 57600;
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
tty->alt_speed = 115200; tty->alt_speed = 115200;
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
tty->alt_speed = 230400; tty->alt_speed = 230400;
if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800; tty->alt_speed = 460800;
/* /*
...@@ -574,7 +575,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info) ...@@ -574,7 +575,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
*/ */
change_speed(tty, info, NULL); change_speed(tty, info, NULL);
info->flags |= ASYNC_INITIALIZED; port->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags); local_irq_restore(flags);
return 0; return 0;
...@@ -592,7 +593,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) ...@@ -592,7 +593,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
unsigned long flags; unsigned long flags;
struct serial_state *state; struct serial_state *state;
if (!(info->flags & ASYNC_INITIALIZED)) if (!(info->tport.flags & ASYNC_INITIALIZED))
return; return;
state = info; state = info;
...@@ -633,7 +634,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) ...@@ -633,7 +634,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
set_bit(TTY_IO_ERROR, &tty->flags); set_bit(TTY_IO_ERROR, &tty->flags);
info->flags &= ~ASYNC_INITIALIZED; info->tport.flags &= ~ASYNC_INITIALIZED;
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -645,6 +646,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info) ...@@ -645,6 +646,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
static void change_speed(struct tty_struct *tty, struct serial_state *info, static void change_speed(struct tty_struct *tty, struct serial_state *info,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
struct tty_port *port = &info->tport;
int quot = 0, baud_base, baud; int quot = 0, baud_base, baud;
unsigned cflag, cval = 0; unsigned cflag, cval = 0;
int bits; int bits;
...@@ -675,8 +677,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info, ...@@ -675,8 +677,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
if (!baud) if (!baud)
baud = 9600; /* B0 transition handled in rs_set_termios */ baud = 9600; /* B0 transition handled in rs_set_termios */
baud_base = info->baud_base; baud_base = info->baud_base;
if (baud == 38400 && if (baud == 38400 && (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
quot = info->custom_divisor; quot = info->custom_divisor;
else { else {
if (baud == 134) if (baud == 134)
...@@ -694,7 +695,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info, ...@@ -694,7 +695,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
if (!baud) if (!baud)
baud = 9600; baud = 9600;
if (baud == 38400 && if (baud == 38400 &&
((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
quot = info->custom_divisor; quot = info->custom_divisor;
else { else {
if (baud == 134) if (baud == 134)
...@@ -713,17 +714,17 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info, ...@@ -713,17 +714,17 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
/* CTS flow control flag and modem status interrupts */ /* CTS flow control flag and modem status interrupts */
info->IER &= ~UART_IER_MSI; info->IER &= ~UART_IER_MSI;
if (info->flags & ASYNC_HARDPPS_CD) if (port->flags & ASYNC_HARDPPS_CD)
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
info->flags |= ASYNC_CTS_FLOW; port->flags |= ASYNC_CTS_FLOW;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
} else } else
info->flags &= ~ASYNC_CTS_FLOW; port->flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL) if (cflag & CLOCAL)
info->flags &= ~ASYNC_CHECK_CD; port->flags &= ~ASYNC_CHECK_CD;
else { else {
info->flags |= ASYNC_CHECK_CD; port->flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI; info->IER |= UART_IER_MSI;
} }
/* TBD: /* TBD:
...@@ -1019,7 +1020,7 @@ static int get_serial_info(struct serial_state *state, ...@@ -1019,7 +1020,7 @@ static int get_serial_info(struct serial_state *state,
tmp.line = state->line; tmp.line = state->line;
tmp.port = state->port; tmp.port = state->port;
tmp.irq = state->irq; tmp.irq = state->irq;
tmp.flags = state->flags; tmp.flags = state->tport.flags;
tmp.xmit_fifo_size = state->xmit_fifo_size; tmp.xmit_fifo_size = state->xmit_fifo_size;
tmp.baud_base = state->baud_base; tmp.baud_base = state->baud_base;
tmp.close_delay = state->tport.close_delay; tmp.close_delay = state->tport.close_delay;
...@@ -1034,6 +1035,7 @@ static int get_serial_info(struct serial_state *state, ...@@ -1034,6 +1035,7 @@ static int get_serial_info(struct serial_state *state,
static int set_serial_info(struct tty_struct *tty, struct serial_state *state, static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
struct serial_struct __user * new_info) struct serial_struct __user * new_info)
{ {
struct tty_port *port = &state->tport;
struct serial_struct new_serial; struct serial_struct new_serial;
bool change_spd; bool change_spd;
int retval = 0; int retval = 0;
...@@ -1042,7 +1044,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, ...@@ -1042,7 +1044,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
return -EFAULT; return -EFAULT;
tty_lock(); tty_lock();
change_spd = ((new_serial.flags ^ state->flags) & ASYNC_SPD_MASK) || change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
new_serial.custom_divisor != state->custom_divisor; new_serial.custom_divisor != state->custom_divisor;
if (new_serial.irq != state->irq || new_serial.port != state->port || if (new_serial.irq != state->irq || new_serial.port != state->port ||
new_serial.xmit_fifo_size != state->xmit_fifo_size) { new_serial.xmit_fifo_size != state->xmit_fifo_size) {
...@@ -1052,12 +1054,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, ...@@ -1052,12 +1054,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
if (!serial_isroot()) { if (!serial_isroot()) {
if ((new_serial.baud_base != state->baud_base) || if ((new_serial.baud_base != state->baud_base) ||
(new_serial.close_delay != state->tport.close_delay) || (new_serial.close_delay != port->close_delay) ||
(new_serial.xmit_fifo_size != state->xmit_fifo_size) || (new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
((new_serial.flags & ~ASYNC_USR_MASK) != ((new_serial.flags & ~ASYNC_USR_MASK) !=
(state->flags & ~ASYNC_USR_MASK))) (port->flags & ~ASYNC_USR_MASK)))
return -EPERM; return -EPERM;
state->flags = ((state->flags & ~ASYNC_USR_MASK) | port->flags = ((port->flags & ~ASYNC_USR_MASK) |
(new_serial.flags & ASYNC_USR_MASK)); (new_serial.flags & ASYNC_USR_MASK));
state->custom_divisor = new_serial.custom_divisor; state->custom_divisor = new_serial.custom_divisor;
goto check_and_exit; goto check_and_exit;
...@@ -1074,23 +1076,23 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, ...@@ -1074,23 +1076,23 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
*/ */
state->baud_base = new_serial.baud_base; state->baud_base = new_serial.baud_base;
state->flags = ((state->flags & ~ASYNC_FLAGS) | port->flags = ((port->flags & ~ASYNC_FLAGS) |
(new_serial.flags & ASYNC_FLAGS)); (new_serial.flags & ASYNC_FLAGS));
state->custom_divisor = new_serial.custom_divisor; state->custom_divisor = new_serial.custom_divisor;
state->tport.close_delay = new_serial.close_delay * HZ/100; port->close_delay = new_serial.close_delay * HZ/100;
state->tport.closing_wait = new_serial.closing_wait * HZ/100; port->closing_wait = new_serial.closing_wait * HZ/100;
tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit: check_and_exit:
if (state->flags & ASYNC_INITIALIZED) { if (port->flags & ASYNC_INITIALIZED) {
if (change_spd) { if (change_spd) {
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600; tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
tty->alt_speed = 115200; tty->alt_speed = 115200;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
tty->alt_speed = 230400; tty->alt_speed = 230400;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800; tty->alt_speed = 460800;
change_speed(tty, state, NULL); change_speed(tty, state, NULL);
} }
...@@ -1407,7 +1409,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -1407,7 +1409,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
local_irq_restore(flags); local_irq_restore(flags);
return; return;
} }
state->flags |= ASYNC_CLOSING; state->tport.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.
...@@ -1422,7 +1424,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -1422,7 +1424,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->flags & ASYNC_INITIALIZED) { if (state->tport.flags & ASYNC_INITIALIZED) {
/* disable receive interrupts */ /* disable receive interrupts */
custom.intena = IF_RBF; custom.intena = IF_RBF;
mb(); mb();
...@@ -1449,7 +1451,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -1449,7 +1451,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
} }
wake_up_interruptible(&state->tport.open_wait); wake_up_interruptible(&state->tport.open_wait);
} }
state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); state->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&state->tport.close_wait); wake_up_interruptible(&state->tport.close_wait);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -1530,7 +1532,7 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -1530,7 +1532,7 @@ static void rs_hangup(struct tty_struct *tty)
rs_flush_buffer(tty); rs_flush_buffer(tty);
shutdown(tty, info); shutdown(tty, info);
info->tport.count = 0; info->tport.count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE; info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
info->tport.tty = NULL; info->tport.tty = NULL;
wake_up_interruptible(&info->tport.open_wait); wake_up_interruptible(&info->tport.open_wait);
} }
...@@ -1548,6 +1550,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1548,6 +1550,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#else #else
struct wait_queue wait = { current, NULL }; struct wait_queue wait = { current, NULL };
#endif #endif
struct tty_port *port = &info->tport;
int retval; int retval;
int do_clocal = 0, extra_count = 0; int do_clocal = 0, extra_count = 0;
unsigned long flags; unsigned long flags;
...@@ -1557,11 +1560,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1557,11 +1560,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
* 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->flags & ASYNC_CLOSING)) { (port->flags & ASYNC_CLOSING)) {
if (info->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->flags & ASYNC_HUP_NOTIFY) ? return ((port->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
#else #else
return -EAGAIN; return -EAGAIN;
...@@ -1574,7 +1577,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1574,7 +1577,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
*/ */
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->flags |= ASYNC_NORMAL_ACTIVE; port->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
...@@ -1584,23 +1587,23 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1584,23 +1587,23 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
/* /*
* Block waiting for the carrier detect and the line to become * Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in * free (i.e., not in use by the callout). While we are in
* this loop, info->tport.count is dropped by one, so that * this loop, port->count is dropped by one, so that
* rs_close() knows when to free things. We restore it upon * rs_close() knows when to free things. We restore it upon
* exit, either normal or abnormal. * exit, either normal or abnormal.
*/ */
retval = 0; retval = 0;
add_wait_queue(&info->tport.open_wait, &wait); add_wait_queue(&port->open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: ttys%d, count = %d\n", printk("block_til_ready before block: ttys%d, count = %d\n",
info->line, info->tport.count); info->line, port->count);
#endif #endif
local_irq_save(flags); local_irq_save(flags);
if (!tty_hung_up_p(filp)) { if (!tty_hung_up_p(filp)) {
extra_count = 1; extra_count = 1;
info->tport.count--; port->count--;
} }
local_irq_restore(flags); local_irq_restore(flags);
info->tport.blocked_open++; port->blocked_open++;
while (1) { while (1) {
local_irq_save(flags); local_irq_save(flags);
if (tty->termios->c_cflag & CBAUD) if (tty->termios->c_cflag & CBAUD)
...@@ -1608,9 +1611,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1608,9 +1611,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
local_irq_restore(flags); local_irq_restore(flags);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) || if (tty_hung_up_p(filp) ||
!(info->flags & ASYNC_INITIALIZED)) { !(port->flags & ASYNC_INITIALIZED)) {
#ifdef SERIAL_DO_RESTART #ifdef SERIAL_DO_RESTART
if (info->flags & ASYNC_HUP_NOTIFY) if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN; retval = -EAGAIN;
else else
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
...@@ -1619,7 +1622,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1619,7 +1622,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#endif #endif
break; break;
} }
if (!(info->flags & ASYNC_CLOSING) && if (!(port->flags & ASYNC_CLOSING) &&
(do_clocal || (!(ciab.pra & SER_DCD)) )) (do_clocal || (!(ciab.pra & SER_DCD)) ))
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
...@@ -1628,24 +1631,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1628,24 +1631,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
} }
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready blocking: ttys%d, count = %d\n", printk("block_til_ready blocking: ttys%d, count = %d\n",
info->line, info->tport.count); info->line, port->count);
#endif #endif
tty_unlock(); tty_unlock();
schedule(); schedule();
tty_lock(); tty_lock();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&info->tport.open_wait, &wait); remove_wait_queue(&port->open_wait, &wait);
if (extra_count) if (extra_count)
info->tport.count++; port->count++;
info->tport.blocked_open--; port->blocked_open--;
#ifdef SERIAL_DEBUG_OPEN #ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: ttys%d, count = %d\n", printk("block_til_ready after blocking: ttys%d, count = %d\n",
info->line, info->tport.count); info->line, port->count);
#endif #endif
if (retval) if (retval)
return retval; return retval;
info->flags |= ASYNC_NORMAL_ACTIVE; port->flags |= ASYNC_NORMAL_ACTIVE;
return 0; return 0;
} }
...@@ -1670,17 +1673,17 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -1670,17 +1673,17 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
#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->flags & ASYNC_LOW_LATENCY) ? 1 : 0; tty->low_latency = (info->tport.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->flags & ASYNC_CLOSING)) { (info->tport.flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING) if (info->tport.flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->tport.close_wait); interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART #ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ? return ((info->tport.flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS); -EAGAIN : -ERESTARTSYS);
#else #else
return -EAGAIN; return -EAGAIN;
...@@ -1723,7 +1726,7 @@ static inline void line_info(struct seq_file *m, struct serial_state *state) ...@@ -1723,7 +1726,7 @@ static inline void line_info(struct seq_file *m, struct serial_state *state)
local_irq_save(flags); local_irq_save(flags);
status = ciab.pra; status = ciab.pra;
control = (state->flags & ASYNC_INITIALIZED) ? state->MCR : status; control = (state->tport.flags & ASYNC_INITIALIZED) ? state->MCR : status;
local_irq_restore(flags); local_irq_restore(flags);
stat_buf[0] = 0; stat_buf[0] = 0;
......
...@@ -30,7 +30,6 @@ struct serial_state { ...@@ -30,7 +30,6 @@ struct serial_state {
int baud_base; int baud_base;
unsigned long port; unsigned long port;
int irq; int irq;
int flags;
int type; int type;
int line; int line;
int xmit_fifo_size; int xmit_fifo_size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册