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>
This commit is contained in:
Johan Hovold 2014-01-02 22:49:35 +01:00 committed by Greg Kroah-Hartman
parent 1acc36e9c8
commit bd6383c81d

View File

@ -135,7 +135,6 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
static int oti6858_tiocmget(struct tty_struct *tty);
static int oti6858_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear);
static int oti6858_tiocmiwait(struct tty_struct *tty, unsigned long arg);
static int oti6858_port_probe(struct usb_serial_port *port);
static int oti6858_port_remove(struct usb_serial_port *port);
@ -154,7 +153,7 @@ static struct usb_serial_driver oti6858_device = {
.init_termios = oti6858_init_termios,
.tiocmget = oti6858_tiocmget,
.tiocmset = oti6858_tiocmset,
.tiocmiwait = oti6858_tiocmiwait,
.tiocmiwait = usb_serial_generic_tiocmiwait,
.read_bulk_callback = oti6858_read_bulk_callback,
.read_int_callback = oti6858_read_int_callback,
.write_bulk_callback = oti6858_write_bulk_callback,
@ -643,46 +642,6 @@ static int oti6858_tiocmget(struct tty_struct *tty)
return result;
}
static int oti6858_tiocmiwait(struct tty_struct *tty, unsigned long arg)
{
struct usb_serial_port *port = tty->driver_data;
struct oti6858_private *priv = usb_get_serial_port_data(port);
unsigned long flags;
unsigned int prev, status;
unsigned int changed;
spin_lock_irqsave(&priv->lock, flags);
prev = priv->status.pin_state;
spin_unlock_irqrestore(&priv->lock, flags);
while (1) {
wait_event_interruptible(port->port.delta_msr_wait,
port->serial->disconnected ||
priv->status.pin_state != prev);
if (signal_pending(current))
return -ERESTARTSYS;
if (port->serial->disconnected)
return -EIO;
spin_lock_irqsave(&priv->lock, flags);
status = priv->status.pin_state & PIN_MASK;
spin_unlock_irqrestore(&priv->lock, flags);
changed = prev ^ status;
/* FIXME: check if this is correct (active high/low) */
if (((arg & TIOCM_RNG) && (changed & PIN_RI)) ||
((arg & TIOCM_DSR) && (changed & PIN_DSR)) ||
((arg & TIOCM_CD) && (changed & PIN_DCD)) ||
((arg & TIOCM_CTS) && (changed & PIN_CTS)))
return 0;
prev = status;
}
/* NOTREACHED */
return 0;
}
static void oti6858_read_int_callback(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
@ -742,8 +701,18 @@ static void oti6858_read_int_callback(struct urb *urb)
if (!priv->transient) {
u8 delta = xs->pin_state ^ priv->status.pin_state;
if (delta & PIN_MSR_MASK)
if (delta & PIN_MSR_MASK) {
if (delta & PIN_CTS)
port->icount.cts++;
if (delta & PIN_DSR)
port->icount.dsr++;
if (delta & PIN_RI)
port->icount.rng++;
if (delta & PIN_DCD)
port->icount.dcd++;
wake_up_interruptible(&port->port.delta_msr_wait);
}
memcpy(&priv->status, xs, OTI6858_CTRL_PKT_SIZE);
}