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 */
469 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hsotype_show()
520 for (idx = 0; idx < serial->num_rx_urbs; idx++) in hso_urb_to_index()
521 if (serial->rx_urb[idx] == urb) in hso_urb_to_index()
523 dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); in hso_urb_to_index()
524 return -1; in hso_urb_to_index()
591 (dev2ser(serial_table[i])->shared_int == shared_int) && in get_serial_by_shared_int_and_type()
592 ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { in get_serial_by_shared_int_and_type()
621 serial_table[index] = serial->parent; in obtain_minor()
622 serial->minor = index; in obtain_minor()
630 return -1; in obtain_minor()
638 serial_table[serial->minor] = NULL; in release_minor()
648 case -ENODEV: in handle_usb_error()
651 case -ENOENT: in handle_usb_error()
654 case -EPIPE: in handle_usb_error()
657 case -ENOSPC: in handle_usb_error()
660 case -ESHUTDOWN: in handle_usb_error()
663 case -EHOSTUNREACH: in handle_usb_error()
666 case -EINVAL: in handle_usb_error()
667 case -EAGAIN: in handle_usb_error()
668 case -EFBIG: in handle_usb_error()
669 case -EMSGSIZE: in handle_usb_error()
672 case -EILSEQ: in handle_usb_error()
673 case -EPROTO: in handle_usb_error()
674 case -ETIME: in handle_usb_error()
675 case -ETIMEDOUT: in handle_usb_error()
678 usb_queue_reset_device(hso_dev->interface); in handle_usb_error()
686 hso_dbg(0x1, "%s: received USB status - %s (%d)\n", in handle_usb_error()
699 dev_err(&net->dev, "No net device !\n"); in hso_net_open()
700 return -ENODEV; in hso_net_open()
703 odev->skb_tx_buf = NULL; in hso_net_open()
706 spin_lock_irqsave(&odev->net_lock, flags); in hso_net_open()
707 odev->rx_parse_state = WAIT_IP; in hso_net_open()
708 odev->rx_buf_size = 0; in hso_net_open()
709 odev->rx_buf_missing = sizeof(struct iphdr); in hso_net_open()
710 spin_unlock_irqrestore(&odev->net_lock, flags); in hso_net_open()
713 set_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_open()
714 hso_start_net_device(odev->parent); in hso_net_open()
730 clear_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_close()
732 hso_stop_net_device(odev->parent); in hso_net_close()
741 struct hso_net *odev = urb->context; in write_bulk_callback()
742 int status = urb->status; in write_bulk_callback()
745 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in write_bulk_callback()
746 dev_err(&urb->dev->dev, "%s: device not running\n", __func__); in write_bulk_callback()
751 if (!netif_device_present(odev->net)) { in write_bulk_callback()
752 dev_err(&urb->dev->dev, "%s: net device not present\n", in write_bulk_callback()
760 handle_usb_error(status, __func__, odev->parent); in write_bulk_callback()
762 hso_put_activity(odev->parent); in write_bulk_callback()
765 netif_wake_queue(odev->net); in write_bulk_callback()
777 if (hso_get_activity(odev->parent) == -EAGAIN) { in hso_net_start_xmit()
778 odev->skb_tx_buf = skb; in hso_net_start_xmit()
783 DUMP1(skb->data, skb->len); in hso_net_start_xmit()
785 memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); in hso_net_start_xmit()
786 hso_dbg(0x1, "len: %d/%d\n", skb->len, MUX_BULK_TX_BUF_SIZE); in hso_net_start_xmit()
789 usb_fill_bulk_urb(odev->mux_bulk_tx_urb, in hso_net_start_xmit()
790 odev->parent->usb, in hso_net_start_xmit()
791 usb_sndbulkpipe(odev->parent->usb, in hso_net_start_xmit()
792 odev->out_endp-> in hso_net_start_xmit()
794 odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, in hso_net_start_xmit()
798 odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; in hso_net_start_xmit()
801 result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); in hso_net_start_xmit()
803 dev_warn(&odev->parent->interface->dev, in hso_net_start_xmit()
805 net->stats.tx_errors++; in hso_net_start_xmit()
808 net->stats.tx_packets++; in hso_net_start_xmit()
809 net->stats.tx_bytes += skb->len; in hso_net_start_xmit()
829 dev_warn(&net->dev, "Tx timed out.\n"); in hso_net_tx_timeout()
832 if (odev->mux_bulk_tx_urb) in hso_net_tx_timeout()
833 usb_unlink_urb(odev->mux_bulk_tx_urb); in hso_net_tx_timeout()
836 net->stats.tx_errors++; in hso_net_tx_timeout()
852 switch (odev->rx_parse_state) { in packetizeRx()
855 /* wanted bytes - size of ip header */ in packetizeRx()
858 odev->rx_buf_missing) ? count : odev-> in packetizeRx()
861 memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + in packetizeRx()
862 odev->rx_buf_size, ip_pkt + buffer_offset, in packetizeRx()
865 odev->rx_buf_size += temp_bytes; in packetizeRx()
867 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
868 count -= temp_bytes; in packetizeRx()
870 if (!odev->rx_buf_missing) { in packetizeRx()
873 frame_len = ntohs(odev->rx_ip_hdr.tot_len); in packetizeRx()
877 dev_err(&odev->net->dev, in packetizeRx()
880 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
884 odev->skb_rx_buf = netdev_alloc_skb(odev->net, in packetizeRx()
886 if (!odev->skb_rx_buf) { in packetizeRx()
889 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
895 skb_put_data(odev->skb_rx_buf, in packetizeRx()
896 (char *)&(odev->rx_ip_hdr), in packetizeRx()
900 odev->rx_buf_size = sizeof(struct iphdr); in packetizeRx()
903 odev->rx_buf_missing = in packetizeRx()
904 frame_len - sizeof(struct iphdr); in packetizeRx()
905 odev->rx_parse_state = WAIT_DATA; in packetizeRx()
910 temp_bytes = (count < odev->rx_buf_missing) in packetizeRx()
911 ? count : odev->rx_buf_missing; in packetizeRx()
916 skb_put_data(odev->skb_rx_buf, in packetizeRx()
920 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
921 count -= temp_bytes; in packetizeRx()
923 odev->rx_buf_size += temp_bytes; in packetizeRx()
924 if (!odev->rx_buf_missing) { in packetizeRx()
927 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); in packetizeRx()
928 skb_reset_mac_header(odev->skb_rx_buf); in packetizeRx()
931 netif_rx(odev->skb_rx_buf); in packetizeRx()
933 odev->skb_rx_buf = NULL; in packetizeRx()
936 odev->net->stats.rx_packets++; in packetizeRx()
938 odev->net->stats.rx_bytes += odev->rx_buf_size; in packetizeRx()
940 odev->rx_buf_size = 0; in packetizeRx()
941 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
942 odev->rx_parse_state = WAIT_IP; in packetizeRx()
952 count--; in packetizeRx()
959 if (odev->rx_parse_state == WAIT_SYNC) { in packetizeRx()
960 odev->rx_parse_state = WAIT_IP; in packetizeRx()
961 odev->rx_buf_size = 0; in packetizeRx()
962 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
970 u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); in fix_crc_bug()
973 !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, in fix_crc_bug()
975 urb->actual_length -= 4; in fix_crc_bug()
982 struct hso_net *odev = urb->context; in read_bulk_callback()
986 int status = urb->status; in read_bulk_callback()
990 handle_usb_error(status, __func__, odev->parent); in read_bulk_callback()
995 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in read_bulk_callback()
999 usb_mark_last_busy(urb->dev); in read_bulk_callback()
1001 net = odev->net; in read_bulk_callback()
1008 if (odev->parent->port_spec & HSO_INFO_CRC_BUG) in read_bulk_callback()
1009 fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); in read_bulk_callback()
1012 if (urb->actual_length) { in read_bulk_callback()
1015 spin_lock_irqsave(&odev->net_lock, flags); in read_bulk_callback()
1016 packetizeRx(odev, urb->transfer_buffer, urb->actual_length, in read_bulk_callback()
1017 (urb->transfer_buffer_length > in read_bulk_callback()
1018 urb->actual_length) ? 1 : 0); in read_bulk_callback()
1019 spin_unlock_irqrestore(&odev->net_lock, flags); in read_bulk_callback()
1025 odev->parent->usb, in read_bulk_callback()
1026 usb_rcvbulkpipe(odev->parent->usb, in read_bulk_callback()
1027 odev->in_endp-> in read_bulk_callback()
1029 urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, in read_bulk_callback()
1036 dev_warn(&odev->parent->interface->dev, in read_bulk_callback()
1048 termios->c_iflag &= in hso_init_termios()
1059 termios->c_oflag &= ~OPOST; in hso_init_termios()
1061 termios->c_lflag &= in hso_init_termios()
1068 | IEXTEN); /* disable non-POSIX special characters */ in hso_init_termios()
1070 termios->c_cflag &= in hso_init_termios()
1076 termios->c_cflag |= CS8; /* character size 8 bits */ in hso_init_termios()
1084 struct hso_serial *serial = tty->driver_data; in _hso_serial_set_termios()
1091 hso_dbg(0x8, "port %d\n", serial->minor); in _hso_serial_set_termios()
1096 tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ in _hso_serial_set_termios()
1098 tty->termios.c_cflag &= in _hso_serial_set_termios()
1104 tty->termios.c_cflag |= CS8; /* character size 8 bits */ in _hso_serial_set_termios()
1115 usb_fill_bulk_urb(urb, serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1116 usb_rcvbulkpipe(serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1117 serial->in_endp-> in hso_resubmit_rx_bulk_urb()
1119 urb->transfer_buffer, serial->rx_data_length, in hso_resubmit_rx_bulk_urb()
1125 dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", in hso_resubmit_rx_bulk_urb()
1138 while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { in put_rxbuf_data_and_resubmit_bulk_urb()
1139 curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; in put_rxbuf_data_and_resubmit_bulk_urb()
1141 if (count == -1) in put_rxbuf_data_and_resubmit_bulk_urb()
1144 serial->curr_rx_urb_idx++; in put_rxbuf_data_and_resubmit_bulk_urb()
1145 if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) in put_rxbuf_data_and_resubmit_bulk_urb()
1146 serial->curr_rx_urb_idx = 0; in put_rxbuf_data_and_resubmit_bulk_urb()
1157 urb = serial->rx_urb[0]; in put_rxbuf_data_and_resubmit_ctrl_urb()
1158 if (serial->port.count > 0) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1160 if (count == -1) in put_rxbuf_data_and_resubmit_ctrl_urb()
1165 if (count == 0 && ((urb->actual_length != 0) || in put_rxbuf_data_and_resubmit_ctrl_urb()
1166 (serial->rx_state == RX_PENDING))) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1167 serial->rx_state = RX_SENT; in put_rxbuf_data_and_resubmit_ctrl_urb()
1170 serial->rx_state = RX_IDLE; in put_rxbuf_data_and_resubmit_ctrl_urb()
1177 struct hso_serial *serial = urb->context; in hso_std_serial_read_bulk_callback()
1178 int status = urb->status; in hso_std_serial_read_bulk_callback()
1181 hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status); in hso_std_serial_read_bulk_callback()
1189 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_read_bulk_callback()
1193 hso_dbg(0x1, "Actual length = %d\n", urb->actual_length); in hso_std_serial_read_bulk_callback()
1194 DUMP1(urb->transfer_buffer, urb->actual_length); in hso_std_serial_read_bulk_callback()
1197 if (serial->port.count == 0) in hso_std_serial_read_bulk_callback()
1200 if (serial->parent->port_spec & HSO_INFO_CRC_BUG) in hso_std_serial_read_bulk_callback()
1201 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); in hso_std_serial_read_bulk_callback()
1203 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1204 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; in hso_std_serial_read_bulk_callback()
1206 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1219 spin_lock_irqsave(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1220 if ((serial->parent->port_spec & HSO_INTF_MUX)) in hso_unthrottle_tasklet()
1224 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1229 struct hso_serial *serial = tty->driver_data; in hso_unthrottle()
1231 tasklet_hi_schedule(&serial->unthrottle_tasklet); in hso_unthrottle()
1237 struct hso_serial *serial = get_serial_by_index(tty->index); in hso_serial_open()
1241 if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { in hso_serial_open()
1243 tty->driver_data = NULL; in hso_serial_open()
1245 return -ENODEV; in hso_serial_open()
1248 mutex_lock(&serial->parent->mutex); in hso_serial_open()
1249 result = usb_autopm_get_interface(serial->parent->interface); in hso_serial_open()
1253 hso_dbg(0x1, "Opening %d\n", serial->minor); in hso_serial_open()
1256 tty->driver_data = serial; in hso_serial_open()
1257 tty_port_tty_set(&serial->port, tty); in hso_serial_open()
1260 serial->port.count++; in hso_serial_open()
1261 if (serial->port.count == 1) { in hso_serial_open()
1262 serial->rx_state = RX_IDLE; in hso_serial_open()
1265 tasklet_setup(&serial->unthrottle_tasklet, in hso_serial_open()
1267 result = hso_start_serial_device(serial->parent, GFP_KERNEL); in hso_serial_open()
1269 hso_stop_serial_device(serial->parent); in hso_serial_open()
1270 serial->port.count--; in hso_serial_open()
1272 kref_get(&serial->parent->ref); in hso_serial_open()
1278 usb_autopm_put_interface(serial->parent->interface); in hso_serial_open()
1284 mutex_unlock(&serial->parent->mutex); in hso_serial_open()
1291 struct hso_serial *serial = tty->driver_data; in hso_serial_close()
1300 mutex_lock(&serial->parent->mutex); in hso_serial_close()
1301 usb_gone = serial->parent->usb_gone; in hso_serial_close()
1304 usb_autopm_get_interface(serial->parent->interface); in hso_serial_close()
1306 /* reset the rts and dtr */ in hso_serial_close()
1308 serial->port.count--; in hso_serial_close()
1310 if (serial->port.count <= 0) { in hso_serial_close()
1311 serial->port.count = 0; in hso_serial_close()
1312 tty_port_tty_set(&serial->port, NULL); in hso_serial_close()
1314 hso_stop_serial_device(serial->parent); in hso_serial_close()
1315 tasklet_kill(&serial->unthrottle_tasklet); in hso_serial_close()
1319 usb_autopm_put_interface(serial->parent->interface); in hso_serial_close()
1321 mutex_unlock(&serial->parent->mutex); in hso_serial_close()
1328 struct hso_serial *serial = tty->driver_data; in hso_serial_write()
1335 return -ENODEV; in hso_serial_write()
1338 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write()
1340 space = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write()
1346 memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); in hso_serial_write()
1347 serial->tx_buffer_count += tx_bytes; in hso_serial_write()
1350 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write()
1360 struct hso_serial *serial = tty->driver_data; in hso_serial_write_room()
1364 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write_room()
1365 room = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write_room()
1366 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write_room()
1374 struct hso_serial *serial = tty->driver_data; in hso_serial_cleanup()
1379 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_serial_cleanup()
1385 struct hso_serial *serial = tty->driver_data; in hso_serial_set_termios()
1389 hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", in hso_serial_set_termios()
1390 (unsigned int)tty->termios.c_cflag, in hso_serial_set_termios()
1391 (unsigned int)old->c_cflag); in hso_serial_set_termios()
1394 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_set_termios()
1395 if (serial->port.count) in hso_serial_set_termios()
1398 tty->termios = *old; in hso_serial_set_termios()
1399 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_set_termios()
1407 struct hso_serial *serial = tty->driver_data; in hso_serial_chars_in_buffer()
1415 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1416 chars = serial->tx_buffer_count; in hso_serial_chars_in_buffer()
1417 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1427 if (serial->parent->usb_gone) in tiocmget_submit_urb()
1428 return -ENODEV; in tiocmget_submit_urb()
1429 usb_fill_int_urb(tiocmget->urb, usb, in tiocmget_submit_urb()
1431 tiocmget->endp-> in tiocmget_submit_urb()
1433 tiocmget->serial_state_notification, in tiocmget_submit_urb()
1436 tiocmget->endp->bInterval); in tiocmget_submit_urb()
1437 result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); in tiocmget_submit_urb()
1439 dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, in tiocmget_submit_urb()
1448 struct hso_serial *serial = urb->context; in tiocmget_intr_callback()
1450 int status = urb->status; in tiocmget_intr_callback()
1462 handle_usb_error(status, __func__, serial->parent); in tiocmget_intr_callback()
1467 tiocmget = serial->tiocmget; in tiocmget_intr_callback()
1470 BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); in tiocmget_intr_callback()
1472 usb = serial->parent->usb; in tiocmget_intr_callback()
1473 interface = serial->parent->interface; in tiocmget_intr_callback()
1475 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in tiocmget_intr_callback()
1480 serial_state_notification = tiocmget->serial_state_notification; in tiocmget_intr_callback()
1481 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || in tiocmget_intr_callback()
1482 serial_state_notification->bNotification != B_NOTIFICATION || in tiocmget_intr_callback()
1483 le16_to_cpu(serial_state_notification->wValue) != W_VALUE || in tiocmget_intr_callback()
1484 le16_to_cpu(serial_state_notification->wIndex) != if_num || in tiocmget_intr_callback()
1485 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { in tiocmget_intr_callback()
1486 dev_warn(&usb->dev, in tiocmget_intr_callback()
1493 UART_state_bitmap = le16_to_cpu(serial_state_notification-> in tiocmget_intr_callback()
1495 prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; in tiocmget_intr_callback()
1496 icount = &tiocmget->icount; in tiocmget_intr_callback()
1497 spin_lock_irqsave(&serial->serial_lock, flags); in tiocmget_intr_callback()
1500 icount->parity++; in tiocmget_intr_callback()
1503 icount->parity++; in tiocmget_intr_callback()
1506 icount->frame++; in tiocmget_intr_callback()
1509 icount->rng++; in tiocmget_intr_callback()
1512 icount->brk++; in tiocmget_intr_callback()
1515 icount->dsr++; in tiocmget_intr_callback()
1518 icount->dcd++; in tiocmget_intr_callback()
1519 tiocmget->prev_UART_state_bitmap = UART_state_bitmap; in tiocmget_intr_callback()
1520 spin_unlock_irqrestore(&serial->serial_lock, flags); in tiocmget_intr_callback()
1521 tiocmget->intr_completed = 1; in tiocmget_intr_callback()
1522 wake_up_interruptible(&tiocmget->waitq); in tiocmget_intr_callback()
1528 serial->parent->usb); in tiocmget_intr_callback()
1534 /* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1535 * - mask passed in arg for lines of interest
1536 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1547 tiocmget = serial->tiocmget; in hso_wait_modem_status()
1549 return -ENOENT; in hso_wait_modem_status()
1553 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1554 memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1555 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1556 add_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1558 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1559 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1560 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1571 ret = -ERESTARTSYS; in hso_wait_modem_status()
1577 remove_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1583 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1585 * NB: both 1->0 and 0->1 transitions are counted except for
1586 * RI where only 0->1 is counted.
1592 struct hso_serial *serial = tty->driver_data; in hso_get_count()
1593 struct hso_tiocmget *tiocmget = serial->tiocmget; in hso_get_count()
1598 return -ENOENT; in hso_get_count()
1599 spin_lock_irq(&serial->serial_lock); in hso_get_count()
1600 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_get_count()
1601 spin_unlock_irq(&serial->serial_lock); in hso_get_count()
1603 icount->cts = cnow.cts; in hso_get_count()
1604 icount->dsr = cnow.dsr; in hso_get_count()
1605 icount->rng = cnow.rng; in hso_get_count()
1606 icount->dcd = cnow.dcd; in hso_get_count()
1607 icount->rx = cnow.rx; in hso_get_count()
1608 icount->tx = cnow.tx; in hso_get_count()
1609 icount->frame = cnow.frame; in hso_get_count()
1610 icount->overrun = cnow.overrun; in hso_get_count()
1611 icount->parity = cnow.parity; in hso_get_count()
1612 icount->brk = cnow.brk; in hso_get_count()
1613 icount->buf_overrun = cnow.buf_overrun; in hso_get_count()
1622 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmget()
1629 return -EINVAL; in hso_serial_tiocmget()
1631 spin_lock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1632 retval = ((serial->rts_state) ? TIOCM_RTS : 0) | in hso_serial_tiocmget()
1633 ((serial->dtr_state) ? TIOCM_DTR : 0); in hso_serial_tiocmget()
1634 tiocmget = serial->tiocmget; in hso_serial_tiocmget()
1638 tiocmget->prev_UART_state_bitmap); in hso_serial_tiocmget()
1646 spin_unlock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1656 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmset()
1662 return -EINVAL; in hso_serial_tiocmset()
1665 if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) in hso_serial_tiocmset()
1666 return -EINVAL; in hso_serial_tiocmset()
1668 interface = serial->parent->interface; in hso_serial_tiocmset()
1669 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_serial_tiocmset()
1671 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_tiocmset()
1673 serial->rts_state = 1; in hso_serial_tiocmset()
1675 serial->dtr_state = 1; in hso_serial_tiocmset()
1678 serial->rts_state = 0; in hso_serial_tiocmset()
1680 serial->dtr_state = 0; in hso_serial_tiocmset()
1682 if (serial->dtr_state) in hso_serial_tiocmset()
1684 if (serial->rts_state) in hso_serial_tiocmset()
1687 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_tiocmset()
1689 return usb_control_msg(serial->parent->usb, in hso_serial_tiocmset()
1690 usb_sndctrlpipe(serial->parent->usb, 0), 0x22, in hso_serial_tiocmset()
1698 struct hso_serial *serial = tty->driver_data; in hso_serial_ioctl()
1703 return -ENODEV; in hso_serial_ioctl()
1709 ret = -ENOIOCTLCMD; in hso_serial_ioctl()
1722 spin_lock_irqsave(&serial->serial_lock, flags); in hso_kick_transmit()
1723 if (!serial->tx_buffer_count) in hso_kick_transmit()
1726 if (serial->tx_urb_used) in hso_kick_transmit()
1730 if (hso_get_activity(serial->parent) == -EAGAIN) in hso_kick_transmit()
1734 swap(serial->tx_buffer, serial->tx_data); in hso_kick_transmit()
1735 serial->tx_data_count = serial->tx_buffer_count; in hso_kick_transmit()
1736 serial->tx_buffer_count = 0; in hso_kick_transmit()
1738 /* If serial->tx_data is set, it means we switched buffers */ in hso_kick_transmit()
1739 if (serial->tx_data && serial->write_data) { in hso_kick_transmit()
1740 res = serial->write_data(serial); in hso_kick_transmit()
1742 serial->tx_urb_used = 1; in hso_kick_transmit()
1745 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_kick_transmit()
1760 return -EINVAL; in mux_device_request()
1764 ctrl_req->wValue = 0; in mux_device_request()
1765 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); in mux_device_request()
1766 ctrl_req->wLength = cpu_to_le16(size); in mux_device_request()
1770 ctrl_req->bRequestType = USB_DIR_IN | in mux_device_request()
1773 ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; in mux_device_request()
1774 pipe = usb_rcvctrlpipe(serial->parent->usb, 0); in mux_device_request()
1777 ctrl_req->bRequestType = USB_DIR_OUT | in mux_device_request()
1780 ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; in mux_device_request()
1781 pipe = usb_sndctrlpipe(serial->parent->usb, 0); in mux_device_request()
1786 ctrl_req->bRequestType, ctrl_req->wLength, port); in mux_device_request()
1789 ctrl_urb->transfer_flags = 0; in mux_device_request()
1791 serial->parent->usb, in mux_device_request()
1798 dev_err(&ctrl_urb->dev->dev, in mux_device_request()
1812 return -EINVAL; in hso_mux_serial_read()
1815 memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); in hso_mux_serial_read()
1818 if (serial->num_rx_urbs != 1) { in hso_mux_serial_read()
1819 dev_err(&serial->parent->interface->dev, in hso_mux_serial_read()
1826 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_read()
1827 serial->rx_urb[0], in hso_mux_serial_read()
1828 &serial->ctrl_req_rx, in hso_mux_serial_read()
1829 serial->rx_data[0], serial->rx_data_length); in hso_mux_serial_read()
1835 struct hso_shared_int *shared_int = urb->context; in intr_callback()
1838 int status = urb->status; in intr_callback()
1842 usb_mark_last_busy(urb->dev); in intr_callback()
1853 hso_dbg(0x8, "--- Got intr callback 0x%02X ---\n", status); in intr_callback()
1856 port_req = urb->transfer_buffer; in intr_callback()
1867 spin_lock_irqsave(&serial->serial_lock, flags); in intr_callback()
1868 if (serial->rx_state == RX_IDLE && in intr_callback()
1869 serial->port.count > 0) { in intr_callback()
1872 if (!serial->rx_urb_filled[0]) { in intr_callback()
1873 serial->rx_state = RX_SENT; in intr_callback()
1876 serial->rx_state = RX_PENDING; in intr_callback()
1881 spin_unlock_irqrestore(&serial->serial_lock, in intr_callback()
1887 hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); in intr_callback()
1894 return -EINVAL; in hso_mux_serial_write_data()
1898 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_write_data()
1899 serial->tx_urb, in hso_mux_serial_write_data()
1900 &serial->ctrl_req_tx, in hso_mux_serial_write_data()
1901 serial->tx_data, serial->tx_data_count); in hso_mux_serial_write_data()
1907 struct hso_serial *serial = urb->context; in hso_std_serial_write_bulk_callback()
1908 int status = urb->status; in hso_std_serial_write_bulk_callback()
1917 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1918 serial->tx_urb_used = 0; in hso_std_serial_write_bulk_callback()
1919 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1921 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_write_bulk_callback()
1924 hso_put_activity(serial->parent); in hso_std_serial_write_bulk_callback()
1925 tty_port_tty_wakeup(&serial->port); in hso_std_serial_write_bulk_callback()
1934 int count = serial->tx_data_count; in hso_std_serial_write_data()
1937 usb_fill_bulk_urb(serial->tx_urb, in hso_std_serial_write_data()
1938 serial->parent->usb, in hso_std_serial_write_data()
1939 usb_sndbulkpipe(serial->parent->usb, in hso_std_serial_write_data()
1940 serial->out_endp-> in hso_std_serial_write_data()
1942 serial->tx_data, serial->tx_data_count, in hso_std_serial_write_data()
1945 result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); in hso_std_serial_write_data()
1947 dev_warn(&serial->parent->usb->dev, in hso_std_serial_write_data()
1948 "Failed to submit urb - res %d\n", result); in hso_std_serial_write_data()
1958 struct hso_serial *serial = urb->context; in ctrl_callback()
1960 int status = urb->status; in ctrl_callback()
1967 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1968 serial->tx_urb_used = 0; in ctrl_callback()
1969 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1971 handle_usb_error(status, __func__, serial->parent); in ctrl_callback()
1976 req = (struct usb_ctrlrequest *)(urb->setup_packet); in ctrl_callback()
1977 hso_dbg(0x8, "--- Got muxed ctrl callback 0x%02X ---\n", status); in ctrl_callback()
1978 hso_dbg(0x8, "Actual length of urb = %d\n", urb->actual_length); in ctrl_callback()
1979 DUMP1(urb->transfer_buffer, urb->actual_length); in ctrl_callback()
1981 if (req->bRequestType == in ctrl_callback()
1984 serial->rx_urb_filled[0] = 1; in ctrl_callback()
1985 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1987 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1989 hso_put_activity(serial->parent); in ctrl_callback()
1990 tty_port_tty_wakeup(&serial->port); in ctrl_callback()
2005 return -2; in put_rxbuf_data()
2008 tty = tty_port_tty_get(&serial->port); in put_rxbuf_data()
2012 return -1; in put_rxbuf_data()
2017 count = tty_buffer_request_room(&serial->port, urb->actual_length); in put_rxbuf_data()
2018 if (count >= urb->actual_length) { in put_rxbuf_data()
2019 tty_insert_flip_string(&serial->port, urb->transfer_buffer, in put_rxbuf_data()
2020 urb->actual_length); in put_rxbuf_data()
2021 tty_flip_buffer_push(&serial->port); in put_rxbuf_data()
2023 dev_warn(&serial->parent->usb->dev, in put_rxbuf_data()
2024 "dropping data, %d bytes lost\n", urb->actual_length); in put_rxbuf_data()
2029 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; in put_rxbuf_data()
2042 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_log_port()
2077 if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { in hso_log_port()
2078 sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); in hso_log_port()
2081 dev2ser(hso_dev)->minor); in hso_log_port()
2083 dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", in hso_log_port()
2093 return -ENODEV; in hso_start_net_device()
2099 usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2100 hso_dev->usb, in hso_start_net_device()
2101 usb_rcvbulkpipe(hso_dev->usb, in hso_start_net_device()
2102 hso_net->in_endp-> in hso_start_net_device()
2104 hso_net->mux_bulk_rx_buf_pool[i], in hso_start_net_device()
2109 result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2112 dev_warn(&hso_dev->usb->dev, in hso_start_net_device()
2126 return -ENODEV; in hso_stop_net_device()
2129 if (hso_net->mux_bulk_rx_urb_pool[i]) in hso_stop_net_device()
2130 usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_stop_net_device()
2133 if (hso_net->mux_bulk_tx_urb) in hso_stop_net_device()
2134 usb_kill_urb(hso_net->mux_bulk_tx_urb); in hso_stop_net_device()
2145 return -ENODEV; in hso_start_serial_device()
2149 if (!(serial->parent->port_spec & HSO_INTF_MUX)) { in hso_start_serial_device()
2150 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_start_serial_device()
2151 usb_fill_bulk_urb(serial->rx_urb[i], in hso_start_serial_device()
2152 serial->parent->usb, in hso_start_serial_device()
2153 usb_rcvbulkpipe(serial->parent->usb, in hso_start_serial_device()
2154 serial->in_endp-> in hso_start_serial_device()
2157 serial->rx_data[i], in hso_start_serial_device()
2158 serial->rx_data_length, in hso_start_serial_device()
2161 result = usb_submit_urb(serial->rx_urb[i], flags); in hso_start_serial_device()
2163 dev_warn(&serial->parent->usb->dev, in hso_start_serial_device()
2164 "Failed to submit urb - res %d\n", in hso_start_serial_device()
2170 mutex_lock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2171 if (!serial->shared_int->use_count) { in hso_start_serial_device()
2173 hso_mux_submit_intr_urb(serial->shared_int, in hso_start_serial_device()
2174 hso_dev->usb, flags); in hso_start_serial_device()
2176 serial->shared_int->use_count++; in hso_start_serial_device()
2177 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2179 if (serial->tiocmget) in hso_start_serial_device()
2181 serial->tiocmget, in hso_start_serial_device()
2182 serial->parent->usb); in hso_start_serial_device()
2193 return -ENODEV; in hso_stop_serial_device()
2195 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_stop_serial_device()
2196 if (serial->rx_urb[i]) { in hso_stop_serial_device()
2197 usb_kill_urb(serial->rx_urb[i]); in hso_stop_serial_device()
2198 serial->rx_urb_filled[i] = 0; in hso_stop_serial_device()
2201 serial->curr_rx_urb_idx = 0; in hso_stop_serial_device()
2203 if (serial->tx_urb) in hso_stop_serial_device()
2204 usb_kill_urb(serial->tx_urb); in hso_stop_serial_device()
2206 if (serial->shared_int) { in hso_stop_serial_device()
2207 mutex_lock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2208 if (serial->shared_int->use_count && in hso_stop_serial_device()
2209 (--serial->shared_int->use_count == 0)) { in hso_stop_serial_device()
2212 urb = serial->shared_int->shared_intr_urb; in hso_stop_serial_device()
2216 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2218 tiocmget = serial->tiocmget; in hso_stop_serial_device()
2220 wake_up_interruptible(&tiocmget->waitq); in hso_stop_serial_device()
2221 usb_kill_urb(tiocmget->urb); in hso_stop_serial_device()
2229 tty_unregister_device(tty_drv, serial->minor); in hso_serial_tty_unregister()
2237 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_free()
2239 usb_free_urb(serial->rx_urb[i]); in hso_serial_common_free()
2241 kfree(serial->rx_data[i]); in hso_serial_common_free()
2245 usb_free_urb(serial->tx_urb); in hso_serial_common_free()
2246 kfree(serial->tx_buffer); in hso_serial_common_free()
2247 kfree(serial->tx_data); in hso_serial_common_free()
2248 tty_port_destroy(&serial->port); in hso_serial_common_free()
2256 tty_port_init(&serial->port); in hso_serial_common_create()
2262 serial->parent->dev = tty_port_register_device_attr(&serial->port, in hso_serial_common_create()
2263 tty_drv, serial->minor, &serial->parent->interface->dev, in hso_serial_common_create()
2264 serial->parent, hso_serial_dev_groups); in hso_serial_common_create()
2265 if (IS_ERR(serial->parent->dev)) { in hso_serial_common_create()
2270 serial->magic = HSO_SERIAL_MAGIC; in hso_serial_common_create()
2271 spin_lock_init(&serial->serial_lock); in hso_serial_common_create()
2272 serial->num_rx_urbs = num_urbs; in hso_serial_common_create()
2277 serial->rx_data_length = rx_size; in hso_serial_common_create()
2278 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_create()
2279 serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2280 if (!serial->rx_urb[i]) in hso_serial_common_create()
2282 serial->rx_urb[i]->transfer_buffer = NULL; in hso_serial_common_create()
2283 serial->rx_urb[i]->transfer_buffer_length = 0; in hso_serial_common_create()
2284 serial->rx_data[i] = kzalloc(serial->rx_data_length, in hso_serial_common_create()
2286 if (!serial->rx_data[i]) in hso_serial_common_create()
2291 serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2292 if (!serial->tx_urb) in hso_serial_common_create()
2294 serial->tx_urb->transfer_buffer = NULL; in hso_serial_common_create()
2295 serial->tx_urb->transfer_buffer_length = 0; in hso_serial_common_create()
2297 serial->tx_data_count = 0; in hso_serial_common_create()
2298 serial->tx_buffer_count = 0; in hso_serial_common_create()
2299 serial->tx_data_length = tx_size; in hso_serial_common_create()
2300 serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2301 if (!serial->tx_data) in hso_serial_common_create()
2304 serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2305 if (!serial->tx_buffer) in hso_serial_common_create()
2313 return -1; in hso_serial_common_create()
2326 hso_dev->port_spec = port_spec; in hso_create_device()
2327 hso_dev->usb = interface_to_usbdev(intf); in hso_create_device()
2328 hso_dev->interface = intf; in hso_create_device()
2329 kref_init(&hso_dev->ref); in hso_create_device()
2330 mutex_init(&hso_dev->mutex); in hso_create_device()
2332 INIT_WORK(&hso_dev->async_get_intf, async_get_intf); in hso_create_device()
2333 INIT_WORK(&hso_dev->async_put_intf, async_put_intf); in hso_create_device()
2350 return -1; in remove_net_device()
2363 remove_net_device(hso_net->parent); in hso_free_net_device()
2365 if (hso_net->net) in hso_free_net_device()
2366 unregister_netdev(hso_net->net); in hso_free_net_device()
2370 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_free_net_device()
2371 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_free_net_device()
2372 hso_net->mux_bulk_rx_buf_pool[i] = NULL; in hso_free_net_device()
2374 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_free_net_device()
2375 kfree(hso_net->mux_bulk_tx_buf); in hso_free_net_device()
2376 hso_net->mux_bulk_tx_buf = NULL; in hso_free_net_device()
2378 if (hso_net->net) in hso_free_net_device()
2379 free_netdev(hso_net->net); in hso_free_net_device()
2399 net->netdev_ops = &hso_netdev_ops; in hso_net_init()
2400 net->watchdog_timeo = HSO_NET_TX_TIMEOUT; in hso_net_init()
2401 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; in hso_net_init()
2402 net->type = ARPHRD_NONE; in hso_net_init()
2403 net->mtu = DEFAULT_MTU - 14; in hso_net_init()
2404 net->tx_queue_len = 10; in hso_net_init()
2405 net->ethtool_ops = &ops; in hso_net_init()
2408 spin_lock_init(&hso_net->net_lock); in hso_net_init()
2423 return -1; in add_net_device()
2433 mutex_lock(&hso_dev->mutex); in hso_rfkill_set_block()
2434 if (hso_dev->usb_gone) in hso_rfkill_set_block()
2437 rv = usb_control_msg(hso_dev->usb, usb_sndctrlpipe(hso_dev->usb, 0), in hso_rfkill_set_block()
2440 mutex_unlock(&hso_dev->mutex); in hso_rfkill_set_block()
2453 struct device *dev = &hso_net->net->dev; in hso_create_rfkill()
2456 snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d", in hso_create_rfkill()
2459 hso_net->rfkill = rfkill_alloc(hso_net->name, in hso_create_rfkill()
2460 &interface_to_usbdev(interface)->dev, in hso_create_rfkill()
2463 if (!hso_net->rfkill) in hso_create_rfkill()
2466 if (rfkill_register(hso_net->rfkill) < 0) { in hso_create_rfkill()
2467 rfkill_destroy(hso_net->rfkill); in hso_create_rfkill()
2468 hso_net->rfkill = NULL; in hso_create_rfkill()
2469 dev_err(dev, "%s - Failed to register rfkill\n", __func__); in hso_create_rfkill()
2496 dev_err(&interface->dev, "Unable to create ethernet device\n"); in hso_create_net_device()
2502 hso_dev->port_data.dev_net = hso_net; in hso_create_net_device()
2503 hso_net->net = net; in hso_create_net_device()
2504 hso_net->parent = hso_dev; in hso_create_net_device()
2506 hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2508 if (!hso_net->in_endp) { in hso_create_net_device()
2509 dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); in hso_create_net_device()
2512 hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2514 if (!hso_net->out_endp) { in hso_create_net_device()
2515 dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); in hso_create_net_device()
2518 SET_NETDEV_DEV(net, &interface->dev); in hso_create_net_device()
2523 hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2524 if (!hso_net->mux_bulk_rx_urb_pool[i]) in hso_create_net_device()
2526 hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, in hso_create_net_device()
2528 if (!hso_net->mux_bulk_rx_buf_pool[i]) in hso_create_net_device()
2531 hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2532 if (!hso_net->mux_bulk_tx_urb) in hso_create_net_device()
2534 hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); in hso_create_net_device()
2535 if (!hso_net->mux_bulk_tx_buf) in hso_create_net_device()
2540 dev_err(&interface->dev, "Failed to add net device\n"); in hso_create_net_device()
2547 dev_err(&interface->dev, "Failed to register device\n"); in hso_create_net_device()
2560 kfree(hso_net->mux_bulk_tx_buf); in hso_create_net_device()
2562 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_create_net_device()
2565 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_create_net_device()
2566 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_create_net_device()
2580 tiocmget = serial->tiocmget; in hso_free_tiomget()
2582 usb_free_urb(tiocmget->urb); in hso_free_tiomget()
2583 tiocmget->urb = NULL; in hso_free_tiomget()
2584 serial->tiocmget = NULL; in hso_free_tiomget()
2585 kfree(tiocmget->serial_state_notification); in hso_free_tiomget()
2586 tiocmget->serial_state_notification = NULL; in hso_free_tiomget()
2591 /* Frees an AT channel ( goes for both mux and non-mux ) */
2601 if (serial->shared_int) { in hso_free_serial_device()
2602 mutex_lock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2603 if (--serial->shared_int->ref_count == 0) in hso_free_serial_device()
2604 hso_free_shared_int(serial->shared_int); in hso_free_serial_device()
2606 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2630 serial->parent = hso_dev; in hso_create_bulk_serial_device()
2631 hso_dev->port_data.dev_serial = serial; in hso_create_bulk_serial_device()
2635 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), in hso_create_bulk_serial_device()
2637 if (!serial->tiocmget) in hso_create_bulk_serial_device()
2639 serial->tiocmget->serial_state_notification in hso_create_bulk_serial_device()
2642 if (!serial->tiocmget->serial_state_notification) in hso_create_bulk_serial_device()
2644 tiocmget = serial->tiocmget; in hso_create_bulk_serial_device()
2645 tiocmget->endp = hso_get_ep(interface, in hso_create_bulk_serial_device()
2648 if (!tiocmget->endp) { in hso_create_bulk_serial_device()
2649 dev_err(&interface->dev, "Failed to find INT IN ep\n"); in hso_create_bulk_serial_device()
2653 tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_bulk_serial_device()
2654 if (!tiocmget->urb) in hso_create_bulk_serial_device()
2657 mutex_init(&tiocmget->mutex); in hso_create_bulk_serial_device()
2658 init_waitqueue_head(&tiocmget->waitq); in hso_create_bulk_serial_device()
2667 serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_bulk_serial_device()
2669 if (!serial->in_endp) { in hso_create_bulk_serial_device()
2670 dev_err(&interface->dev, "Failed to find BULK IN ep\n"); in hso_create_bulk_serial_device()
2675 (serial->out_endp = in hso_create_bulk_serial_device()
2677 dev_err(&interface->dev, "Failed to find BULK OUT ep\n"); in hso_create_bulk_serial_device()
2681 serial->write_data = hso_std_serial_write_data; in hso_create_bulk_serial_device()
2724 hso_dev->port_data.dev_serial = serial; in hso_create_mux_serial_device()
2725 serial->parent = hso_dev; in hso_create_mux_serial_device()
2731 serial->tx_data_length--; in hso_create_mux_serial_device()
2732 serial->write_data = hso_mux_serial_write_data; in hso_create_mux_serial_device()
2734 serial->shared_int = mux; in hso_create_mux_serial_device()
2735 mutex_lock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2736 serial->shared_int->ref_count++; in hso_create_mux_serial_device()
2737 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2755 usb_free_urb(mux->shared_intr_urb); in hso_free_shared_int()
2756 kfree(mux->shared_intr_buf); in hso_free_shared_int()
2757 mutex_unlock(&mux->shared_int_lock); in hso_free_shared_int()
2769 mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, in hso_create_shared_int()
2771 if (!mux->intr_endp) { in hso_create_shared_int()
2772 dev_err(&interface->dev, "Can't find INT IN endpoint\n"); in hso_create_shared_int()
2776 mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_shared_int()
2777 if (!mux->shared_intr_urb) in hso_create_shared_int()
2779 mux->shared_intr_buf = in hso_create_shared_int()
2780 kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), in hso_create_shared_int()
2782 if (!mux->shared_intr_buf) in hso_create_shared_int()
2785 mutex_init(&mux->shared_int_lock); in hso_create_shared_int()
2790 kfree(mux->shared_intr_buf); in hso_create_shared_int()
2791 usb_free_urb(mux->shared_intr_urb); in hso_create_shared_int()
2801 u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_get_config_data()
2805 return -ENOMEM; in hso_get_config_data()
2810 return -EIO; in hso_get_config_data()
2816 return -EINVAL; in hso_get_config_data()
2880 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { in hso_probe()
2881 dev_err(&interface->dev, "Not our interface\n"); in hso_probe()
2882 return -ENODEV; in hso_probe()
2885 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_probe()
2889 if (id->driver_info) { in hso_probe()
2893 if (((u32 *)(id->driver_info))[i] == 0) in hso_probe()
2895 port_spec = ((u32 *)(id->driver_info))[if_num]; in hso_probe()
2904 if (interface->num_altsetting > 1) in hso_probe()
2906 interface->needs_remote_wakeup = 1; in hso_probe()
2923 /* TODO: de-allocate everything */ in hso_probe()
2967 return -ENODEV; in hso_probe()
2983 usb_autopm_get_interface(hso_dev->interface); in async_get_intf()
2990 usb_autopm_put_interface(hso_dev->interface); in async_put_intf()
2995 if (hso_dev->usb->state == USB_STATE_SUSPENDED) { in hso_get_activity()
2996 if (!hso_dev->is_active) { in hso_get_activity()
2997 hso_dev->is_active = 1; in hso_get_activity()
2998 schedule_work(&hso_dev->async_get_intf); in hso_get_activity()
3002 if (hso_dev->usb->state != USB_STATE_CONFIGURED) in hso_get_activity()
3003 return -EAGAIN; in hso_get_activity()
3005 usb_mark_last_busy(hso_dev->usb); in hso_get_activity()
3012 if (hso_dev->usb->state != USB_STATE_SUSPENDED) { in hso_put_activity()
3013 if (hso_dev->is_active) { in hso_put_activity()
3014 hso_dev->is_active = 0; in hso_put_activity()
3015 schedule_work(&hso_dev->async_put_intf); in hso_put_activity()
3016 return -EAGAIN; in hso_put_activity()
3019 hso_dev->is_active = 0; in hso_put_activity()
3030 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_suspend()
3040 (network_table[i]->interface == iface)) { in hso_suspend()
3059 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_resume()
3060 if (dev2ser(serial_table[i])->port.count) { in hso_resume()
3073 (network_table[i]->interface == iface)) { in hso_resume()
3075 if (hso_net->flags & IFF_UP) { in hso_resume()
3078 if (hso_net->skb_tx_buf) { in hso_resume()
3079 dev_dbg(&iface->dev, in hso_resume()
3082 hso_net_start_xmit(hso_net->skb_tx_buf, in hso_resume()
3083 hso_net->net); in hso_resume()
3084 hso_net->skb_tx_buf = NULL; in hso_resume()
3111 (serial_table[i]->interface == interface)) { in hso_free_interface()
3113 tty_port_tty_hangup(&serial->port, false); in hso_free_interface()
3114 mutex_lock(&serial->parent->mutex); in hso_free_interface()
3115 serial->parent->usb_gone = 1; in hso_free_interface()
3116 mutex_unlock(&serial->parent->mutex); in hso_free_interface()
3117 cancel_work_sync(&serial_table[i]->async_put_intf); in hso_free_interface()
3118 cancel_work_sync(&serial_table[i]->async_get_intf); in hso_free_interface()
3120 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_free_interface()
3126 (network_table[i]->interface == interface)) { in hso_free_interface()
3127 struct rfkill *rfk = dev2net(network_table[i])->rfkill; in hso_free_interface()
3130 netif_stop_queue(dev2net(network_table[i])->net); in hso_free_interface()
3132 cancel_work_sync(&network_table[i]->async_put_intf); in hso_free_interface()
3133 cancel_work_sync(&network_table[i]->async_get_intf); in hso_free_interface()
3150 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_ep()
3153 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_ep()
3154 endp = &iface->endpoint[i].desc; in hso_get_ep()
3155 if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && in hso_get_ep()
3167 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_mux_ports()
3169 if (iface->extralen == 3) { in hso_get_mux_ports()
3170 *ports = iface->extra[2]; in hso_get_mux_ports()
3174 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_mux_ports()
3175 if (iface->endpoint[i].extralen == 3) { in hso_get_mux_ports()
3176 *ports = iface->endpoint[i].extra[2]; in hso_get_mux_ports()
3181 return -1; in hso_get_mux_ports()
3190 usb_fill_int_urb(shared_int->shared_intr_urb, usb, in hso_mux_submit_intr_urb()
3192 shared_int->intr_endp->bEndpointAddress & 0x7F), in hso_mux_submit_intr_urb()
3193 shared_int->shared_intr_buf, in hso_mux_submit_intr_urb()
3196 shared_int->intr_endp->bInterval); in hso_mux_submit_intr_urb()
3198 result = usb_submit_urb(shared_int->shared_intr_urb, gfp); in hso_mux_submit_intr_urb()
3200 dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, in hso_mux_submit_intr_urb()
3253 tty_drv->driver_name = driver_name; in hso_init()
3254 tty_drv->name = tty_filename; in hso_init()
3258 tty_drv->major = tty_major; in hso_init()
3260 tty_drv->minor_start = 0; in hso_init()
3261 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; in hso_init()
3262 tty_drv->subtype = SERIAL_TYPE_NORMAL; in hso_init()
3263 tty_drv->init_termios = tty_std_termios; in hso_init()
3264 hso_init_termios(&tty_drv->init_termios); in hso_init()
3270 pr_err("%s - tty_register_driver failed(%d)\n", in hso_init()
3278 pr_err("Could not register hso driver - error: %d\n", result); in hso_init()