aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-05-05 14:32:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-16 20:32:21 -0400
commit0693196fe7bbb5e6cafd255dfce91ff6d10bc18f (patch)
tree9cc67b83f7757647adea0629a3adf94c05865354
parent3b9561e9d9b88eca9d4ed6aab025dec2eeeed501 (diff)
USB: serial: add wait_until_sent operation
Add wait_until_sent operation which can be used to wait for hardware buffers to drain. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/usb-serial.c17
-rw-r--r--include/linux/usb/serial.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index cf75beb1251b..31d27686151f 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -375,6 +375,22 @@ static int serial_chars_in_buffer(struct tty_struct *tty)
375 return count; 375 return count;
376} 376}
377 377
378static void serial_wait_until_sent(struct tty_struct *tty, int timeout)
379{
380 struct usb_serial_port *port = tty->driver_data;
381 struct usb_serial *serial = port->serial;
382
383 dev_dbg(tty->dev, "%s\n", __func__);
384
385 if (!port->serial->type->wait_until_sent)
386 return;
387
388 mutex_lock(&serial->disc_mutex);
389 if (!serial->disconnected)
390 port->serial->type->wait_until_sent(tty, timeout);
391 mutex_unlock(&serial->disc_mutex);
392}
393
378static void serial_throttle(struct tty_struct *tty) 394static void serial_throttle(struct tty_struct *tty)
379{ 395{
380 struct usb_serial_port *port = tty->driver_data; 396 struct usb_serial_port *port = tty->driver_data;
@@ -1191,6 +1207,7 @@ static const struct tty_operations serial_ops = {
1191 .unthrottle = serial_unthrottle, 1207 .unthrottle = serial_unthrottle,
1192 .break_ctl = serial_break, 1208 .break_ctl = serial_break,
1193 .chars_in_buffer = serial_chars_in_buffer, 1209 .chars_in_buffer = serial_chars_in_buffer,
1210 .wait_until_sent = serial_wait_until_sent,
1194 .tiocmget = serial_tiocmget, 1211 .tiocmget = serial_tiocmget,
1195 .tiocmset = serial_tiocmset, 1212 .tiocmset = serial_tiocmset,
1196 .get_icount = serial_get_icount, 1213 .get_icount = serial_get_icount,
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index b9b0f7b4e43b..afbb7eeaac5f 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -268,6 +268,7 @@ struct usb_serial_driver {
268 struct usb_serial_port *port, struct ktermios *old); 268 struct usb_serial_port *port, struct ktermios *old);
269 void (*break_ctl)(struct tty_struct *tty, int break_state); 269 void (*break_ctl)(struct tty_struct *tty, int break_state);
270 int (*chars_in_buffer)(struct tty_struct *tty); 270 int (*chars_in_buffer)(struct tty_struct *tty);
271 void (*wait_until_sent)(struct tty_struct *tty, long timeout);
271 void (*throttle)(struct tty_struct *tty); 272 void (*throttle)(struct tty_struct *tty);
272 void (*unthrottle)(struct tty_struct *tty); 273 void (*unthrottle)(struct tty_struct *tty);
273 int (*tiocmget)(struct tty_struct *tty); 274 int (*tiocmget)(struct tty_struct *tty);