Commit 12c80354 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: amiserial/simserial, use count from tty_port

Nothing special. Just remove count from serial_state and change all
users to use tty_port.
Signed-off-by: default avatarJiri 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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 799be6ff
...@@ -500,26 +500,26 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -500,26 +500,26 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
return; return;
} }
#ifdef SIMSERIAL_DEBUG #ifdef SIMSERIAL_DEBUG
printk("rs_close ttys%d, count = %d\n", info->line, info->count); printk("rs_close ttys%d, count = %d\n", info->line, info->tport.count);
#endif #endif
if ((tty->count == 1) && (info->count != 1)) { if ((tty->count == 1) && (info->tport.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->tport.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(KERN_ERR "rs_close: bad serial port count; tty->count is 1, " printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
"info->count is %d\n", info->count); "info->tport.count is %d\n", info->tport.count);
info->count = 1; info->tport.count = 1;
} }
if (--info->count < 0) { if (--info->tport.count < 0) {
printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n", printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
info->line, info->count); info->line, info->tport.count);
info->count = 0; info->tport.count = 0;
} }
if (info->count) { if (info->tport.count) {
local_irq_restore(flags); local_irq_restore(flags);
return; return;
} }
...@@ -567,7 +567,7 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -567,7 +567,7 @@ static void rs_hangup(struct tty_struct *tty)
return; return;
shutdown(tty, info); shutdown(tty, info);
info->count = 0; info->tport.count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE; info->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);
...@@ -661,13 +661,13 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -661,13 +661,13 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
int retval; int retval;
unsigned long page; unsigned long page;
info->count++; info->tport.count++;
info->tport.tty = tty; info->tport.tty = tty;
tty->driver_data = info; tty->driver_data = info;
tty->port = &info->tport; tty->port = &info->tport;
#ifdef SIMSERIAL_DEBUG #ifdef SIMSERIAL_DEBUG
printk("rs_open %s, count = %d\n", tty->name, info->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->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
......
...@@ -1383,26 +1383,26 @@ static void rs_close(struct tty_struct *tty, struct file * filp) ...@@ -1383,26 +1383,26 @@ 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->count); printk("rs_close ttys%d, count = %d\n", state->line, state->tport.count);
#endif #endif
if ((tty->count == 1) && (state->count != 1)) { if ((tty->count == 1) && (state->tport.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->count should always * structure will be freed. state->tport.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->count is %d\n", state->count); "state->tport.count is %d\n", state->tport.count);
state->count = 1; state->tport.count = 1;
} }
if (--state->count < 0) { if (--state->tport.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->count); state->line, state->tport.count);
state->count = 0; state->tport.count = 0;
} }
if (state->count) { if (state->tport.count) {
DBG_CNT("before DEC-2"); DBG_CNT("before DEC-2");
local_irq_restore(flags); local_irq_restore(flags);
return; return;
...@@ -1529,7 +1529,7 @@ static void rs_hangup(struct tty_struct *tty) ...@@ -1529,7 +1529,7 @@ static void rs_hangup(struct tty_struct *tty)
rs_flush_buffer(tty); rs_flush_buffer(tty);
shutdown(tty, info); shutdown(tty, info);
info->count = 0; info->tport.count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE; info->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);
...@@ -1584,7 +1584,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1584,7 +1584,7 @@ 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->count is dropped by one, so that * this loop, info->tport.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.
*/ */
...@@ -1592,12 +1592,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1592,12 +1592,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
add_wait_queue(&info->tport.open_wait, &wait); add_wait_queue(&info->tport.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->count); info->line, info->tport.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->count--; info->tport.count--;
} }
local_irq_restore(flags); local_irq_restore(flags);
info->tport.blocked_open++; info->tport.blocked_open++;
...@@ -1628,7 +1628,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1628,7 +1628,7 @@ 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->count); info->line, info->tport.count);
#endif #endif
tty_unlock(); tty_unlock();
schedule(); schedule();
...@@ -1637,11 +1637,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, ...@@ -1637,11 +1637,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&info->tport.open_wait, &wait); remove_wait_queue(&info->tport.open_wait, &wait);
if (extra_count) if (extra_count)
info->count++; info->tport.count++;
info->tport.blocked_open--; info->tport.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->count); info->line, info->tport.count);
#endif #endif
if (retval) if (retval)
return retval; return retval;
...@@ -1660,7 +1660,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp) ...@@ -1660,7 +1660,7 @@ 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;
int retval; int retval;
info->count++; info->tport.count++;
info->tport.tty = tty; info->tport.tty = tty;
tty->driver_data = info; tty->driver_data = info;
tty->port = &info->tport; tty->port = &info->tport;
......
...@@ -35,7 +35,6 @@ struct serial_state { ...@@ -35,7 +35,6 @@ struct serial_state {
int line; int line;
int xmit_fifo_size; int xmit_fifo_size;
int custom_divisor; int custom_divisor;
int count;
struct async_icount icount; struct async_icount icount;
struct tty_port tport; struct tty_port tport;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment