--- zzzz-none-000/linux-3.10.107/drivers/usb/serial/oti6858.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/usb/serial/oti6858.c 2021-02-04 17:41:59.000000000 +0000 @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -103,6 +102,7 @@ #define TX_BUFFER_EMPTIED 0x09 u8 pin_state; #define PIN_MASK 0x3f +#define PIN_MSR_MASK 0x1b #define PIN_RTS 0x20 /* output pin */ #define PIN_CTS 0x10 /* input pin, active low */ #define PIN_DSR 0x08 /* input pin, active low */ @@ -134,7 +134,6 @@ 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_attach(struct usb_serial *serial); static int oti6858_port_probe(struct usb_serial_port *port); static int oti6858_port_remove(struct usb_serial_port *port); @@ -154,7 +153,7 @@ .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, @@ -202,8 +201,7 @@ int result; new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); - if (new_setup == NULL) { - dev_err(&port->dev, "%s(): out of memory!\n", __func__); + if (!new_setup) { /* we will try again */ schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2)); @@ -289,11 +287,9 @@ if (count != 0) { allow = kmalloc(1, GFP_KERNEL); - if (!allow) { - dev_err_console(port, "%s(): kmalloc failed\n", - __func__); + if (!allow) return; - } + result = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), OTI6858_REQ_T_CHECK_TXBUFF, @@ -359,6 +355,8 @@ usb_set_serial_port_data(port, priv); + port->port.drain_delay = 256; /* FIXME: check the FIFO length */ + return 0; } @@ -427,9 +425,6 @@ __le16 divisor; int br; - if (!tty) - return; - cflag = tty->termios.c_cflag; spin_lock_irqsave(&priv->lock, flags); @@ -525,7 +520,6 @@ static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port) { struct oti6858_private *priv = usb_get_serial_port_data(port); - struct ktermios tmp_termios; struct usb_serial *serial = port->serial; struct oti6858_control_pkt *buf; unsigned long flags; @@ -535,10 +529,8 @@ usb_clear_halt(serial->dev, port->read_urb->pipe); buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL); - if (buf == NULL) { - dev_err(&port->dev, "%s(): out of memory!\n", __func__); + if (!buf) return -ENOMEM; - } result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), OTI6858_REQ_T_GET_STATUS, @@ -576,8 +568,8 @@ /* setup termios */ if (tty) - oti6858_set_termios(tty, port, &tmp_termios); - port->port.drain_delay = 256; /* FIXME: check the FIFO length */ + oti6858_set_termios(tty, port, NULL); + return 0; } @@ -665,46 +657,6 @@ 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; @@ -762,8 +714,21 @@ } if (!priv->transient) { - if (xs->pin_state != priv->status.pin_state) + u8 delta = xs->pin_state ^ priv->status.pin_state; + + 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); }