diff options
author | Alan Cox <alan@linux.intel.com> | 2009-09-19 16:13:29 -0400 |
---|---|---|
committer | Live-CD User <linux@linux.site> | 2009-09-19 16:13:29 -0400 |
commit | 91312cdb4fcd832341e425f74f49938e0503c929 (patch) | |
tree | d05e4ea773026363df0c9cddf37b465f44125a0f | |
parent | 46d57a449aa13d9c6adcc9d1dbc7b9a0ecfb69d8 (diff) |
serial: move count into the tty_port version
Remove more stuff from the serial special case code
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/serial/serial_core.c | 38 | ||||
-rw-r--r-- | include/linux/serial_core.h | 1 |
2 files changed, 20 insertions, 19 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 0ffefb3f1d8f..4af3364dd811 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -52,7 +52,7 @@ static struct lock_class_key port_lock_key; | |||
52 | 52 | ||
53 | #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) | 53 | #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) |
54 | 54 | ||
55 | #define uart_users(state) ((state)->count + (state)->port.blocked_open) | 55 | #define uart_users(state) ((state)->port.count + (state)->port.blocked_open) |
56 | 56 | ||
57 | #ifdef CONFIG_SERIAL_CORE_CONSOLE | 57 | #ifdef CONFIG_SERIAL_CORE_CONSOLE |
58 | #define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line) | 58 | #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 | USF_CLOSING_WAIT_NONE : new_serial.closing_wait * 10; | 694 | USF_CLOSING_WAIT_NONE : new_serial.closing_wait * 10; |
695 | 695 | ||
696 | /* | 696 | /* |
697 | * This semaphore protects state->count. It is also | 697 | * This semaphore protects port->count. It is also |
698 | * very useful to prevent opens. Also, take the | 698 | * very useful to prevent opens. Also, take the |
699 | * port configuration semaphore to make sure that a | 699 | * port configuration semaphore to make sure that a |
700 | * module insertion/removal doesn't change anything | 700 | * module insertion/removal doesn't change anything |
@@ -1272,24 +1272,24 @@ static void uart_close(struct tty_struct *tty, struct file *filp) | |||
1272 | if (tty_hung_up_p(filp)) | 1272 | if (tty_hung_up_p(filp)) |
1273 | goto done; | 1273 | goto done; |
1274 | 1274 | ||
1275 | if ((tty->count == 1) && (state->count != 1)) { | 1275 | if ((tty->count == 1) && (port->count != 1)) { |
1276 | /* | 1276 | /* |
1277 | * Uh, oh. tty->count is 1, which means that the tty | 1277 | * Uh, oh. tty->count is 1, which means that the tty |
1278 | * structure will be freed. state->count should always | 1278 | * structure will be freed. port->count should always |
1279 | * be one in these conditions. If it's greater than | 1279 | * be one in these conditions. If it's greater than |
1280 | * one, we've got real problems, since it means the | 1280 | * one, we've got real problems, since it means the |
1281 | * serial port won't be shutdown. | 1281 | * serial port won't be shutdown. |
1282 | */ | 1282 | */ |
1283 | printk(KERN_ERR "uart_close: bad serial port count; tty->count is 1, " | 1283 | printk(KERN_ERR "uart_close: bad serial port count; tty->count is 1, " |
1284 | "state->count is %d\n", state->count); | 1284 | "port->count is %d\n", port->count); |
1285 | state->count = 1; | 1285 | port->count = 1; |
1286 | } | 1286 | } |
1287 | if (--state->count < 0) { | 1287 | if (--port->count < 0) { |
1288 | printk(KERN_ERR "uart_close: bad serial port count for %s: %d\n", | 1288 | printk(KERN_ERR "uart_close: bad serial port count for %s: %d\n", |
1289 | tty->name, state->count); | 1289 | tty->name, port->count); |
1290 | state->count = 0; | 1290 | port->count = 0; |
1291 | } | 1291 | } |
1292 | if (state->count) | 1292 | if (port->count) |
1293 | goto done; | 1293 | goto done; |
1294 | 1294 | ||
1295 | /* | 1295 | /* |
@@ -1421,7 +1421,7 @@ static void uart_hangup(struct tty_struct *tty) | |||
1421 | if (state->flags & UIF_NORMAL_ACTIVE) { | 1421 | if (state->flags & UIF_NORMAL_ACTIVE) { |
1422 | uart_flush_buffer(tty); | 1422 | uart_flush_buffer(tty); |
1423 | uart_shutdown(state); | 1423 | uart_shutdown(state); |
1424 | state->count = 0; | 1424 | port->count = 0; |
1425 | state->flags &= ~UIF_NORMAL_ACTIVE; | 1425 | state->flags &= ~UIF_NORMAL_ACTIVE; |
1426 | port->tty = NULL; | 1426 | port->tty = NULL; |
1427 | wake_up_interruptible(&port->open_wait); | 1427 | wake_up_interruptible(&port->open_wait); |
@@ -1478,7 +1478,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) | |||
1478 | unsigned int mctrl; | 1478 | unsigned int mctrl; |
1479 | 1479 | ||
1480 | port->blocked_open++; | 1480 | port->blocked_open++; |
1481 | state->count--; | 1481 | port->count--; |
1482 | 1482 | ||
1483 | add_wait_queue(&port->open_wait, &wait); | 1483 | add_wait_queue(&port->open_wait, &wait); |
1484 | while (1) { | 1484 | while (1) { |
@@ -1539,7 +1539,7 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) | |||
1539 | set_current_state(TASK_RUNNING); | 1539 | set_current_state(TASK_RUNNING); |
1540 | remove_wait_queue(&port->open_wait, &wait); | 1540 | remove_wait_queue(&port->open_wait, &wait); |
1541 | 1541 | ||
1542 | state->count++; | 1542 | port->count++; |
1543 | port->blocked_open--; | 1543 | port->blocked_open--; |
1544 | 1544 | ||
1545 | if (signal_pending(current)) | 1545 | if (signal_pending(current)) |
@@ -1562,7 +1562,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1562 | goto err; | 1562 | goto err; |
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | state->count++; | 1565 | state->port.count++; |
1566 | if (!state->uart_port || state->uart_port->flags & UPF_DEAD) { | 1566 | if (!state->uart_port || state->uart_port->flags & UPF_DEAD) { |
1567 | ret = -ENXIO; | 1567 | ret = -ENXIO; |
1568 | goto err_unlock; | 1568 | goto err_unlock; |
@@ -1570,7 +1570,7 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1570 | return state; | 1570 | return state; |
1571 | 1571 | ||
1572 | err_unlock: | 1572 | err_unlock: |
1573 | state->count--; | 1573 | state->port.count--; |
1574 | mutex_unlock(&state->mutex); | 1574 | mutex_unlock(&state->mutex); |
1575 | err: | 1575 | err: |
1576 | return ERR_PTR(ret); | 1576 | return ERR_PTR(ret); |
@@ -1590,6 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1590 | { | 1590 | { |
1591 | struct uart_driver *drv = (struct uart_driver *)tty->driver->driver_state; | 1591 | struct uart_driver *drv = (struct uart_driver *)tty->driver->driver_state; |
1592 | struct uart_state *state; | 1592 | struct uart_state *state; |
1593 | struct tty_port *port; | ||
1593 | int retval, line = tty->index; | 1594 | int retval, line = tty->index; |
1594 | 1595 | ||
1595 | BUG_ON(!kernel_locked()); | 1596 | BUG_ON(!kernel_locked()); |
@@ -1617,6 +1618,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1617 | retval = PTR_ERR(state); | 1618 | retval = PTR_ERR(state); |
1618 | goto fail; | 1619 | goto fail; |
1619 | } | 1620 | } |
1621 | port = &state->port; | ||
1620 | 1622 | ||
1621 | /* | 1623 | /* |
1622 | * Once we set tty->driver_data here, we are guaranteed that | 1624 | * 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 | state->uart_port->state = state; | 1629 | state->uart_port->state = state; |
1628 | tty->low_latency = (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0; | 1630 | tty->low_latency = (state->uart_port->flags & UPF_LOW_LATENCY) ? 1 : 0; |
1629 | tty->alt_speed = 0; | 1631 | tty->alt_speed = 0; |
1630 | state->port.tty = tty; | 1632 | port->tty = tty; |
1631 | 1633 | ||
1632 | /* | 1634 | /* |
1633 | * If the port is in the middle of closing, bail out now. | 1635 | * If the port is in the middle of closing, bail out now. |
1634 | */ | 1636 | */ |
1635 | if (tty_hung_up_p(filp)) { | 1637 | if (tty_hung_up_p(filp)) { |
1636 | retval = -EAGAIN; | 1638 | retval = -EAGAIN; |
1637 | state->count--; | 1639 | port->count--; |
1638 | mutex_unlock(&state->mutex); | 1640 | mutex_unlock(&state->mutex); |
1639 | goto fail; | 1641 | goto fail; |
1640 | } | 1642 | } |
@@ -1642,7 +1644,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) | |||
1642 | /* | 1644 | /* |
1643 | * Make sure the device is in D0 state. | 1645 | * Make sure the device is in D0 state. |
1644 | */ | 1646 | */ |
1645 | if (state->count == 1) | 1647 | if (port->count == 1) |
1646 | uart_change_pm(state, 0); | 1648 | uart_change_pm(state, 0); |
1647 | 1649 | ||
1648 | /* | 1650 | /* |
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index fd11d4d5a571..63ad90966db2 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h | |||
@@ -354,7 +354,6 @@ struct uart_state { | |||
354 | #define USF_CLOSING_WAIT_INF (0) | 354 | #define USF_CLOSING_WAIT_INF (0) |
355 | #define USF_CLOSING_WAIT_NONE (~0U) | 355 | #define USF_CLOSING_WAIT_NONE (~0U) |
356 | 356 | ||
357 | int count; | ||
358 | int pm_state; | 357 | int pm_state; |
359 | struct circ_buf xmit; | 358 | struct circ_buf xmit; |
360 | uif_t flags; | 359 | uif_t flags; |