diff options
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index cf75beb1251b..5f6b1ff9d29e 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 | ||
372 | count = serial->type->chars_in_buffer(tty); | ||
373 | mutex_unlock(&serial->disc_mutex); | ||
374 | 367 | ||
375 | return count; | 368 | return serial->type->chars_in_buffer(tty); |
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; | ||
380 | |||
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) |
@@ -399,7 +408,7 @@ static int serial_ioctl(struct tty_struct *tty, | |||
399 | unsigned int cmd, unsigned long arg) | 408 | unsigned int cmd, unsigned long arg) |
400 | { | 409 | { |
401 | struct usb_serial_port *port = tty->driver_data; | 410 | struct usb_serial_port *port = tty->driver_data; |
402 | int retval = -ENODEV; | 411 | int retval = -ENOIOCTLCMD; |
403 | 412 | ||
404 | dev_dbg(tty->dev, "%s - cmd 0x%.4x\n", __func__, cmd); | 413 | dev_dbg(tty->dev, "%s - cmd 0x%.4x\n", __func__, cmd); |
405 | 414 | ||
@@ -411,8 +420,6 @@ static int serial_ioctl(struct tty_struct *tty, | |||
411 | default: | 420 | default: |
412 | if (port->serial->type->ioctl) | 421 | if (port->serial->type->ioctl) |
413 | retval = port->serial->type->ioctl(tty, cmd, arg); | 422 | retval = port->serial->type->ioctl(tty, cmd, arg); |
414 | else | ||
415 | retval = -ENOIOCTLCMD; | ||
416 | } | 423 | } |
417 | 424 | ||
418 | return retval; | 425 | return retval; |
@@ -1191,6 +1198,7 @@ static const struct tty_operations serial_ops = { | |||
1191 | .unthrottle = serial_unthrottle, | 1198 | .unthrottle = serial_unthrottle, |
1192 | .break_ctl = serial_break, | 1199 | .break_ctl = serial_break, |
1193 | .chars_in_buffer = serial_chars_in_buffer, | 1200 | .chars_in_buffer = serial_chars_in_buffer, |
1201 | .wait_until_sent = serial_wait_until_sent, | ||
1194 | .tiocmget = serial_tiocmget, | 1202 | .tiocmget = serial_tiocmget, |
1195 | .tiocmset = serial_tiocmset, | 1203 | .tiocmset = serial_tiocmset, |
1196 | .get_icount = serial_get_icount, | 1204 | .get_icount = serial_get_icount, |
@@ -1316,6 +1324,8 @@ static void usb_serial_operations_init(struct usb_serial_driver *device) | |||
1316 | set_to_generic_if_null(device, close); | 1324 | set_to_generic_if_null(device, close); |
1317 | set_to_generic_if_null(device, write_room); | 1325 | set_to_generic_if_null(device, write_room); |
1318 | set_to_generic_if_null(device, chars_in_buffer); | 1326 | set_to_generic_if_null(device, chars_in_buffer); |
1327 | if (device->tx_empty) | ||
1328 | set_to_generic_if_null(device, wait_until_sent); | ||
1319 | set_to_generic_if_null(device, read_bulk_callback); | 1329 | set_to_generic_if_null(device, read_bulk_callback); |
1320 | set_to_generic_if_null(device, write_bulk_callback); | 1330 | set_to_generic_if_null(device, write_bulk_callback); |
1321 | set_to_generic_if_null(device, process_read_urb); | 1331 | set_to_generic_if_null(device, process_read_urb); |