diff options
-rw-r--r-- | Documentation/serial/driver | 6 | ||||
-rw-r--r-- | drivers/tty/serial/serial_core.c | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/Documentation/serial/driver b/Documentation/serial/driver index ba64e4b892e9..c415b0ef4493 100644 --- a/Documentation/serial/driver +++ b/Documentation/serial/driver | |||
@@ -59,7 +59,9 @@ The core driver uses the info->tmpbuf_sem lock to prevent multi-threaded | |||
59 | access to the info->tmpbuf bouncebuffer used for port writes. | 59 | access to the info->tmpbuf bouncebuffer used for port writes. |
60 | 60 | ||
61 | The port_sem semaphore is used to protect against ports being added/ | 61 | The port_sem semaphore is used to protect against ports being added/ |
62 | removed or reconfigured at inappropriate times. | 62 | removed or reconfigured at inappropriate times. Since v2.6.27, this |
63 | semaphore has been the 'mutex' member of the tty_port struct, and | ||
64 | commonly referred to as the port mutex (or port->mutex). | ||
63 | 65 | ||
64 | 66 | ||
65 | uart_ops | 67 | uart_ops |
@@ -248,7 +250,7 @@ hardware. | |||
248 | Other flags may be used (eg, xon/xoff characters) if your | 250 | Other flags may be used (eg, xon/xoff characters) if your |
249 | hardware supports hardware "soft" flow control. | 251 | hardware supports hardware "soft" flow control. |
250 | 252 | ||
251 | Locking: none. | 253 | Locking: caller holds port->mutex |
252 | Interrupts: caller dependent. | 254 | Interrupts: caller dependent. |
253 | This call must not sleep | 255 | This call must not sleep |
254 | 256 | ||
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 9d142972ee2d..e31d56159aee 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -436,7 +436,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud) | |||
436 | 436 | ||
437 | EXPORT_SYMBOL(uart_get_divisor); | 437 | EXPORT_SYMBOL(uart_get_divisor); |
438 | 438 | ||
439 | /* FIXME: Consistent locking policy */ | 439 | /* Caller holds port mutex */ |
440 | static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, | 440 | static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, |
441 | struct ktermios *old_termios) | 441 | struct ktermios *old_termios) |
442 | { | 442 | { |
@@ -1173,11 +1173,15 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, | |||
1173 | break; | 1173 | break; |
1174 | 1174 | ||
1175 | case TIOCSSERIAL: | 1175 | case TIOCSSERIAL: |
1176 | down_write(&tty->termios_rwsem); | ||
1176 | ret = uart_set_info_user(tty, state, uarg); | 1177 | ret = uart_set_info_user(tty, state, uarg); |
1178 | up_write(&tty->termios_rwsem); | ||
1177 | break; | 1179 | break; |
1178 | 1180 | ||
1179 | case TIOCSERCONFIG: | 1181 | case TIOCSERCONFIG: |
1182 | down_write(&tty->termios_rwsem); | ||
1180 | ret = uart_do_autoconfig(tty, state); | 1183 | ret = uart_do_autoconfig(tty, state); |
1184 | up_write(&tty->termios_rwsem); | ||
1181 | break; | 1185 | break; |
1182 | 1186 | ||
1183 | case TIOCSERGWILD: /* obsolete */ | 1187 | case TIOCSERGWILD: /* obsolete */ |
@@ -1278,7 +1282,9 @@ static void uart_set_termios(struct tty_struct *tty, | |||
1278 | return; | 1282 | return; |
1279 | } | 1283 | } |
1280 | 1284 | ||
1285 | mutex_lock(&state->port.mutex); | ||
1281 | uart_change_speed(tty, state, old_termios); | 1286 | uart_change_speed(tty, state, old_termios); |
1287 | mutex_unlock(&state->port.mutex); | ||
1282 | /* reload cflag from termios; port driver may have overriden flags */ | 1288 | /* reload cflag from termios; port driver may have overriden flags */ |
1283 | cflag = tty->termios.c_cflag; | 1289 | cflag = tty->termios.c_cflag; |
1284 | 1290 | ||