Skip to content

Commit befefcd

Browse files
jhovoldgregkh
authored andcommitted
USB: serial: add generic get_icount implementation
Add generic get_icount implementation that subdrivers relying on the port interrupt counters can use. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c371de1 commit befefcd

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎drivers/usb/serial/generic.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,33 @@ int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg)
476476
}
477477
EXPORT_SYMBOL_GPL(usb_serial_generic_tiocmiwait);
478478

479+
int usb_serial_generic_get_icount(struct tty_struct *tty,
480+
struct serial_icounter_struct *icount)
481+
{
482+
struct usb_serial_port *port = tty->driver_data;
483+
struct async_icount cnow;
484+
unsigned long flags;
485+
486+
spin_lock_irqsave(&port->lock, flags);
487+
cnow = port->icount; /* atomic copy */
488+
spin_unlock_irqrestore(&port->lock, flags);
489+
490+
icount->cts = cnow.cts;
491+
icount->dsr = cnow.dsr;
492+
icount->rng = cnow.rng;
493+
icount->dcd = cnow.dcd;
494+
icount->tx = cnow.tx;
495+
icount->rx = cnow.rx;
496+
icount->frame = cnow.frame;
497+
icount->parity = cnow.parity;
498+
icount->overrun = cnow.overrun;
499+
icount->brk = cnow.brk;
500+
icount->buf_overrun = cnow.buf_overrun;
501+
502+
return 0;
503+
}
504+
EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
505+
479506
#ifdef CONFIG_MAGIC_SYSRQ
480507
int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
481508
{

‎include/linux/usb/serial.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ extern void usb_serial_generic_throttle(struct tty_struct *tty);
335335
extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
336336
extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty,
337337
unsigned long arg);
338+
extern int usb_serial_generic_get_icount(struct tty_struct *tty,
339+
struct serial_icounter_struct *icount);
338340
extern int usb_serial_generic_register(void);
339341
extern void usb_serial_generic_deregister(void);
340342
extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port,

0 commit comments

Comments
 (0)