提交 91312cdb 编写于 作者: A Alan Cox 提交者: Live-CD User

serial: move count into the tty_port version

Remove more stuff from the serial special case code
Signed-off-by: NAlan Cox <alan@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 46d57a44
...@@ -52,7 +52,7 @@ static struct lock_class_key port_lock_key; ...@@ -52,7 +52,7 @@ static struct lock_class_key port_lock_key;
#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
#define uart_users(state) ((state)->count + (state)->port.blocked_open) #define uart_users(state) ((state)->port.count + (state)->port.blocked_open)
#ifdef CONFIG_SERIAL_CORE_CONSOLE #ifdef CONFIG_SERIAL_CORE_CONSOLE
#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line) #define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
...@@ -694,7 +694,7 @@ static int uart_set_info(struct uart_state *state, ...@@ -694,7 +694,7 @@ static int uart_set_info(struct uart_state *state,
USF_CLOSING_WAIT_NONE : new_serial.closing_wait * 10; USF_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
/* /*
* This semaphore protects state->count. It is also * This semaphore protects port->count. It is also
* very useful to prevent opens. Also, take the * very useful to prevent opens. Also, take the
* port configuration semaphore to make sure that a * port configuration semaphore to make sure that a
* module insertion/removal doesn't change anything * module insertion/removal doesn't change anything
...@@ -1272,24 +1272,24 @@ static void uart_close(struct tty_struct *tty, struct file *filp) ...@@ -1272,24 +1272,24 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
if (tty_hung_up_p(filp)) if (tty_hung_up_p(filp))
goto done; goto done;
if ((tty->count == 1) && (state->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->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(KERN_ERR "uart_close: bad serial port count; tty->count is 1, " printk(KERN_ERR "uart_close: bad serial port count; tty->count is 1, "
"state->count is %d\n", state->count); "port->count is %d\n", port->count);
state->count = 1; port->count = 1;
} }
if (--state->count < 0) { if (--port->count < 0) {
printk(KERN_ERR "uart_close: bad serial port count for %s: %d\n", printk(KERN_ERR "uart_close: bad serial port count for %s: %d\n",
tty->name, state->count); tty->name, port->count);
state->count = 0; port->count = 0;
} }
if (state->count) if (port->count)
goto done; goto done;
/* /*
...@@ -1421,7 +1421,7 @@ static void uart_hangup(struct tty_struct *tty) ...@@ -1421,7 +1421,7 @@ static void uart_hangup(struct tty_struct *tty)
if (state->flags & UIF_NORMAL_ACTIVE) { if (state->flags & UIF_NORMAL_ACTIVE) {
uart_flush_buffer(tty); uart_flush_buffer(tty);
uart_shutdown(state); uart_shutdown(state);
state->count = 0; port->count = 0;
state->flags &= ~UIF_NORMAL_ACTIVE; state->flags &= ~UIF_NORMAL_ACTIVE;
port->tty = NULL; port->tty = NULL;
wake_up_interruptible(&port->open_wait); wake_up_interruptible(&port->open_wait);
...@@ -1478,7 +1478,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) ...@@ -1478,7 +1478,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
unsigned int mctrl; unsigned int mctrl;
port->blocked_open++; port->blocked_open++;
state->count--; port->count--;
add_wait_queue(&port->open_wait, &wait); add_wait_queue(&port->open_wait, &wait);
while (1) { while (1) {
...@@ -1539,7 +1539,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) ...@@ -1539,7 +1539,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state)
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&port->open_wait, &wait); remove_wait_queue(&port->open_wait, &wait);
state->count++; port->count++;
port->blocked_open--; port->blocked_open--;
if (signal_pending(current)) if (signal_pending(current))
...@@ -1562,7 +1562,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) ...@@ -1562,7 +1562,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
goto err; goto err;
} }
state->count++; state->port.count++;
if (!state->uart_port || state->uart_port->flags & UPF_DEAD) { if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
ret = -ENXIO; ret = -ENXIO;
goto err_unlock; goto err_unlock;
...@@ -1570,7 +1570,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) ...@@ -1570,7 +1570,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line)
return state; return state;
err_unlock: err_unlock:
state->count--; state->port.count--;
mutex_unlock(&state->mutex); mutex_unlock(&state->mutex);
err: err:
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -1590,6 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) ...@@ -1590,6 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
{ {
struct uart_driver *drv = (struct uart_driver *)tty->driver->driver_state; struct uart_driver *drv = (struct uart_driver *)tty->driver->driver_state;
struct uart_state *state; struct uart_state *state;
struct tty_port *port;
int retval, line = tty->index; int retval, line = tty->index;
BUG_ON(!kernel_locked()); BUG_ON(!kernel_locked());
...@@ -1617,6 +1618,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) ...@@ -1617,6 +1618,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
retval = PTR_ERR(state); retval = PTR_ERR(state);
goto fail; goto fail;
} }
port = &state->port;
/* /*
* Once we set tty->driver_data here, we are guaranteed that * Once we set tty->driver_data here, we are guaranteed that
...@@ -1627,14 +1629,14 @@ static int uart_open(struct tty_struct *tty, struct file *filp) ...@@ -1627,14 +1629,14 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
state->uart_port->state = state; state->uart_port->state = state;
tty->low_latency = (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0; tty->low_latency = (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0;
tty->alt_speed = 0; tty->alt_speed = 0;
state->port.tty = tty; port->tty = tty;
/* /*
* If the port is in the middle of closing, bail out now. * If the port is in the middle of closing, bail out now.
*/ */
if (tty_hung_up_p(filp)) { if (tty_hung_up_p(filp)) {
retval = -EAGAIN; retval = -EAGAIN;
state->count--; port->count--;
mutex_unlock(&state->mutex); mutex_unlock(&state->mutex);
goto fail; goto fail;
} }
...@@ -1642,7 +1644,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) ...@@ -1642,7 +1644,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
/* /*
* Make sure the device is in D0 state. * Make sure the device is in D0 state.
*/ */
if (state->count == 1) if (port->count == 1)
uart_change_pm(state, 0); uart_change_pm(state, 0);
/* /*
......
...@@ -354,7 +354,6 @@ struct uart_state { ...@@ -354,7 +354,6 @@ struct uart_state {
#define USF_CLOSING_WAIT_INF (0) #define USF_CLOSING_WAIT_INF (0)
#define USF_CLOSING_WAIT_NONE (~0U) #define USF_CLOSING_WAIT_NONE (~0U)
int count;
int pm_state; int pm_state;
struct circ_buf xmit; struct circ_buf xmit;
uif_t flags; uif_t flags;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册