diff options
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index cf75beb1251b..4753c005cfb6 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -359,20 +359,29 @@ static int serial_chars_in_buffer(struct tty_struct *tty) | |||
359 | { | 359 | { |
360 | struct usb_serial_port *port = tty->driver_data; | 360 | struct usb_serial_port *port = tty->driver_data; |
361 | struct usb_serial *serial = port->serial; | 361 | struct usb_serial *serial = port->serial; |
362 | int count = 0; | ||
363 | 362 | ||
364 | dev_dbg(tty->dev, "%s\n", __func__); | 363 | dev_dbg(tty->dev, "%s\n", __func__); |
365 | 364 | ||
366 | mutex_lock(&serial->disc_mutex); | ||
367 | /* if the device was unplugged then any remaining characters | ||
368 | fell out of the connector ;) */ | ||
369 | if (serial->disconnected) | 365 | if (serial->disconnected) |
370 | count = 0; | 366 | return 0; |
371 | else | 367 | |
372 | count = serial->type->chars_in_buffer(tty); | 368 | return serial->type->chars_in_buffer(tty); |
373 | mutex_unlock(&serial->disc_mutex); | 369 | } |
370 | |||
371 | static void serial_wait_until_sent(struct tty_struct *tty, int timeout) | ||
372 | { | ||
373 | struct usb_serial_port *port = tty->driver_data; | ||
374 | struct usb_serial *serial = port->serial; | ||
375 | |||
376 | dev_dbg(tty->dev, "%s\n", __func__); | ||
377 | |||
378 | if (!port->serial->type->wait_until_sent) | ||
379 | return; | ||
374 | 380 | ||
375 | return count; | 381 | mutex_lock(&serial->disc_mutex); |
382 | if (!serial->disconnected) | ||
383 | port->serial->type->wait_until_sent(tty, timeout); | ||
384 | mutex_unlock(&serial->disc_mutex); | ||
376 | } | 385 | } |
377 | 386 | ||
378 | static void serial_throttle(struct tty_struct *tty) | 387 | static void serial_throttle(struct tty_struct *tty) |
@@ -1191,6 +1200,7 @@ static const struct tty_operations serial_ops = { | |||
1191 | .unthrottle = serial_unthrottle, | 1200 | .unthrottle = serial_unthrottle, |
1192 | .break_ctl = serial_break, | 1201 | .break_ctl = serial_break, |
1193 | .chars_in_buffer = serial_chars_in_buffer, | 1202 | .chars_in_buffer = serial_chars_in_buffer, |
1203 | .wait_until_sent = serial_wait_until_sent, | ||
1194 | .tiocmget = serial_tiocmget, | 1204 | .tiocmget = serial_tiocmget, |
1195 | .tiocmset = serial_tiocmset, | 1205 | .tiocmset = serial_tiocmset, |
1196 | .get_icount = serial_get_icount, | 1206 | .get_icount = serial_get_icount, |
@@ -1316,6 +1326,8 @@ static void usb_serial_operations_init(struct usb_serial_driver *device) | |||
1316 | set_to_generic_if_null(device, close); | 1326 | set_to_generic_if_null(device, close); |
1317 | set_to_generic_if_null(device, write_room); | 1327 | set_to_generic_if_null(device, write_room); |
1318 | set_to_generic_if_null(device, chars_in_buffer); | 1328 | set_to_generic_if_null(device, chars_in_buffer); |
1329 | if (device->tx_empty) | ||
1330 | set_to_generic_if_null(device, wait_until_sent); | ||
1319 | set_to_generic_if_null(device, read_bulk_callback); | 1331 | set_to_generic_if_null(device, read_bulk_callback); |
1320 | set_to_generic_if_null(device, write_bulk_callback); | 1332 | set_to_generic_if_null(device, write_bulk_callback); |
1321 | set_to_generic_if_null(device, process_read_urb); | 1333 | set_to_generic_if_null(device, process_read_urb); |