Lines Matching +full:cts +full:- +full:rts +full:- +full:swap

1 // SPDX-License-Identifier: GPL-2.0-only
12 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
31 * Interface 2: Standard modem interface - circuit switched interface, this
83 /* - use *_bit operations on it. (bit indices not values.) */
326 return hso_dev->port_data.dev_net; in dev2net()
331 return hso_dev->port_data.dev_serial; in dev2ser()
418 {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */
420 {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */
421 {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */
470 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_sysfs_show_porttype()
521 for (idx = 0; idx < serial->num_rx_urbs; idx++) in hso_urb_to_index()
522 if (serial->rx_urb[idx] == urb) in hso_urb_to_index()
524 dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); in hso_urb_to_index()
525 return -1; in hso_urb_to_index()
592 (dev2ser(serial_table[i])->shared_int == shared_int) && in get_serial_by_shared_int_and_type()
593 ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { in get_serial_by_shared_int_and_type()
629 return -1; in get_free_serial_index()
638 serial_table[index] = serial->parent; in set_serial_by_index()
650 case -ENODEV: in handle_usb_error()
653 case -ENOENT: in handle_usb_error()
656 case -EPIPE: in handle_usb_error()
659 case -ENOSPC: in handle_usb_error()
662 case -ESHUTDOWN: in handle_usb_error()
665 case -EHOSTUNREACH: in handle_usb_error()
668 case -EINVAL: in handle_usb_error()
669 case -EAGAIN: in handle_usb_error()
670 case -EFBIG: in handle_usb_error()
671 case -EMSGSIZE: in handle_usb_error()
674 case -EILSEQ: in handle_usb_error()
675 case -EPROTO: in handle_usb_error()
676 case -ETIME: in handle_usb_error()
677 case -ETIMEDOUT: in handle_usb_error()
680 usb_queue_reset_device(hso_dev->interface); in handle_usb_error()
688 hso_dbg(0x1, "%s: received USB status - %s (%d)\n", in handle_usb_error()
701 dev_err(&net->dev, "No net device !\n"); in hso_net_open()
702 return -ENODEV; in hso_net_open()
705 odev->skb_tx_buf = NULL; in hso_net_open()
708 spin_lock_irqsave(&odev->net_lock, flags); in hso_net_open()
709 odev->rx_parse_state = WAIT_IP; in hso_net_open()
710 odev->rx_buf_size = 0; in hso_net_open()
711 odev->rx_buf_missing = sizeof(struct iphdr); in hso_net_open()
712 spin_unlock_irqrestore(&odev->net_lock, flags); in hso_net_open()
715 set_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_open()
716 hso_start_net_device(odev->parent); in hso_net_open()
732 clear_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_close()
734 hso_stop_net_device(odev->parent); in hso_net_close()
743 struct hso_net *odev = urb->context; in write_bulk_callback()
744 int status = urb->status; in write_bulk_callback()
747 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in write_bulk_callback()
748 dev_err(&urb->dev->dev, "%s: device not running\n", __func__); in write_bulk_callback()
753 if (!netif_device_present(odev->net)) { in write_bulk_callback()
754 dev_err(&urb->dev->dev, "%s: net device not present\n", in write_bulk_callback()
762 handle_usb_error(status, __func__, odev->parent); in write_bulk_callback()
764 hso_put_activity(odev->parent); in write_bulk_callback()
767 netif_wake_queue(odev->net); in write_bulk_callback()
779 if (hso_get_activity(odev->parent) == -EAGAIN) { in hso_net_start_xmit()
780 odev->skb_tx_buf = skb; in hso_net_start_xmit()
785 DUMP1(skb->data, skb->len); in hso_net_start_xmit()
787 memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); in hso_net_start_xmit()
788 hso_dbg(0x1, "len: %d/%d\n", skb->len, MUX_BULK_TX_BUF_SIZE); in hso_net_start_xmit()
791 usb_fill_bulk_urb(odev->mux_bulk_tx_urb, in hso_net_start_xmit()
792 odev->parent->usb, in hso_net_start_xmit()
793 usb_sndbulkpipe(odev->parent->usb, in hso_net_start_xmit()
794 odev->out_endp-> in hso_net_start_xmit()
796 odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, in hso_net_start_xmit()
800 odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; in hso_net_start_xmit()
803 result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); in hso_net_start_xmit()
805 dev_warn(&odev->parent->interface->dev, in hso_net_start_xmit()
807 net->stats.tx_errors++; in hso_net_start_xmit()
810 net->stats.tx_packets++; in hso_net_start_xmit()
811 net->stats.tx_bytes += skb->len; in hso_net_start_xmit()
831 dev_warn(&net->dev, "Tx timed out.\n"); in hso_net_tx_timeout()
834 if (odev->mux_bulk_tx_urb) in hso_net_tx_timeout()
835 usb_unlink_urb(odev->mux_bulk_tx_urb); in hso_net_tx_timeout()
838 net->stats.tx_errors++; in hso_net_tx_timeout()
854 switch (odev->rx_parse_state) { in packetizeRx()
857 /* wanted bytes - size of ip header */ in packetizeRx()
860 odev->rx_buf_missing) ? count : odev-> in packetizeRx()
863 memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + in packetizeRx()
864 odev->rx_buf_size, ip_pkt + buffer_offset, in packetizeRx()
867 odev->rx_buf_size += temp_bytes; in packetizeRx()
869 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
870 count -= temp_bytes; in packetizeRx()
872 if (!odev->rx_buf_missing) { in packetizeRx()
875 frame_len = ntohs(odev->rx_ip_hdr.tot_len); in packetizeRx()
879 dev_err(&odev->net->dev, in packetizeRx()
882 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
886 odev->skb_rx_buf = netdev_alloc_skb(odev->net, in packetizeRx()
888 if (!odev->skb_rx_buf) { in packetizeRx()
891 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
897 skb_put_data(odev->skb_rx_buf, in packetizeRx()
898 (char *)&(odev->rx_ip_hdr), in packetizeRx()
902 odev->rx_buf_size = sizeof(struct iphdr); in packetizeRx()
905 odev->rx_buf_missing = in packetizeRx()
906 frame_len - sizeof(struct iphdr); in packetizeRx()
907 odev->rx_parse_state = WAIT_DATA; in packetizeRx()
912 temp_bytes = (count < odev->rx_buf_missing) in packetizeRx()
913 ? count : odev->rx_buf_missing; in packetizeRx()
918 skb_put_data(odev->skb_rx_buf, in packetizeRx()
922 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
923 count -= temp_bytes; in packetizeRx()
925 odev->rx_buf_size += temp_bytes; in packetizeRx()
926 if (!odev->rx_buf_missing) { in packetizeRx()
929 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); in packetizeRx()
930 skb_reset_mac_header(odev->skb_rx_buf); in packetizeRx()
933 netif_rx(odev->skb_rx_buf); in packetizeRx()
935 odev->skb_rx_buf = NULL; in packetizeRx()
938 odev->net->stats.rx_packets++; in packetizeRx()
940 odev->net->stats.rx_bytes += odev->rx_buf_size; in packetizeRx()
942 odev->rx_buf_size = 0; in packetizeRx()
943 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
944 odev->rx_parse_state = WAIT_IP; in packetizeRx()
954 count--; in packetizeRx()
961 if (odev->rx_parse_state == WAIT_SYNC) { in packetizeRx()
962 odev->rx_parse_state = WAIT_IP; in packetizeRx()
963 odev->rx_buf_size = 0; in packetizeRx()
964 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
972 u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); in fix_crc_bug()
975 !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, in fix_crc_bug()
977 urb->actual_length -= 4; in fix_crc_bug()
984 struct hso_net *odev = urb->context; in read_bulk_callback()
988 int status = urb->status; in read_bulk_callback()
992 handle_usb_error(status, __func__, odev->parent); in read_bulk_callback()
997 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in read_bulk_callback()
1001 usb_mark_last_busy(urb->dev); in read_bulk_callback()
1003 net = odev->net; in read_bulk_callback()
1010 if (odev->parent->port_spec & HSO_INFO_CRC_BUG) in read_bulk_callback()
1011 fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); in read_bulk_callback()
1014 if (urb->actual_length) { in read_bulk_callback()
1017 spin_lock_irqsave(&odev->net_lock, flags); in read_bulk_callback()
1018 packetizeRx(odev, urb->transfer_buffer, urb->actual_length, in read_bulk_callback()
1019 (urb->transfer_buffer_length > in read_bulk_callback()
1020 urb->actual_length) ? 1 : 0); in read_bulk_callback()
1021 spin_unlock_irqrestore(&odev->net_lock, flags); in read_bulk_callback()
1027 odev->parent->usb, in read_bulk_callback()
1028 usb_rcvbulkpipe(odev->parent->usb, in read_bulk_callback()
1029 odev->in_endp-> in read_bulk_callback()
1031 urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, in read_bulk_callback()
1038 dev_warn(&odev->parent->interface->dev, in read_bulk_callback()
1050 termios->c_iflag &= in hso_init_termios()
1061 termios->c_oflag &= ~OPOST; in hso_init_termios()
1063 termios->c_lflag &= in hso_init_termios()
1070 | IEXTEN); /* disable non-POSIX special characters */ in hso_init_termios()
1072 termios->c_cflag &= in hso_init_termios()
1078 termios->c_cflag |= CS8; /* character size 8 bits */ in hso_init_termios()
1087 struct hso_serial *serial = tty->driver_data; in _hso_serial_set_termios()
1094 hso_dbg(0x8, "port %d\n", serial->minor); in _hso_serial_set_termios()
1099 tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ in _hso_serial_set_termios()
1101 tty->termios.c_cflag &= in _hso_serial_set_termios()
1107 tty->termios.c_cflag |= CS8; /* character size 8 bits */ in _hso_serial_set_termios()
1118 usb_fill_bulk_urb(urb, serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1119 usb_rcvbulkpipe(serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1120 serial->in_endp-> in hso_resubmit_rx_bulk_urb()
1122 urb->transfer_buffer, serial->rx_data_length, in hso_resubmit_rx_bulk_urb()
1128 dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", in hso_resubmit_rx_bulk_urb()
1141 while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { in put_rxbuf_data_and_resubmit_bulk_urb()
1142 curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; in put_rxbuf_data_and_resubmit_bulk_urb()
1144 if (count == -1) in put_rxbuf_data_and_resubmit_bulk_urb()
1147 serial->curr_rx_urb_idx++; in put_rxbuf_data_and_resubmit_bulk_urb()
1148 if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) in put_rxbuf_data_and_resubmit_bulk_urb()
1149 serial->curr_rx_urb_idx = 0; in put_rxbuf_data_and_resubmit_bulk_urb()
1160 urb = serial->rx_urb[0]; in put_rxbuf_data_and_resubmit_ctrl_urb()
1161 if (serial->port.count > 0) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1163 if (count == -1) in put_rxbuf_data_and_resubmit_ctrl_urb()
1168 if (count == 0 && ((urb->actual_length != 0) || in put_rxbuf_data_and_resubmit_ctrl_urb()
1169 (serial->rx_state == RX_PENDING))) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1170 serial->rx_state = RX_SENT; in put_rxbuf_data_and_resubmit_ctrl_urb()
1173 serial->rx_state = RX_IDLE; in put_rxbuf_data_and_resubmit_ctrl_urb()
1180 struct hso_serial *serial = urb->context; in hso_std_serial_read_bulk_callback()
1181 int status = urb->status; in hso_std_serial_read_bulk_callback()
1184 hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status); in hso_std_serial_read_bulk_callback()
1192 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_read_bulk_callback()
1196 hso_dbg(0x1, "Actual length = %d\n", urb->actual_length); in hso_std_serial_read_bulk_callback()
1197 DUMP1(urb->transfer_buffer, urb->actual_length); in hso_std_serial_read_bulk_callback()
1200 if (serial->port.count == 0) in hso_std_serial_read_bulk_callback()
1203 if (serial->parent->port_spec & HSO_INFO_CRC_BUG) in hso_std_serial_read_bulk_callback()
1204 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); in hso_std_serial_read_bulk_callback()
1206 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1207 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; in hso_std_serial_read_bulk_callback()
1209 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1221 spin_lock_irqsave(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1222 if ((serial->parent->port_spec & HSO_INTF_MUX)) in hso_unthrottle_tasklet()
1226 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1231 struct hso_serial *serial = tty->driver_data; in hso_unthrottle()
1233 tasklet_hi_schedule(&serial->unthrottle_tasklet); in hso_unthrottle()
1239 struct hso_serial *serial = get_serial_by_index(tty->index); in hso_serial_open()
1243 if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { in hso_serial_open()
1245 tty->driver_data = NULL; in hso_serial_open()
1247 return -ENODEV; in hso_serial_open()
1250 mutex_lock(&serial->parent->mutex); in hso_serial_open()
1251 result = usb_autopm_get_interface(serial->parent->interface); in hso_serial_open()
1255 hso_dbg(0x1, "Opening %d\n", serial->minor); in hso_serial_open()
1258 tty->driver_data = serial; in hso_serial_open()
1259 tty_port_tty_set(&serial->port, tty); in hso_serial_open()
1262 serial->port.count++; in hso_serial_open()
1263 if (serial->port.count == 1) { in hso_serial_open()
1264 serial->rx_state = RX_IDLE; in hso_serial_open()
1267 tasklet_init(&serial->unthrottle_tasklet, in hso_serial_open()
1270 result = hso_start_serial_device(serial->parent, GFP_KERNEL); in hso_serial_open()
1272 hso_stop_serial_device(serial->parent); in hso_serial_open()
1273 serial->port.count--; in hso_serial_open()
1275 kref_get(&serial->parent->ref); in hso_serial_open()
1281 usb_autopm_put_interface(serial->parent->interface); in hso_serial_open()
1287 mutex_unlock(&serial->parent->mutex); in hso_serial_open()
1294 struct hso_serial *serial = tty->driver_data; in hso_serial_close()
1303 mutex_lock(&serial->parent->mutex); in hso_serial_close()
1304 usb_gone = serial->parent->usb_gone; in hso_serial_close()
1307 usb_autopm_get_interface(serial->parent->interface); in hso_serial_close()
1309 /* reset the rts and dtr */ in hso_serial_close()
1311 serial->port.count--; in hso_serial_close()
1313 if (serial->port.count <= 0) { in hso_serial_close()
1314 serial->port.count = 0; in hso_serial_close()
1315 tty_port_tty_set(&serial->port, NULL); in hso_serial_close()
1317 hso_stop_serial_device(serial->parent); in hso_serial_close()
1318 tasklet_kill(&serial->unthrottle_tasklet); in hso_serial_close()
1322 usb_autopm_put_interface(serial->parent->interface); in hso_serial_close()
1324 mutex_unlock(&serial->parent->mutex); in hso_serial_close()
1331 struct hso_serial *serial = tty->driver_data; in hso_serial_write()
1338 return -ENODEV; in hso_serial_write()
1341 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write()
1343 space = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write()
1349 memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); in hso_serial_write()
1350 serial->tx_buffer_count += tx_bytes; in hso_serial_write()
1353 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write()
1363 struct hso_serial *serial = tty->driver_data; in hso_serial_write_room()
1367 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write_room()
1368 room = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write_room()
1369 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write_room()
1377 struct hso_serial *serial = tty->driver_data; in hso_serial_cleanup()
1382 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_serial_cleanup()
1388 struct hso_serial *serial = tty->driver_data; in hso_serial_set_termios()
1392 hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", in hso_serial_set_termios()
1393 (unsigned int)tty->termios.c_cflag, in hso_serial_set_termios()
1394 (unsigned int)old->c_cflag); in hso_serial_set_termios()
1397 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_set_termios()
1398 if (serial->port.count) in hso_serial_set_termios()
1401 tty->termios = *old; in hso_serial_set_termios()
1402 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_set_termios()
1410 struct hso_serial *serial = tty->driver_data; in hso_serial_chars_in_buffer()
1418 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1419 chars = serial->tx_buffer_count; in hso_serial_chars_in_buffer()
1420 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1430 if (serial->parent->usb_gone) in tiocmget_submit_urb()
1431 return -ENODEV; in tiocmget_submit_urb()
1432 usb_fill_int_urb(tiocmget->urb, usb, in tiocmget_submit_urb()
1434 tiocmget->endp-> in tiocmget_submit_urb()
1436 tiocmget->serial_state_notification, in tiocmget_submit_urb()
1439 tiocmget->endp->bInterval); in tiocmget_submit_urb()
1440 result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); in tiocmget_submit_urb()
1442 dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, in tiocmget_submit_urb()
1451 struct hso_serial *serial = urb->context; in tiocmget_intr_callback()
1453 int status = urb->status; in tiocmget_intr_callback()
1465 handle_usb_error(status, __func__, serial->parent); in tiocmget_intr_callback()
1470 tiocmget = serial->tiocmget; in tiocmget_intr_callback()
1473 BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); in tiocmget_intr_callback()
1475 usb = serial->parent->usb; in tiocmget_intr_callback()
1476 interface = serial->parent->interface; in tiocmget_intr_callback()
1478 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in tiocmget_intr_callback()
1483 serial_state_notification = tiocmget->serial_state_notification; in tiocmget_intr_callback()
1484 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || in tiocmget_intr_callback()
1485 serial_state_notification->bNotification != B_NOTIFICATION || in tiocmget_intr_callback()
1486 le16_to_cpu(serial_state_notification->wValue) != W_VALUE || in tiocmget_intr_callback()
1487 le16_to_cpu(serial_state_notification->wIndex) != if_num || in tiocmget_intr_callback()
1488 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { in tiocmget_intr_callback()
1489 dev_warn(&usb->dev, in tiocmget_intr_callback()
1496 UART_state_bitmap = le16_to_cpu(serial_state_notification-> in tiocmget_intr_callback()
1498 prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; in tiocmget_intr_callback()
1499 icount = &tiocmget->icount; in tiocmget_intr_callback()
1500 spin_lock_irqsave(&serial->serial_lock, flags); in tiocmget_intr_callback()
1503 icount->parity++; in tiocmget_intr_callback()
1506 icount->parity++; in tiocmget_intr_callback()
1509 icount->frame++; in tiocmget_intr_callback()
1512 icount->rng++; in tiocmget_intr_callback()
1515 icount->brk++; in tiocmget_intr_callback()
1518 icount->dsr++; in tiocmget_intr_callback()
1521 icount->dcd++; in tiocmget_intr_callback()
1522 tiocmget->prev_UART_state_bitmap = UART_state_bitmap; in tiocmget_intr_callback()
1523 spin_unlock_irqrestore(&serial->serial_lock, flags); in tiocmget_intr_callback()
1524 tiocmget->intr_completed = 1; in tiocmget_intr_callback()
1525 wake_up_interruptible(&tiocmget->waitq); in tiocmget_intr_callback()
1531 serial->parent->usb); in tiocmget_intr_callback()
1537 /* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1538 * - mask passed in arg for lines of interest
1539 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1550 tiocmget = serial->tiocmget; in hso_wait_modem_status()
1552 return -ENOENT; in hso_wait_modem_status()
1556 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1557 memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1558 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1559 add_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1561 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1562 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1563 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1574 ret = -ERESTARTSYS; in hso_wait_modem_status()
1580 remove_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1586 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1588 * NB: both 1->0 and 0->1 transitions are counted except for
1589 * RI where only 0->1 is counted.
1595 struct hso_serial *serial = tty->driver_data; in hso_get_count()
1596 struct hso_tiocmget *tiocmget = serial->tiocmget; in hso_get_count()
1601 return -ENOENT; in hso_get_count()
1602 spin_lock_irq(&serial->serial_lock); in hso_get_count()
1603 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_get_count()
1604 spin_unlock_irq(&serial->serial_lock); in hso_get_count()
1606 icount->cts = cnow.cts; in hso_get_count()
1607 icount->dsr = cnow.dsr; in hso_get_count()
1608 icount->rng = cnow.rng; in hso_get_count()
1609 icount->dcd = cnow.dcd; in hso_get_count()
1610 icount->rx = cnow.rx; in hso_get_count()
1611 icount->tx = cnow.tx; in hso_get_count()
1612 icount->frame = cnow.frame; in hso_get_count()
1613 icount->overrun = cnow.overrun; in hso_get_count()
1614 icount->parity = cnow.parity; in hso_get_count()
1615 icount->brk = cnow.brk; in hso_get_count()
1616 icount->buf_overrun = cnow.buf_overrun; in hso_get_count()
1625 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmget()
1632 return -EINVAL; in hso_serial_tiocmget()
1634 spin_lock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1635 retval = ((serial->rts_state) ? TIOCM_RTS : 0) | in hso_serial_tiocmget()
1636 ((serial->dtr_state) ? TIOCM_DTR : 0); in hso_serial_tiocmget()
1637 tiocmget = serial->tiocmget; in hso_serial_tiocmget()
1641 tiocmget->prev_UART_state_bitmap); in hso_serial_tiocmget()
1649 spin_unlock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1659 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmset()
1665 return -EINVAL; in hso_serial_tiocmset()
1668 if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) in hso_serial_tiocmset()
1669 return -EINVAL; in hso_serial_tiocmset()
1671 interface = serial->parent->interface; in hso_serial_tiocmset()
1672 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_serial_tiocmset()
1674 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_tiocmset()
1676 serial->rts_state = 1; in hso_serial_tiocmset()
1678 serial->dtr_state = 1; in hso_serial_tiocmset()
1681 serial->rts_state = 0; in hso_serial_tiocmset()
1683 serial->dtr_state = 0; in hso_serial_tiocmset()
1685 if (serial->dtr_state) in hso_serial_tiocmset()
1687 if (serial->rts_state) in hso_serial_tiocmset()
1690 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_tiocmset()
1692 return usb_control_msg(serial->parent->usb, in hso_serial_tiocmset()
1693 usb_rcvctrlpipe(serial->parent->usb, 0), 0x22, in hso_serial_tiocmset()
1701 struct hso_serial *serial = tty->driver_data; in hso_serial_ioctl()
1706 return -ENODEV; in hso_serial_ioctl()
1712 ret = -ENOIOCTLCMD; in hso_serial_ioctl()
1725 spin_lock_irqsave(&serial->serial_lock, flags); in hso_kick_transmit()
1726 if (!serial->tx_buffer_count) in hso_kick_transmit()
1729 if (serial->tx_urb_used) in hso_kick_transmit()
1733 if (hso_get_activity(serial->parent) == -EAGAIN) in hso_kick_transmit()
1737 swap(serial->tx_buffer, serial->tx_data); in hso_kick_transmit()
1738 serial->tx_data_count = serial->tx_buffer_count; in hso_kick_transmit()
1739 serial->tx_buffer_count = 0; in hso_kick_transmit()
1741 /* If serial->tx_data is set, it means we switched buffers */ in hso_kick_transmit()
1742 if (serial->tx_data && serial->write_data) { in hso_kick_transmit()
1743 res = serial->write_data(serial); in hso_kick_transmit()
1745 serial->tx_urb_used = 1; in hso_kick_transmit()
1748 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_kick_transmit()
1763 return -EINVAL; in mux_device_request()
1767 ctrl_req->wValue = 0; in mux_device_request()
1768 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); in mux_device_request()
1769 ctrl_req->wLength = cpu_to_le16(size); in mux_device_request()
1773 ctrl_req->bRequestType = USB_DIR_IN | in mux_device_request()
1776 ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; in mux_device_request()
1777 pipe = usb_rcvctrlpipe(serial->parent->usb, 0); in mux_device_request()
1780 ctrl_req->bRequestType = USB_DIR_OUT | in mux_device_request()
1783 ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; in mux_device_request()
1784 pipe = usb_sndctrlpipe(serial->parent->usb, 0); in mux_device_request()
1789 ctrl_req->bRequestType, ctrl_req->wLength, port); in mux_device_request()
1792 ctrl_urb->transfer_flags = 0; in mux_device_request()
1794 serial->parent->usb, in mux_device_request()
1801 dev_err(&ctrl_urb->dev->dev, in mux_device_request()
1815 return -EINVAL; in hso_mux_serial_read()
1818 memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); in hso_mux_serial_read()
1821 if (serial->num_rx_urbs != 1) { in hso_mux_serial_read()
1822 dev_err(&serial->parent->interface->dev, in hso_mux_serial_read()
1829 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_read()
1830 serial->rx_urb[0], in hso_mux_serial_read()
1831 &serial->ctrl_req_rx, in hso_mux_serial_read()
1832 serial->rx_data[0], serial->rx_data_length); in hso_mux_serial_read()
1838 struct hso_shared_int *shared_int = urb->context; in intr_callback()
1841 int status = urb->status; in intr_callback()
1845 usb_mark_last_busy(urb->dev); in intr_callback()
1856 hso_dbg(0x8, "--- Got intr callback 0x%02X ---\n", status); in intr_callback()
1859 port_req = urb->transfer_buffer; in intr_callback()
1870 spin_lock_irqsave(&serial->serial_lock, flags); in intr_callback()
1871 if (serial->rx_state == RX_IDLE && in intr_callback()
1872 serial->port.count > 0) { in intr_callback()
1875 if (!serial->rx_urb_filled[0]) { in intr_callback()
1876 serial->rx_state = RX_SENT; in intr_callback()
1879 serial->rx_state = RX_PENDING; in intr_callback()
1884 spin_unlock_irqrestore(&serial->serial_lock, in intr_callback()
1890 hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); in intr_callback()
1897 return -EINVAL; in hso_mux_serial_write_data()
1901 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_write_data()
1902 serial->tx_urb, in hso_mux_serial_write_data()
1903 &serial->ctrl_req_tx, in hso_mux_serial_write_data()
1904 serial->tx_data, serial->tx_data_count); in hso_mux_serial_write_data()
1910 struct hso_serial *serial = urb->context; in hso_std_serial_write_bulk_callback()
1911 int status = urb->status; in hso_std_serial_write_bulk_callback()
1920 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1921 serial->tx_urb_used = 0; in hso_std_serial_write_bulk_callback()
1922 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1924 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_write_bulk_callback()
1927 hso_put_activity(serial->parent); in hso_std_serial_write_bulk_callback()
1928 tty_port_tty_wakeup(&serial->port); in hso_std_serial_write_bulk_callback()
1937 int count = serial->tx_data_count; in hso_std_serial_write_data()
1940 usb_fill_bulk_urb(serial->tx_urb, in hso_std_serial_write_data()
1941 serial->parent->usb, in hso_std_serial_write_data()
1942 usb_sndbulkpipe(serial->parent->usb, in hso_std_serial_write_data()
1943 serial->out_endp-> in hso_std_serial_write_data()
1945 serial->tx_data, serial->tx_data_count, in hso_std_serial_write_data()
1948 result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); in hso_std_serial_write_data()
1950 dev_warn(&serial->parent->usb->dev, in hso_std_serial_write_data()
1951 "Failed to submit urb - res %d\n", result); in hso_std_serial_write_data()
1961 struct hso_serial *serial = urb->context; in ctrl_callback()
1963 int status = urb->status; in ctrl_callback()
1970 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1971 serial->tx_urb_used = 0; in ctrl_callback()
1972 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1974 handle_usb_error(status, __func__, serial->parent); in ctrl_callback()
1979 req = (struct usb_ctrlrequest *)(urb->setup_packet); in ctrl_callback()
1980 hso_dbg(0x8, "--- Got muxed ctrl callback 0x%02X ---\n", status); in ctrl_callback()
1981 hso_dbg(0x8, "Actual length of urb = %d\n", urb->actual_length); in ctrl_callback()
1982 DUMP1(urb->transfer_buffer, urb->actual_length); in ctrl_callback()
1984 if (req->bRequestType == in ctrl_callback()
1987 serial->rx_urb_filled[0] = 1; in ctrl_callback()
1988 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1990 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1992 hso_put_activity(serial->parent); in ctrl_callback()
1993 tty_port_tty_wakeup(&serial->port); in ctrl_callback()
2008 return -2; in put_rxbuf_data()
2011 tty = tty_port_tty_get(&serial->port); in put_rxbuf_data()
2015 return -1; in put_rxbuf_data()
2020 count = tty_buffer_request_room(&serial->port, urb->actual_length); in put_rxbuf_data()
2021 if (count >= urb->actual_length) { in put_rxbuf_data()
2022 tty_insert_flip_string(&serial->port, urb->transfer_buffer, in put_rxbuf_data()
2023 urb->actual_length); in put_rxbuf_data()
2024 tty_flip_buffer_push(&serial->port); in put_rxbuf_data()
2026 dev_warn(&serial->parent->usb->dev, in put_rxbuf_data()
2027 "dropping data, %d bytes lost\n", urb->actual_length); in put_rxbuf_data()
2032 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; in put_rxbuf_data()
2045 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_log_port()
2080 if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { in hso_log_port()
2081 sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); in hso_log_port()
2084 dev2ser(hso_dev)->minor); in hso_log_port()
2086 dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", in hso_log_port()
2096 return -ENODEV; in hso_start_net_device()
2102 usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2103 hso_dev->usb, in hso_start_net_device()
2104 usb_rcvbulkpipe(hso_dev->usb, in hso_start_net_device()
2105 hso_net->in_endp-> in hso_start_net_device()
2107 hso_net->mux_bulk_rx_buf_pool[i], in hso_start_net_device()
2112 result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2115 dev_warn(&hso_dev->usb->dev, in hso_start_net_device()
2129 return -ENODEV; in hso_stop_net_device()
2132 if (hso_net->mux_bulk_rx_urb_pool[i]) in hso_stop_net_device()
2133 usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_stop_net_device()
2136 if (hso_net->mux_bulk_tx_urb) in hso_stop_net_device()
2137 usb_kill_urb(hso_net->mux_bulk_tx_urb); in hso_stop_net_device()
2148 return -ENODEV; in hso_start_serial_device()
2152 if (!(serial->parent->port_spec & HSO_INTF_MUX)) { in hso_start_serial_device()
2153 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_start_serial_device()
2154 usb_fill_bulk_urb(serial->rx_urb[i], in hso_start_serial_device()
2155 serial->parent->usb, in hso_start_serial_device()
2156 usb_rcvbulkpipe(serial->parent->usb, in hso_start_serial_device()
2157 serial->in_endp-> in hso_start_serial_device()
2160 serial->rx_data[i], in hso_start_serial_device()
2161 serial->rx_data_length, in hso_start_serial_device()
2164 result = usb_submit_urb(serial->rx_urb[i], flags); in hso_start_serial_device()
2166 dev_warn(&serial->parent->usb->dev, in hso_start_serial_device()
2167 "Failed to submit urb - res %d\n", in hso_start_serial_device()
2173 mutex_lock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2174 if (!serial->shared_int->use_count) { in hso_start_serial_device()
2176 hso_mux_submit_intr_urb(serial->shared_int, in hso_start_serial_device()
2177 hso_dev->usb, flags); in hso_start_serial_device()
2179 serial->shared_int->use_count++; in hso_start_serial_device()
2180 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2182 if (serial->tiocmget) in hso_start_serial_device()
2184 serial->tiocmget, in hso_start_serial_device()
2185 serial->parent->usb); in hso_start_serial_device()
2196 return -ENODEV; in hso_stop_serial_device()
2198 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_stop_serial_device()
2199 if (serial->rx_urb[i]) { in hso_stop_serial_device()
2200 usb_kill_urb(serial->rx_urb[i]); in hso_stop_serial_device()
2201 serial->rx_urb_filled[i] = 0; in hso_stop_serial_device()
2204 serial->curr_rx_urb_idx = 0; in hso_stop_serial_device()
2206 if (serial->tx_urb) in hso_stop_serial_device()
2207 usb_kill_urb(serial->tx_urb); in hso_stop_serial_device()
2209 if (serial->shared_int) { in hso_stop_serial_device()
2210 mutex_lock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2211 if (serial->shared_int->use_count && in hso_stop_serial_device()
2212 (--serial->shared_int->use_count == 0)) { in hso_stop_serial_device()
2215 urb = serial->shared_int->shared_intr_urb; in hso_stop_serial_device()
2219 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2221 tiocmget = serial->tiocmget; in hso_stop_serial_device()
2223 wake_up_interruptible(&tiocmget->waitq); in hso_stop_serial_device()
2224 usb_kill_urb(tiocmget->urb); in hso_stop_serial_device()
2232 tty_unregister_device(tty_drv, serial->minor); in hso_serial_tty_unregister()
2239 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_free()
2241 usb_free_urb(serial->rx_urb[i]); in hso_serial_common_free()
2243 kfree(serial->rx_data[i]); in hso_serial_common_free()
2247 usb_free_urb(serial->tx_urb); in hso_serial_common_free()
2248 kfree(serial->tx_buffer); in hso_serial_common_free()
2249 kfree(serial->tx_data); in hso_serial_common_free()
2250 tty_port_destroy(&serial->port); in hso_serial_common_free()
2259 tty_port_init(&serial->port); in hso_serial_common_create()
2266 serial->parent->dev = tty_port_register_device_attr(&serial->port, in hso_serial_common_create()
2267 tty_drv, minor, &serial->parent->interface->dev, in hso_serial_common_create()
2268 serial->parent, hso_serial_dev_groups); in hso_serial_common_create()
2269 if (IS_ERR(serial->parent->dev)) in hso_serial_common_create()
2273 serial->minor = minor; in hso_serial_common_create()
2274 serial->magic = HSO_SERIAL_MAGIC; in hso_serial_common_create()
2275 spin_lock_init(&serial->serial_lock); in hso_serial_common_create()
2276 serial->num_rx_urbs = num_urbs; in hso_serial_common_create()
2281 serial->rx_data_length = rx_size; in hso_serial_common_create()
2282 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_create()
2283 serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2284 if (!serial->rx_urb[i]) in hso_serial_common_create()
2286 serial->rx_urb[i]->transfer_buffer = NULL; in hso_serial_common_create()
2287 serial->rx_urb[i]->transfer_buffer_length = 0; in hso_serial_common_create()
2288 serial->rx_data[i] = kzalloc(serial->rx_data_length, in hso_serial_common_create()
2290 if (!serial->rx_data[i]) in hso_serial_common_create()
2295 serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2296 if (!serial->tx_urb) in hso_serial_common_create()
2298 serial->tx_urb->transfer_buffer = NULL; in hso_serial_common_create()
2299 serial->tx_urb->transfer_buffer_length = 0; in hso_serial_common_create()
2301 serial->tx_data_count = 0; in hso_serial_common_create()
2302 serial->tx_buffer_count = 0; in hso_serial_common_create()
2303 serial->tx_data_length = tx_size; in hso_serial_common_create()
2304 serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2305 if (!serial->tx_data) in hso_serial_common_create()
2308 serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2309 if (!serial->tx_buffer) in hso_serial_common_create()
2317 return -1; in hso_serial_common_create()
2330 hso_dev->port_spec = port_spec; in hso_create_device()
2331 hso_dev->usb = interface_to_usbdev(intf); in hso_create_device()
2332 hso_dev->interface = intf; in hso_create_device()
2333 kref_init(&hso_dev->ref); in hso_create_device()
2334 mutex_init(&hso_dev->mutex); in hso_create_device()
2336 INIT_WORK(&hso_dev->async_get_intf, async_get_intf); in hso_create_device()
2337 INIT_WORK(&hso_dev->async_put_intf, async_put_intf); in hso_create_device()
2354 return -1; in remove_net_device()
2367 remove_net_device(hso_net->parent); in hso_free_net_device()
2369 if (hso_net->net) in hso_free_net_device()
2370 unregister_netdev(hso_net->net); in hso_free_net_device()
2374 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_free_net_device()
2375 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_free_net_device()
2376 hso_net->mux_bulk_rx_buf_pool[i] = NULL; in hso_free_net_device()
2378 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_free_net_device()
2379 kfree(hso_net->mux_bulk_tx_buf); in hso_free_net_device()
2380 hso_net->mux_bulk_tx_buf = NULL; in hso_free_net_device()
2382 if (hso_net->net && !bailout) in hso_free_net_device()
2383 free_netdev(hso_net->net); in hso_free_net_device()
2403 net->netdev_ops = &hso_netdev_ops; in hso_net_init()
2404 net->watchdog_timeo = HSO_NET_TX_TIMEOUT; in hso_net_init()
2405 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; in hso_net_init()
2406 net->type = ARPHRD_NONE; in hso_net_init()
2407 net->mtu = DEFAULT_MTU - 14; in hso_net_init()
2408 net->tx_queue_len = 10; in hso_net_init()
2409 net->ethtool_ops = &ops; in hso_net_init()
2412 spin_lock_init(&hso_net->net_lock); in hso_net_init()
2427 return -1; in add_net_device()
2437 mutex_lock(&hso_dev->mutex); in hso_rfkill_set_block()
2438 if (hso_dev->usb_gone) in hso_rfkill_set_block()
2441 rv = usb_control_msg(hso_dev->usb, usb_rcvctrlpipe(hso_dev->usb, 0), in hso_rfkill_set_block()
2444 mutex_unlock(&hso_dev->mutex); in hso_rfkill_set_block()
2457 struct device *dev = &hso_net->net->dev; in hso_create_rfkill()
2460 snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d", in hso_create_rfkill()
2463 hso_net->rfkill = rfkill_alloc(hso_net->name, in hso_create_rfkill()
2464 &interface_to_usbdev(interface)->dev, in hso_create_rfkill()
2467 if (!hso_net->rfkill) in hso_create_rfkill()
2470 if (rfkill_register(hso_net->rfkill) < 0) { in hso_create_rfkill()
2471 rfkill_destroy(hso_net->rfkill); in hso_create_rfkill()
2472 hso_net->rfkill = NULL; in hso_create_rfkill()
2473 dev_err(dev, "%s - Failed to register rfkill\n", __func__); in hso_create_rfkill()
2500 dev_err(&interface->dev, "Unable to create ethernet device\n"); in hso_create_net_device()
2506 hso_dev->port_data.dev_net = hso_net; in hso_create_net_device()
2507 hso_net->net = net; in hso_create_net_device()
2508 hso_net->parent = hso_dev; in hso_create_net_device()
2510 hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2512 if (!hso_net->in_endp) { in hso_create_net_device()
2513 dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); in hso_create_net_device()
2516 hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2518 if (!hso_net->out_endp) { in hso_create_net_device()
2519 dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); in hso_create_net_device()
2522 SET_NETDEV_DEV(net, &interface->dev); in hso_create_net_device()
2527 hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2528 if (!hso_net->mux_bulk_rx_urb_pool[i]) in hso_create_net_device()
2530 hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, in hso_create_net_device()
2532 if (!hso_net->mux_bulk_rx_buf_pool[i]) in hso_create_net_device()
2535 hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2536 if (!hso_net->mux_bulk_tx_urb) in hso_create_net_device()
2538 hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); in hso_create_net_device()
2539 if (!hso_net->mux_bulk_tx_buf) in hso_create_net_device()
2547 dev_err(&interface->dev, "Failed to register device\n"); in hso_create_net_device()
2566 tiocmget = serial->tiocmget; in hso_free_tiomget()
2568 usb_free_urb(tiocmget->urb); in hso_free_tiomget()
2569 tiocmget->urb = NULL; in hso_free_tiomget()
2570 serial->tiocmget = NULL; in hso_free_tiomget()
2571 kfree(tiocmget->serial_state_notification); in hso_free_tiomget()
2572 tiocmget->serial_state_notification = NULL; in hso_free_tiomget()
2577 /* Frees an AT channel ( goes for both mux and non-mux ) */
2587 if (serial->shared_int) { in hso_free_serial_device()
2588 mutex_lock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2589 if (--serial->shared_int->ref_count == 0) in hso_free_serial_device()
2590 hso_free_shared_int(serial->shared_int); in hso_free_serial_device()
2592 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2616 serial->parent = hso_dev; in hso_create_bulk_serial_device()
2617 hso_dev->port_data.dev_serial = serial; in hso_create_bulk_serial_device()
2621 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), in hso_create_bulk_serial_device()
2623 serial->tiocmget->serial_state_notification in hso_create_bulk_serial_device()
2626 /* it isn't going to break our heart if serial->tiocmget in hso_create_bulk_serial_device()
2629 if (serial->tiocmget && serial->tiocmget->serial_state_notification) { in hso_create_bulk_serial_device()
2630 tiocmget = serial->tiocmget; in hso_create_bulk_serial_device()
2631 tiocmget->endp = hso_get_ep(interface, in hso_create_bulk_serial_device()
2634 if (!tiocmget->endp) { in hso_create_bulk_serial_device()
2635 dev_err(&interface->dev, "Failed to find INT IN ep\n"); in hso_create_bulk_serial_device()
2639 tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_bulk_serial_device()
2640 if (tiocmget->urb) { in hso_create_bulk_serial_device()
2641 mutex_init(&tiocmget->mutex); in hso_create_bulk_serial_device()
2642 init_waitqueue_head(&tiocmget->waitq); in hso_create_bulk_serial_device()
2654 serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_bulk_serial_device()
2656 if (!serial->in_endp) { in hso_create_bulk_serial_device()
2657 dev_err(&interface->dev, "Failed to find BULK IN ep\n"); in hso_create_bulk_serial_device()
2662 (serial->out_endp = in hso_create_bulk_serial_device()
2664 dev_err(&interface->dev, "Failed to find BULK OUT ep\n"); in hso_create_bulk_serial_device()
2668 serial->write_data = hso_std_serial_write_data; in hso_create_bulk_serial_device()
2671 set_serial_by_index(serial->minor, serial); in hso_create_bulk_serial_device()
2714 hso_dev->port_data.dev_serial = serial; in hso_create_mux_serial_device()
2715 serial->parent = hso_dev; in hso_create_mux_serial_device()
2721 serial->tx_data_length--; in hso_create_mux_serial_device()
2722 serial->write_data = hso_mux_serial_write_data; in hso_create_mux_serial_device()
2724 serial->shared_int = mux; in hso_create_mux_serial_device()
2725 mutex_lock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2726 serial->shared_int->ref_count++; in hso_create_mux_serial_device()
2727 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2730 set_serial_by_index(serial->minor, serial); in hso_create_mux_serial_device()
2740 tty_unregister_device(tty_drv, serial->minor); in hso_create_mux_serial_device()
2750 usb_free_urb(mux->shared_intr_urb); in hso_free_shared_int()
2751 kfree(mux->shared_intr_buf); in hso_free_shared_int()
2752 mutex_unlock(&mux->shared_int_lock); in hso_free_shared_int()
2764 mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, in hso_create_shared_int()
2766 if (!mux->intr_endp) { in hso_create_shared_int()
2767 dev_err(&interface->dev, "Can't find INT IN endpoint\n"); in hso_create_shared_int()
2771 mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_shared_int()
2772 if (!mux->shared_intr_urb) in hso_create_shared_int()
2774 mux->shared_intr_buf = in hso_create_shared_int()
2775 kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), in hso_create_shared_int()
2777 if (!mux->shared_intr_buf) in hso_create_shared_int()
2780 mutex_init(&mux->shared_int_lock); in hso_create_shared_int()
2785 kfree(mux->shared_intr_buf); in hso_create_shared_int()
2786 usb_free_urb(mux->shared_intr_urb); in hso_create_shared_int()
2796 u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_get_config_data()
2800 return -ENOMEM; in hso_get_config_data()
2805 return -EIO; in hso_get_config_data()
2811 return -EINVAL; in hso_get_config_data()
2875 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { in hso_probe()
2876 dev_err(&interface->dev, "Not our interface\n"); in hso_probe()
2877 return -ENODEV; in hso_probe()
2880 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_probe()
2884 if (id->driver_info) { in hso_probe()
2888 if (((u32 *)(id->driver_info))[i] == 0) in hso_probe()
2890 port_spec = ((u32 *)(id->driver_info))[if_num]; in hso_probe()
2899 if (interface->num_altsetting > 1) in hso_probe()
2901 interface->needs_remote_wakeup = 1; in hso_probe()
2918 /* TODO: de-allocate everything */ in hso_probe()
2962 return -ENODEV; in hso_probe()
2978 usb_autopm_get_interface(hso_dev->interface); in async_get_intf()
2985 usb_autopm_put_interface(hso_dev->interface); in async_put_intf()
2990 if (hso_dev->usb->state == USB_STATE_SUSPENDED) { in hso_get_activity()
2991 if (!hso_dev->is_active) { in hso_get_activity()
2992 hso_dev->is_active = 1; in hso_get_activity()
2993 schedule_work(&hso_dev->async_get_intf); in hso_get_activity()
2997 if (hso_dev->usb->state != USB_STATE_CONFIGURED) in hso_get_activity()
2998 return -EAGAIN; in hso_get_activity()
3000 usb_mark_last_busy(hso_dev->usb); in hso_get_activity()
3007 if (hso_dev->usb->state != USB_STATE_SUSPENDED) { in hso_put_activity()
3008 if (hso_dev->is_active) { in hso_put_activity()
3009 hso_dev->is_active = 0; in hso_put_activity()
3010 schedule_work(&hso_dev->async_put_intf); in hso_put_activity()
3011 return -EAGAIN; in hso_put_activity()
3014 hso_dev->is_active = 0; in hso_put_activity()
3025 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_suspend()
3035 (network_table[i]->interface == iface)) { in hso_suspend()
3054 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_resume()
3055 if (dev2ser(serial_table[i])->port.count) { in hso_resume()
3068 (network_table[i]->interface == iface)) { in hso_resume()
3070 if (hso_net->flags & IFF_UP) { in hso_resume()
3073 if (hso_net->skb_tx_buf) { in hso_resume()
3074 dev_dbg(&iface->dev, in hso_resume()
3077 hso_net_start_xmit(hso_net->skb_tx_buf, in hso_resume()
3078 hso_net->net); in hso_resume()
3079 hso_net->skb_tx_buf = NULL; in hso_resume()
3106 (serial_table[i]->interface == interface)) { in hso_free_interface()
3108 tty_port_tty_hangup(&serial->port, false); in hso_free_interface()
3109 mutex_lock(&serial->parent->mutex); in hso_free_interface()
3110 serial->parent->usb_gone = 1; in hso_free_interface()
3111 mutex_unlock(&serial->parent->mutex); in hso_free_interface()
3112 cancel_work_sync(&serial_table[i]->async_put_intf); in hso_free_interface()
3113 cancel_work_sync(&serial_table[i]->async_get_intf); in hso_free_interface()
3115 kref_put(&serial_table[i]->ref, hso_serial_ref_free); in hso_free_interface()
3122 (network_table[i]->interface == interface)) { in hso_free_interface()
3123 struct rfkill *rfk = dev2net(network_table[i])->rfkill; in hso_free_interface()
3126 netif_stop_queue(dev2net(network_table[i])->net); in hso_free_interface()
3128 cancel_work_sync(&network_table[i]->async_put_intf); in hso_free_interface()
3129 cancel_work_sync(&network_table[i]->async_get_intf); in hso_free_interface()
3146 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_ep()
3149 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_ep()
3150 endp = &iface->endpoint[i].desc; in hso_get_ep()
3151 if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && in hso_get_ep()
3163 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_mux_ports()
3165 if (iface->extralen == 3) { in hso_get_mux_ports()
3166 *ports = iface->extra[2]; in hso_get_mux_ports()
3170 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_mux_ports()
3171 if (iface->endpoint[i].extralen == 3) { in hso_get_mux_ports()
3172 *ports = iface->endpoint[i].extra[2]; in hso_get_mux_ports()
3177 return -1; in hso_get_mux_ports()
3186 usb_fill_int_urb(shared_int->shared_intr_urb, usb, in hso_mux_submit_intr_urb()
3188 shared_int->intr_endp->bEndpointAddress & 0x7F), in hso_mux_submit_intr_urb()
3189 shared_int->shared_intr_buf, in hso_mux_submit_intr_urb()
3192 shared_int->intr_endp->bInterval); in hso_mux_submit_intr_urb()
3194 result = usb_submit_urb(shared_int->shared_intr_urb, gfp); in hso_mux_submit_intr_urb()
3196 dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, in hso_mux_submit_intr_urb()
3246 return -ENOMEM; in hso_init()
3249 tty_drv->driver_name = driver_name; in hso_init()
3250 tty_drv->name = tty_filename; in hso_init()
3254 tty_drv->major = tty_major; in hso_init()
3256 tty_drv->minor_start = 0; in hso_init()
3257 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; in hso_init()
3258 tty_drv->subtype = SERIAL_TYPE_NORMAL; in hso_init()
3259 tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; in hso_init()
3260 tty_drv->init_termios = tty_std_termios; in hso_init()
3261 hso_init_termios(&tty_drv->init_termios); in hso_init()
3267 pr_err("%s - tty_register_driver failed(%d)\n", in hso_init()
3275 pr_err("Could not register hso driver - error: %d\n", result); in hso_init()