aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-03-21 07:36:54 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-25 16:50:51 -0400
commitbefefcda4bddc52d29248931801961a72aeef28b (patch)
treeb8b47011f4321938a599ad8622944d786c33d4f4
parentc371de14b9a23aadb57accab0ca2e5dd28de7f16 (diff)
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>
-rw-r--r--drivers/usb/serial/generic.c27
-rw-r--r--include/linux/usb/serial.h2
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 18bc74e20fe1..5e55761b2cb8 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -476,6 +476,33 @@ int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg)
476} 476}
477EXPORT_SYMBOL_GPL(usb_serial_generic_tiocmiwait); 477EXPORT_SYMBOL_GPL(usb_serial_generic_tiocmiwait);
478 478
479int 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}
504EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
505
479#ifdef CONFIG_MAGIC_SYSRQ 506#ifdef CONFIG_MAGIC_SYSRQ
480int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch) 507int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
481{ 508{
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 47c8d2c506c8..c786ee7fca8f 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -335,6 +335,8 @@ extern void usb_serial_generic_throttle(struct tty_struct *tty);
335extern void usb_serial_generic_unthrottle(struct tty_struct *tty); 335extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
336extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty, 336extern int usb_serial_generic_tiocmiwait(struct tty_struct *tty,
337 unsigned long arg); 337 unsigned long arg);
338extern int usb_serial_generic_get_icount(struct tty_struct *tty,
339 struct serial_icounter_struct *icount);
338extern int usb_serial_generic_register(void); 340extern int usb_serial_generic_register(void);
339extern void usb_serial_generic_deregister(void); 341extern void usb_serial_generic_deregister(void);
340extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, 342extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port,