aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/oti6858.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2014-01-02 16:49:35 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-03 15:42:24 -0500
commitbd6383c81d5f33e01688a87c50a8d3a878aa43d5 (patch)
tree519ebdb154bc6432f793485c852b8f7b7df4295f /drivers/usb/serial/oti6858.c
parent1acc36e9c8dcd44f0978c9270e24daa83f343f85 (diff)
USB: oti6858: switch to generic TIOCMIWAIT implementation
Switch to the generic TIOCMIWAIT implementation. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/oti6858.c')
-rw-r--r--drivers/usb/serial/oti6858.c55
1 files changed, 12 insertions, 43 deletions
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 9ea15e0a22d8..95a79b487515 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -135,7 +135,6 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
135static int oti6858_tiocmget(struct tty_struct *tty); 135static int oti6858_tiocmget(struct tty_struct *tty);
136static int oti6858_tiocmset(struct tty_struct *tty, 136static int oti6858_tiocmset(struct tty_struct *tty,
137 unsigned int set, unsigned int clear); 137 unsigned int set, unsigned int clear);
138static int oti6858_tiocmiwait(struct tty_struct *tty, unsigned long arg);
139static int oti6858_port_probe(struct usb_serial_port *port); 138static int oti6858_port_probe(struct usb_serial_port *port);
140static int oti6858_port_remove(struct usb_serial_port *port); 139static int oti6858_port_remove(struct usb_serial_port *port);
141 140
@@ -154,7 +153,7 @@ static struct usb_serial_driver oti6858_device = {
154 .init_termios = oti6858_init_termios, 153 .init_termios = oti6858_init_termios,
155 .tiocmget = oti6858_tiocmget, 154 .tiocmget = oti6858_tiocmget,
156 .tiocmset = oti6858_tiocmset, 155 .tiocmset = oti6858_tiocmset,
157 .tiocmiwait = oti6858_tiocmiwait, 156 .tiocmiwait = usb_serial_generic_tiocmiwait,
158 .read_bulk_callback = oti6858_read_bulk_callback, 157 .read_bulk_callback = oti6858_read_bulk_callback,
159 .read_int_callback = oti6858_read_int_callback, 158 .read_int_callback = oti6858_read_int_callback,
160 .write_bulk_callback = oti6858_write_bulk_callback, 159 .write_bulk_callback = oti6858_write_bulk_callback,
@@ -643,46 +642,6 @@ static int oti6858_tiocmget(struct tty_struct *tty)
643 return result; 642 return result;
644} 643}
645 644
646static int oti6858_tiocmiwait(struct tty_struct *tty, unsigned long arg)
647{
648 struct usb_serial_port *port = tty->driver_data;
649 struct oti6858_private *priv = usb_get_serial_port_data(port);
650 unsigned long flags;
651 unsigned int prev, status;
652 unsigned int changed;
653
654 spin_lock_irqsave(&priv->lock, flags);
655 prev = priv->status.pin_state;
656 spin_unlock_irqrestore(&priv->lock, flags);
657
658 while (1) {
659 wait_event_interruptible(port->port.delta_msr_wait,
660 port->serial->disconnected ||
661 priv->status.pin_state != prev);
662 if (signal_pending(current))
663 return -ERESTARTSYS;
664
665 if (port->serial->disconnected)
666 return -EIO;
667
668 spin_lock_irqsave(&priv->lock, flags);
669 status = priv->status.pin_state & PIN_MASK;
670 spin_unlock_irqrestore(&priv->lock, flags);
671
672 changed = prev ^ status;
673 /* FIXME: check if this is correct (active high/low) */
674 if (((arg & TIOCM_RNG) && (changed & PIN_RI)) ||
675 ((arg & TIOCM_DSR) && (changed & PIN_DSR)) ||
676 ((arg & TIOCM_CD) && (changed & PIN_DCD)) ||
677 ((arg & TIOCM_CTS) && (changed & PIN_CTS)))
678 return 0;
679 prev = status;
680 }
681
682 /* NOTREACHED */
683 return 0;
684}
685
686static void oti6858_read_int_callback(struct urb *urb) 645static void oti6858_read_int_callback(struct urb *urb)
687{ 646{
688 struct usb_serial_port *port = urb->context; 647 struct usb_serial_port *port = urb->context;
@@ -742,8 +701,18 @@ static void oti6858_read_int_callback(struct urb *urb)
742 if (!priv->transient) { 701 if (!priv->transient) {
743 u8 delta = xs->pin_state ^ priv->status.pin_state; 702 u8 delta = xs->pin_state ^ priv->status.pin_state;
744 703
745 if (delta & PIN_MSR_MASK) 704 if (delta & PIN_MSR_MASK) {
705 if (delta & PIN_CTS)
706 port->icount.cts++;
707 if (delta & PIN_DSR)
708 port->icount.dsr++;
709 if (delta & PIN_RI)
710 port->icount.rng++;
711 if (delta & PIN_DCD)
712 port->icount.dcd++;
713
746 wake_up_interruptible(&port->port.delta_msr_wait); 714 wake_up_interruptible(&port->port.delta_msr_wait);
715 }
747 716
748 memcpy(&priv->status, xs, OTI6858_CTRL_PKT_SIZE); 717 memcpy(&priv->status, xs, OTI6858_CTRL_PKT_SIZE);
749 } 718 }