Skip to content

Commit 0693196

Browse files
jhovoldgregkh
authored andcommitted
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>
1 parent 3b9561e commit 0693196

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎drivers/usb/serial/usb-serial.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,22 @@ static int serial_chars_in_buffer(struct tty_struct *tty)
375375
return count;
376376
}
377377

378+
static 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+
378394
static void serial_throttle(struct tty_struct *tty)
379395
{
380396
struct usb_serial_port *port = tty->driver_data;
@@ -1191,6 +1207,7 @@ static const struct tty_operations serial_ops = {
11911207
.unthrottle = serial_unthrottle,
11921208
.break_ctl = serial_break,
11931209
.chars_in_buffer = serial_chars_in_buffer,
1210+
.wait_until_sent = serial_wait_until_sent,
11941211
.tiocmget = serial_tiocmget,
11951212
.tiocmset = serial_tiocmset,
11961213
.get_icount = serial_get_icount,

‎include/linux/usb/serial.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ struct usb_serial_driver {
268268
struct usb_serial_port *port, struct ktermios *old);
269269
void (*break_ctl)(struct tty_struct *tty, int break_state);
270270
int (*chars_in_buffer)(struct tty_struct *tty);
271+
void (*wait_until_sent)(struct tty_struct *tty, long timeout);
271272
void (*throttle)(struct tty_struct *tty);
272273
void (*unthrottle)(struct tty_struct *tty);
273274
int (*tiocmget)(struct tty_struct *tty);

0 commit comments

Comments
 (0)