Lines Matching +full:buffered +full:- +full:negative

1 // SPDX-License-Identifier: GPL-2.0+
3 * Digi AccelePort USB-4 and USB-2 Serial Converters
7 * Shamelessly based on Brian Warner's keyspan_pda.c and Greg Kroah-Hartman's
8 * usb-serial driver.
31 #define DRIVER_DESC "Digi AccelePort USB-2/USB-4 Serial Converter driver"
33 /* port output buffer length -- must be <= transfer buffer length - 2 */
37 /* port input buffer length -- must be >= transfer buffer length - 3 */
54 #define DIGI_2_ID 0x0002 /* USB-2 */
55 #define DIGI_4_ID 0x0004 /* USB-4 */
58 * "INB": can be used on the in-band endpoint
59 * "OOB": can be used on the out-of-band endpoint
182 struct usb_serial_port *ds_oob_port; /* out-of-band port */
183 int ds_oob_port_num; /* index of out-of-band port */
364 * if successful, -EINTR if interrupted while sleeping and
365 * the interruptible flag is true, or a negative error
374 …(struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; in digi_write_oob_command()
378 dev_dbg(&port->dev, in digi_write_oob_command()
380 oob_priv->dp_port_num, count); in digi_write_oob_command()
382 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); in digi_write_oob_command()
384 while (oob_priv->dp_write_urb_in_use) { in digi_write_oob_command()
386 &oob_priv->write_wait, DIGI_RETRY_TIMEOUT, in digi_write_oob_command()
387 &oob_priv->dp_port_lock, flags); in digi_write_oob_command()
389 return -EINTR; in digi_write_oob_command()
390 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); in digi_write_oob_command()
394 len = min(count, oob_port->bulk_out_size); in digi_write_oob_command()
397 memcpy(oob_port->write_urb->transfer_buffer, buf, len); in digi_write_oob_command()
398 oob_port->write_urb->transfer_buffer_length = len; in digi_write_oob_command()
399 ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); in digi_write_oob_command()
401 oob_priv->dp_write_urb_in_use = 1; in digi_write_oob_command()
402 count -= len; in digi_write_oob_command()
406 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); in digi_write_oob_command()
408 dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", in digi_write_oob_command()
421 * is non-zero, write in band command will return after
423 * timeout ticks. Returns 0 if successful, or a negative
433 unsigned char *data = port->write_urb->transfer_buffer; in digi_write_inb_command()
436 dev_dbg(&port->dev, "digi_write_inb_command: TOP: port=%d, count=%d\n", in digi_write_inb_command()
437 priv->dp_port_num, count); in digi_write_inb_command()
444 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_write_inb_command()
446 while (priv->dp_write_urb_in_use && in digi_write_inb_command()
449 &priv->write_wait, DIGI_RETRY_TIMEOUT, in digi_write_inb_command()
450 &priv->dp_port_lock, flags); in digi_write_inb_command()
452 return -EINTR; in digi_write_inb_command()
453 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_write_inb_command()
457 /* guarantee the write will send buffered data first, */ in digi_write_inb_command()
459 len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len); in digi_write_inb_command()
463 /* write any buffered data first */ in digi_write_inb_command()
464 if (priv->dp_out_buf_len > 0) { in digi_write_inb_command()
466 data[1] = priv->dp_out_buf_len; in digi_write_inb_command()
467 memcpy(data + 2, priv->dp_out_buf, in digi_write_inb_command()
468 priv->dp_out_buf_len); in digi_write_inb_command()
469 memcpy(data + 2 + priv->dp_out_buf_len, buf, len); in digi_write_inb_command()
470 port->write_urb->transfer_buffer_length in digi_write_inb_command()
471 = priv->dp_out_buf_len + 2 + len; in digi_write_inb_command()
474 port->write_urb->transfer_buffer_length = len; in digi_write_inb_command()
477 ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); in digi_write_inb_command()
479 priv->dp_write_urb_in_use = 1; in digi_write_inb_command()
480 priv->dp_out_buf_len = 0; in digi_write_inb_command()
481 count -= len; in digi_write_inb_command()
486 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write_inb_command()
489 dev_err(&port->dev, in digi_write_inb_command()
491 __func__, ret, priv->dp_port_num); in digi_write_inb_command()
502 * -EINTR if interrupted while sleeping, or a non-zero error
512 …struct usb_serial_port *) ((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; in digi_set_modem_signals()
514 unsigned char *data = oob_port->write_urb->transfer_buffer; in digi_set_modem_signals()
517 dev_dbg(&port->dev, in digi_set_modem_signals()
519 port_priv->dp_port_num, modem_signals); in digi_set_modem_signals()
521 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); in digi_set_modem_signals()
522 spin_lock(&port_priv->dp_port_lock); in digi_set_modem_signals()
524 while (oob_priv->dp_write_urb_in_use) { in digi_set_modem_signals()
525 spin_unlock(&port_priv->dp_port_lock); in digi_set_modem_signals()
527 &oob_priv->write_wait, DIGI_RETRY_TIMEOUT, in digi_set_modem_signals()
528 &oob_priv->dp_port_lock, flags); in digi_set_modem_signals()
530 return -EINTR; in digi_set_modem_signals()
531 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); in digi_set_modem_signals()
532 spin_lock(&port_priv->dp_port_lock); in digi_set_modem_signals()
535 data[1] = port_priv->dp_port_num; in digi_set_modem_signals()
540 data[5] = port_priv->dp_port_num; in digi_set_modem_signals()
545 oob_port->write_urb->transfer_buffer_length = 8; in digi_set_modem_signals()
547 ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC); in digi_set_modem_signals()
549 oob_priv->dp_write_urb_in_use = 1; in digi_set_modem_signals()
550 port_priv->dp_modem_signals &= ~(TIOCM_DTR | TIOCM_RTS); in digi_set_modem_signals()
551 port_priv->dp_modem_signals |= in digi_set_modem_signals()
554 spin_unlock(&port_priv->dp_port_lock); in digi_set_modem_signals()
555 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags); in digi_set_modem_signals()
557 dev_err(&port->dev, "%s: usb_submit_urb failed, ret=%d\n", in digi_set_modem_signals()
566 * to go idle. It returns 0 if successful or a negative error.
582 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_transmit_idle()
583 priv->dp_transmit_idle = 0; in digi_transmit_idle()
584 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_transmit_idle()
591 ret = digi_write_inb_command(port, buf, 2, timeout - jiffies); in digi_transmit_idle()
595 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_transmit_idle()
597 while (time_before(jiffies, timeout) && !priv->dp_transmit_idle) { in digi_transmit_idle()
599 &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT, in digi_transmit_idle()
600 &priv->dp_port_lock, flags); in digi_transmit_idle()
602 return -EINTR; in digi_transmit_idle()
603 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_transmit_idle()
605 priv->dp_transmit_idle = 0; in digi_transmit_idle()
606 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_transmit_idle()
615 struct usb_serial_port *port = tty->driver_data; in digi_rx_throttle()
619 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_rx_throttle()
620 priv->dp_throttled = 1; in digi_rx_throttle()
621 priv->dp_throttle_restart = 0; in digi_rx_throttle()
622 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_rx_throttle()
630 struct usb_serial_port *port = tty->driver_data; in digi_rx_unthrottle()
633 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_rx_unthrottle()
636 if (priv->dp_throttle_restart) in digi_rx_unthrottle()
637 ret = usb_submit_urb(port->read_urb, GFP_ATOMIC); in digi_rx_unthrottle()
640 priv->dp_throttled = 0; in digi_rx_unthrottle()
641 priv->dp_throttle_restart = 0; in digi_rx_unthrottle()
643 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_rx_unthrottle()
646 dev_err(&port->dev, in digi_rx_unthrottle()
648 __func__, ret, priv->dp_port_num); in digi_rx_unthrottle()
657 struct device *dev = &port->dev; in digi_set_termios()
658 unsigned int iflag = tty->termios.c_iflag; in digi_set_termios()
659 unsigned int cflag = tty->termios.c_cflag; in digi_set_termios()
660 unsigned int old_iflag = old_termios->c_iflag; in digi_set_termios()
661 unsigned int old_cflag = old_termios->c_cflag; in digi_set_termios()
670 priv->dp_port_num, iflag, old_iflag, cflag, old_cflag); in digi_set_termios()
675 arg = -1; in digi_set_termios()
712 if (arg != -1) { in digi_set_termios()
714 buf[i++] = priv->dp_port_num; in digi_set_termios()
720 tty->termios.c_cflag &= ~CMSPAR; in digi_set_termios()
732 buf[i++] = priv->dp_port_num; in digi_set_termios()
738 arg = -1; in digi_set_termios()
751 if (arg != -1) { in digi_set_termios()
753 buf[i++] = priv->dp_port_num; in digi_set_termios()
769 buf[i++] = priv->dp_port_num; in digi_set_termios()
787 /* On USB-4 it is necessary to assert RTS prior */ in digi_set_termios()
790 buf[i++] = priv->dp_port_num; in digi_set_termios()
798 buf[i++] = priv->dp_port_num; in digi_set_termios()
818 buf[i++] = priv->dp_port_num; in digi_set_termios()
831 buf[i++] = priv->dp_port_num; in digi_set_termios()
844 struct usb_serial_port *port = tty->driver_data; in digi_break_ctl()
858 struct usb_serial_port *port = tty->driver_data; in digi_tiocmget()
863 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_tiocmget()
864 val = priv->dp_modem_signals; in digi_tiocmget()
865 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_tiocmget()
873 struct usb_serial_port *port = tty->driver_data; in digi_tiocmset()
878 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_tiocmset()
879 val = (priv->dp_modem_signals & ~clear) | set; in digi_tiocmset()
880 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_tiocmset()
891 unsigned char *data = port->write_urb->transfer_buffer; in digi_write()
894 dev_dbg(&port->dev, "digi_write: TOP: port=%d, count=%d\n", in digi_write()
895 priv->dp_port_num, count); in digi_write()
898 count = min(count, port->bulk_out_size-2); in digi_write()
903 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_write()
906 if (priv->dp_write_urb_in_use) { in digi_write()
908 if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) { in digi_write()
909 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; in digi_write()
914 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write()
918 /* allow space for any buffered data and for new data, up to */ in digi_write()
919 /* transfer buffer size - 2 (for command and length bytes) */ in digi_write()
920 new_len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len); in digi_write()
921 data_len = new_len + priv->dp_out_buf_len; in digi_write()
924 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write()
928 port->write_urb->transfer_buffer_length = data_len+2; in digi_write()
933 /* copy in buffered data first */ in digi_write()
934 memcpy(data, priv->dp_out_buf, priv->dp_out_buf_len); in digi_write()
935 data += priv->dp_out_buf_len; in digi_write()
940 ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); in digi_write()
942 priv->dp_write_urb_in_use = 1; in digi_write()
944 priv->dp_out_buf_len = 0; in digi_write()
948 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write()
952 __func__, ret, priv->dp_port_num); in digi_write()
953 dev_dbg(&port->dev, "digi_write: returning %d\n", ret); in digi_write()
961 struct usb_serial_port *port = urb->context; in digi_write_bulk_callback()
967 int status = urb->status; in digi_write_bulk_callback()
972 pr_err("%s: port or port->private is NULL, status=%d\n", in digi_write_bulk_callback()
976 serial = port->serial; in digi_write_bulk_callback()
978 dev_err(&port->dev, in digi_write_bulk_callback()
979 "%s: serial or serial->private is NULL, status=%d\n", in digi_write_bulk_callback()
985 if (priv->dp_port_num == serial_priv->ds_oob_port_num) { in digi_write_bulk_callback()
986 dev_dbg(&port->dev, "digi_write_bulk_callback: oob callback\n"); in digi_write_bulk_callback()
987 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_write_bulk_callback()
988 priv->dp_write_urb_in_use = 0; in digi_write_bulk_callback()
989 wake_up_interruptible(&priv->write_wait); in digi_write_bulk_callback()
990 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write_bulk_callback()
994 /* try to send any buffered data on this port */ in digi_write_bulk_callback()
996 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_write_bulk_callback()
997 priv->dp_write_urb_in_use = 0; in digi_write_bulk_callback()
998 if (priv->dp_out_buf_len > 0) { in digi_write_bulk_callback()
999 *((unsigned char *)(port->write_urb->transfer_buffer)) in digi_write_bulk_callback()
1001 *((unsigned char *)(port->write_urb->transfer_buffer) + 1) in digi_write_bulk_callback()
1002 = (unsigned char)priv->dp_out_buf_len; in digi_write_bulk_callback()
1003 port->write_urb->transfer_buffer_length = in digi_write_bulk_callback()
1004 priv->dp_out_buf_len + 2; in digi_write_bulk_callback()
1005 memcpy(port->write_urb->transfer_buffer + 2, priv->dp_out_buf, in digi_write_bulk_callback()
1006 priv->dp_out_buf_len); in digi_write_bulk_callback()
1007 ret = usb_submit_urb(port->write_urb, GFP_ATOMIC); in digi_write_bulk_callback()
1009 priv->dp_write_urb_in_use = 1; in digi_write_bulk_callback()
1010 priv->dp_out_buf_len = 0; in digi_write_bulk_callback()
1014 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write_bulk_callback()
1016 if (ret && ret != -EPERM) in digi_write_bulk_callback()
1019 __func__, ret, priv->dp_port_num); in digi_write_bulk_callback()
1022 tty_port_tty_wakeup(&port->port); in digi_write_bulk_callback()
1027 struct usb_serial_port *port = tty->driver_data; in digi_write_room()
1032 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_write_room()
1034 if (priv->dp_write_urb_in_use) in digi_write_room()
1037 room = port->bulk_out_size - 2 - priv->dp_out_buf_len; in digi_write_room()
1039 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_write_room()
1040 dev_dbg(&port->dev, "digi_write_room: port=%d, room=%u\n", priv->dp_port_num, room); in digi_write_room()
1047 struct usb_serial_port *port = tty->driver_data; in digi_chars_in_buffer()
1052 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_chars_in_buffer()
1053 if (priv->dp_write_urb_in_use) in digi_chars_in_buffer()
1054 chars = port->bulk_out_size - 2; in digi_chars_in_buffer()
1056 chars = priv->dp_out_buf_len; in digi_chars_in_buffer()
1057 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_chars_in_buffer()
1059 dev_dbg(&port->dev, "%s: port=%d, chars=%d\n", __func__, in digi_chars_in_buffer()
1060 priv->dp_port_num, chars); in digi_chars_in_buffer()
1078 if (digi_startup_device(port->serial) != 0) in digi_open()
1079 return -ENXIO; in digi_open()
1083 buf[1] = priv->dp_port_num; in digi_open()
1089 buf[5] = priv->dp_port_num; in digi_open()
1095 dev_dbg(&port->dev, "digi_open: write oob failed, ret=%d\n", ret); in digi_open()
1099 not_termios.c_cflag = ~tty->termios.c_cflag; in digi_open()
1100 not_termios.c_iflag = ~tty->termios.c_iflag; in digi_open()
1114 mutex_lock(&port->serial->disc_mutex); in digi_close()
1116 if (port->serial->disconnected) in digi_close()
1124 buf[1] = priv->dp_port_num; in digi_close()
1130 buf[5] = priv->dp_port_num; in digi_close()
1136 buf[9] = priv->dp_port_num; in digi_close()
1142 buf[13] = priv->dp_port_num; in digi_close()
1148 buf[17] = priv->dp_port_num; in digi_close()
1154 dev_dbg(&port->dev, "digi_close: write oob failed, ret=%d\n", in digi_close()
1157 prepare_to_wait(&priv->dp_flush_wait, &wait, in digi_close()
1160 finish_wait(&priv->dp_flush_wait, &wait); in digi_close()
1163 usb_kill_urb(port->write_urb); in digi_close()
1165 spin_lock_irq(&priv->dp_port_lock); in digi_close()
1166 priv->dp_write_urb_in_use = 0; in digi_close()
1167 wake_up_interruptible(&priv->dp_close_wait); in digi_close()
1168 spin_unlock_irq(&priv->dp_port_lock); in digi_close()
1169 mutex_unlock(&port->serial->disc_mutex); in digi_close()
1177 * urbs initialized. Returns 0 if successful, non-zero error otherwise.
1187 spin_lock(&serial_priv->ds_serial_lock); in digi_startup_device()
1188 if (serial_priv->ds_device_started) { in digi_startup_device()
1189 spin_unlock(&serial_priv->ds_serial_lock); in digi_startup_device()
1192 serial_priv->ds_device_started = 1; in digi_startup_device()
1193 spin_unlock(&serial_priv->ds_serial_lock); in digi_startup_device()
1197 for (i = 0; i < serial->type->num_ports + 1; i++) { in digi_startup_device()
1198 port = serial->port[i]; in digi_startup_device()
1199 ret = usb_submit_urb(port->read_urb, GFP_KERNEL); in digi_startup_device()
1201 dev_err(&port->dev, in digi_startup_device()
1216 return -ENOMEM; in digi_port_init()
1218 spin_lock_init(&priv->dp_port_lock); in digi_port_init()
1219 priv->dp_port_num = port_num; in digi_port_init()
1220 init_waitqueue_head(&priv->dp_transmit_idle_wait); in digi_port_init()
1221 init_waitqueue_head(&priv->dp_flush_wait); in digi_port_init()
1222 init_waitqueue_head(&priv->dp_close_wait); in digi_port_init()
1223 init_waitqueue_head(&priv->write_wait); in digi_port_init()
1224 priv->dp_port = port; in digi_port_init()
1238 return -ENOMEM; in digi_startup()
1240 spin_lock_init(&serial_priv->ds_serial_lock); in digi_startup()
1241 serial_priv->ds_oob_port_num = serial->type->num_ports; in digi_startup()
1242 serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num]; in digi_startup()
1244 ret = digi_port_init(serial_priv->ds_oob_port, in digi_startup()
1245 serial_priv->ds_oob_port_num); in digi_startup()
1262 for (i = 0; i < serial->type->num_ports + 1; i++) { in digi_disconnect()
1263 usb_kill_urb(serial->port[i]->read_urb); in digi_disconnect()
1264 usb_kill_urb(serial->port[i]->write_urb); in digi_disconnect()
1276 priv = usb_get_serial_port_data(serial_priv->ds_oob_port); in digi_release()
1284 return digi_port_init(port, port->port_number); in digi_port_probe()
1297 struct usb_serial_port *port = urb->context; in digi_read_bulk_callback()
1301 int status = urb->status; in digi_read_bulk_callback()
1308 dev_err(&port->dev, "%s: port->private is NULL, status=%d\n", in digi_read_bulk_callback()
1312 if (port->serial == NULL || in digi_read_bulk_callback()
1313 (serial_priv = usb_get_serial_data(port->serial)) == NULL) { in digi_read_bulk_callback()
1314 dev_err(&port->dev, "%s: serial is bad or serial->private " in digi_read_bulk_callback()
1321 dev_err(&port->dev, in digi_read_bulk_callback()
1323 __func__, status, priv->dp_port_num); in digi_read_bulk_callback()
1328 if (priv->dp_port_num == serial_priv->ds_oob_port_num) { in digi_read_bulk_callback()
1338 if (ret != 0 && ret != -EPERM) { in digi_read_bulk_callback()
1339 dev_err(&port->dev, in digi_read_bulk_callback()
1341 __func__, ret, priv->dp_port_num); in digi_read_bulk_callback()
1351 * port->private are not NULL and port->serial has been validated.
1353 * throttled, and -1 if the sanity checks failed.
1358 struct usb_serial_port *port = urb->context; in digi_read_inb_callback()
1360 unsigned char *buf = urb->transfer_buffer; in digi_read_inb_callback()
1369 if (urb->actual_length < 2) { in digi_read_inb_callback()
1370 dev_warn(&port->dev, "short packet received\n"); in digi_read_inb_callback()
1371 return -1; in digi_read_inb_callback()
1377 if (urb->actual_length != len + 2) { in digi_read_inb_callback()
1378 dev_err(&port->dev, "malformed packet received: port=%d, opcode=%d, len=%d, actual_length=%u\n", in digi_read_inb_callback()
1379 priv->dp_port_num, opcode, len, urb->actual_length); in digi_read_inb_callback()
1380 return -1; in digi_read_inb_callback()
1384 dev_err(&port->dev, "malformed data packet received\n"); in digi_read_inb_callback()
1385 return -1; in digi_read_inb_callback()
1388 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_read_inb_callback()
1392 throttled = priv->dp_throttled; in digi_read_inb_callback()
1394 priv->dp_throttle_restart = 1; in digi_read_inb_callback()
1406 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in digi_read_inb_callback()
1417 /* data length is len-1 (one byte of len is port_status) */ in digi_read_inb_callback()
1418 --len; in digi_read_inb_callback()
1420 tty_insert_flip_string_fixed_flag(&port->port, data, in digi_read_inb_callback()
1422 tty_flip_buffer_push(&port->port); in digi_read_inb_callback()
1425 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_read_inb_callback()
1428 dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__); in digi_read_inb_callback()
1430 dev_dbg(&port->dev, "%s: unknown opcode: %d\n", __func__, opcode); in digi_read_inb_callback()
1441 * When called we know port and port->private are not NULL and
1442 * the port->serial is valid. It returns 0 if successful, and
1443 * -1 if the sanity checks failed.
1449 struct usb_serial_port *port = urb->context; in digi_read_oob_callback()
1450 struct usb_serial *serial = port->serial; in digi_read_oob_callback()
1453 unsigned char *buf = urb->transfer_buffer; in digi_read_oob_callback()
1459 if (urb->actual_length < 4) in digi_read_oob_callback()
1460 return -1; in digi_read_oob_callback()
1463 for (i = 0; i < urb->actual_length - 3; i += 4) { in digi_read_oob_callback()
1469 dev_dbg(&port->dev, "digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d\n", in digi_read_oob_callback()
1472 if (status != 0 || line >= serial->type->num_ports) in digi_read_oob_callback()
1475 port = serial->port[line]; in digi_read_oob_callback()
1479 return -1; in digi_read_oob_callback()
1481 tty = tty_port_tty_get(&port->port); in digi_read_oob_callback()
1490 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_read_oob_callback()
1493 priv->dp_modem_signals |= TIOCM_CTS; in digi_read_oob_callback()
1497 priv->dp_modem_signals &= ~TIOCM_CTS; in digi_read_oob_callback()
1501 priv->dp_modem_signals |= TIOCM_DSR; in digi_read_oob_callback()
1503 priv->dp_modem_signals &= ~TIOCM_DSR; in digi_read_oob_callback()
1505 priv->dp_modem_signals |= TIOCM_RI; in digi_read_oob_callback()
1507 priv->dp_modem_signals &= ~TIOCM_RI; in digi_read_oob_callback()
1509 priv->dp_modem_signals |= TIOCM_CD; in digi_read_oob_callback()
1511 priv->dp_modem_signals &= ~TIOCM_CD; in digi_read_oob_callback()
1513 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_read_oob_callback()
1516 tty_port_tty_wakeup(&port->port); in digi_read_oob_callback()
1518 spin_lock_irqsave(&priv->dp_port_lock, flags); in digi_read_oob_callback()
1519 priv->dp_transmit_idle = 1; in digi_read_oob_callback()
1520 wake_up_interruptible(&priv->dp_transmit_idle_wait); in digi_read_oob_callback()
1521 spin_unlock_irqrestore(&priv->dp_port_lock, flags); in digi_read_oob_callback()
1523 wake_up_interruptible(&priv->dp_flush_wait); in digi_read_oob_callback()