• Home
  • Raw
  • Download

Lines Matching +full:non +full:- +full:muxed

11  *  Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
45 * Interface 2: Standard modem interface - circuit switched interface, this
97 /* - use *_bit operations on it. (bit indices not values.) */
340 return hso_dev->port_data.dev_net; in dev2net()
345 return hso_dev->port_data.dev_serial; in dev2ser()
432 {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */
434 {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */
435 {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */
484 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_sysfs_show_porttype()
535 for (idx = 0; idx < serial->num_rx_urbs; idx++) in hso_urb_to_index()
536 if (serial->rx_urb[idx] == urb) in hso_urb_to_index()
538 dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); in hso_urb_to_index()
539 return -1; in hso_urb_to_index()
606 (dev2ser(serial_table[i])->shared_int == shared_int) && in get_serial_by_shared_int_and_type()
607 ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { in get_serial_by_shared_int_and_type()
643 return -1; in get_free_serial_index()
652 serial_table[index] = serial->parent; in set_serial_by_index()
664 case -ENODEV: in handle_usb_error()
667 case -ENOENT: in handle_usb_error()
670 case -EPIPE: in handle_usb_error()
673 case -ENOSPC: in handle_usb_error()
676 case -ESHUTDOWN: in handle_usb_error()
679 case -EHOSTUNREACH: in handle_usb_error()
682 case -EINVAL: in handle_usb_error()
683 case -EAGAIN: in handle_usb_error()
684 case -EFBIG: in handle_usb_error()
685 case -EMSGSIZE: in handle_usb_error()
688 case -EILSEQ: in handle_usb_error()
689 case -EPROTO: in handle_usb_error()
690 case -ETIME: in handle_usb_error()
691 case -ETIMEDOUT: in handle_usb_error()
694 usb_queue_reset_device(hso_dev->interface); in handle_usb_error()
702 hso_dbg(0x1, "%s: received USB status - %s (%d)\n", in handle_usb_error()
715 dev_err(&net->dev, "No net device !\n"); in hso_net_open()
716 return -ENODEV; in hso_net_open()
719 odev->skb_tx_buf = NULL; in hso_net_open()
722 spin_lock_irqsave(&odev->net_lock, flags); in hso_net_open()
723 odev->rx_parse_state = WAIT_IP; in hso_net_open()
724 odev->rx_buf_size = 0; in hso_net_open()
725 odev->rx_buf_missing = sizeof(struct iphdr); in hso_net_open()
726 spin_unlock_irqrestore(&odev->net_lock, flags); in hso_net_open()
729 set_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_open()
730 hso_start_net_device(odev->parent); in hso_net_open()
746 clear_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_close()
748 hso_stop_net_device(odev->parent); in hso_net_close()
757 struct hso_net *odev = urb->context; in write_bulk_callback()
758 int status = urb->status; in write_bulk_callback()
761 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in write_bulk_callback()
762 dev_err(&urb->dev->dev, "%s: device not running\n", __func__); in write_bulk_callback()
767 if (!netif_device_present(odev->net)) { in write_bulk_callback()
768 dev_err(&urb->dev->dev, "%s: net device not present\n", in write_bulk_callback()
776 handle_usb_error(status, __func__, odev->parent); in write_bulk_callback()
778 hso_put_activity(odev->parent); in write_bulk_callback()
781 netif_wake_queue(odev->net); in write_bulk_callback()
793 if (hso_get_activity(odev->parent) == -EAGAIN) { in hso_net_start_xmit()
794 odev->skb_tx_buf = skb; in hso_net_start_xmit()
799 DUMP1(skb->data, skb->len); in hso_net_start_xmit()
801 memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); in hso_net_start_xmit()
802 hso_dbg(0x1, "len: %d/%d\n", skb->len, MUX_BULK_TX_BUF_SIZE); in hso_net_start_xmit()
805 usb_fill_bulk_urb(odev->mux_bulk_tx_urb, in hso_net_start_xmit()
806 odev->parent->usb, in hso_net_start_xmit()
807 usb_sndbulkpipe(odev->parent->usb, in hso_net_start_xmit()
808 odev->out_endp-> in hso_net_start_xmit()
810 odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, in hso_net_start_xmit()
814 odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; in hso_net_start_xmit()
817 result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); in hso_net_start_xmit()
819 dev_warn(&odev->parent->interface->dev, in hso_net_start_xmit()
821 net->stats.tx_errors++; in hso_net_start_xmit()
824 net->stats.tx_packets++; in hso_net_start_xmit()
825 net->stats.tx_bytes += skb->len; in hso_net_start_xmit()
845 dev_warn(&net->dev, "Tx timed out.\n"); in hso_net_tx_timeout()
848 if (odev->mux_bulk_tx_urb && in hso_net_tx_timeout()
849 (odev->mux_bulk_tx_urb->status == -EINPROGRESS)) in hso_net_tx_timeout()
850 usb_unlink_urb(odev->mux_bulk_tx_urb); in hso_net_tx_timeout()
853 net->stats.tx_errors++; in hso_net_tx_timeout()
869 switch (odev->rx_parse_state) { in packetizeRx()
872 /* wanted bytes - size of ip header */ in packetizeRx()
875 odev->rx_buf_missing) ? count : odev-> in packetizeRx()
878 memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + in packetizeRx()
879 odev->rx_buf_size, ip_pkt + buffer_offset, in packetizeRx()
882 odev->rx_buf_size += temp_bytes; in packetizeRx()
884 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
885 count -= temp_bytes; in packetizeRx()
887 if (!odev->rx_buf_missing) { in packetizeRx()
890 frame_len = ntohs(odev->rx_ip_hdr.tot_len); in packetizeRx()
894 dev_err(&odev->net->dev, in packetizeRx()
897 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
901 odev->skb_rx_buf = netdev_alloc_skb(odev->net, in packetizeRx()
903 if (!odev->skb_rx_buf) { in packetizeRx()
906 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
912 skb_put_data(odev->skb_rx_buf, in packetizeRx()
913 (char *)&(odev->rx_ip_hdr), in packetizeRx()
917 odev->rx_buf_size = sizeof(struct iphdr); in packetizeRx()
920 odev->rx_buf_missing = in packetizeRx()
921 frame_len - sizeof(struct iphdr); in packetizeRx()
922 odev->rx_parse_state = WAIT_DATA; in packetizeRx()
927 temp_bytes = (count < odev->rx_buf_missing) in packetizeRx()
928 ? count : odev->rx_buf_missing; in packetizeRx()
933 skb_put_data(odev->skb_rx_buf, in packetizeRx()
937 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
938 count -= temp_bytes; in packetizeRx()
940 odev->rx_buf_size += temp_bytes; in packetizeRx()
941 if (!odev->rx_buf_missing) { in packetizeRx()
944 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); in packetizeRx()
945 skb_reset_mac_header(odev->skb_rx_buf); in packetizeRx()
948 netif_rx(odev->skb_rx_buf); in packetizeRx()
950 odev->skb_rx_buf = NULL; in packetizeRx()
953 odev->net->stats.rx_packets++; in packetizeRx()
955 odev->net->stats.rx_bytes += odev->rx_buf_size; in packetizeRx()
957 odev->rx_buf_size = 0; in packetizeRx()
958 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
959 odev->rx_parse_state = WAIT_IP; in packetizeRx()
969 count--; in packetizeRx()
976 if (odev->rx_parse_state == WAIT_SYNC) { in packetizeRx()
977 odev->rx_parse_state = WAIT_IP; in packetizeRx()
978 odev->rx_buf_size = 0; in packetizeRx()
979 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
987 u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); in fix_crc_bug()
990 !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, in fix_crc_bug()
992 urb->actual_length -= 4; in fix_crc_bug()
999 struct hso_net *odev = urb->context; in read_bulk_callback()
1003 int status = urb->status; in read_bulk_callback()
1007 handle_usb_error(status, __func__, odev->parent); in read_bulk_callback()
1012 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in read_bulk_callback()
1016 usb_mark_last_busy(urb->dev); in read_bulk_callback()
1018 net = odev->net; in read_bulk_callback()
1025 if (odev->parent->port_spec & HSO_INFO_CRC_BUG) in read_bulk_callback()
1026 fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); in read_bulk_callback()
1029 if (urb->actual_length) { in read_bulk_callback()
1032 spin_lock_irqsave(&odev->net_lock, flags); in read_bulk_callback()
1033 packetizeRx(odev, urb->transfer_buffer, urb->actual_length, in read_bulk_callback()
1034 (urb->transfer_buffer_length > in read_bulk_callback()
1035 urb->actual_length) ? 1 : 0); in read_bulk_callback()
1036 spin_unlock_irqrestore(&odev->net_lock, flags); in read_bulk_callback()
1042 odev->parent->usb, in read_bulk_callback()
1043 usb_rcvbulkpipe(odev->parent->usb, in read_bulk_callback()
1044 odev->in_endp-> in read_bulk_callback()
1046 urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, in read_bulk_callback()
1053 dev_warn(&odev->parent->interface->dev, in read_bulk_callback()
1065 termios->c_iflag &= in hso_init_termios()
1076 termios->c_oflag &= ~OPOST; in hso_init_termios()
1078 termios->c_lflag &= in hso_init_termios()
1085 | IEXTEN); /* disable non-POSIX special characters */ in hso_init_termios()
1087 termios->c_cflag &= in hso_init_termios()
1093 termios->c_cflag |= CS8; /* character size 8 bits */ in hso_init_termios()
1102 struct hso_serial *serial = tty->driver_data; in _hso_serial_set_termios()
1109 hso_dbg(0x8, "port %d\n", serial->minor); in _hso_serial_set_termios()
1114 tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ in _hso_serial_set_termios()
1116 tty->termios.c_cflag &= in _hso_serial_set_termios()
1122 tty->termios.c_cflag |= CS8; /* character size 8 bits */ in _hso_serial_set_termios()
1133 usb_fill_bulk_urb(urb, serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1134 usb_rcvbulkpipe(serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1135 serial->in_endp-> in hso_resubmit_rx_bulk_urb()
1137 urb->transfer_buffer, serial->rx_data_length, in hso_resubmit_rx_bulk_urb()
1143 dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", in hso_resubmit_rx_bulk_urb()
1156 while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { in put_rxbuf_data_and_resubmit_bulk_urb()
1157 curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; in put_rxbuf_data_and_resubmit_bulk_urb()
1159 if (count == -1) in put_rxbuf_data_and_resubmit_bulk_urb()
1162 serial->curr_rx_urb_idx++; in put_rxbuf_data_and_resubmit_bulk_urb()
1163 if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) in put_rxbuf_data_and_resubmit_bulk_urb()
1164 serial->curr_rx_urb_idx = 0; in put_rxbuf_data_and_resubmit_bulk_urb()
1175 urb = serial->rx_urb[0]; in put_rxbuf_data_and_resubmit_ctrl_urb()
1176 if (serial->port.count > 0) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1178 if (count == -1) in put_rxbuf_data_and_resubmit_ctrl_urb()
1183 if (count == 0 && ((urb->actual_length != 0) || in put_rxbuf_data_and_resubmit_ctrl_urb()
1184 (serial->rx_state == RX_PENDING))) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1185 serial->rx_state = RX_SENT; in put_rxbuf_data_and_resubmit_ctrl_urb()
1188 serial->rx_state = RX_IDLE; in put_rxbuf_data_and_resubmit_ctrl_urb()
1195 struct hso_serial *serial = urb->context; in hso_std_serial_read_bulk_callback()
1196 int status = urb->status; in hso_std_serial_read_bulk_callback()
1199 hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status); in hso_std_serial_read_bulk_callback()
1207 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_read_bulk_callback()
1211 hso_dbg(0x1, "Actual length = %d\n", urb->actual_length); in hso_std_serial_read_bulk_callback()
1212 DUMP1(urb->transfer_buffer, urb->actual_length); in hso_std_serial_read_bulk_callback()
1215 if (serial->port.count == 0) in hso_std_serial_read_bulk_callback()
1218 if (serial->parent->port_spec & HSO_INFO_CRC_BUG) in hso_std_serial_read_bulk_callback()
1219 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); in hso_std_serial_read_bulk_callback()
1221 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1222 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; in hso_std_serial_read_bulk_callback()
1224 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1235 spin_lock_irqsave(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1236 if ((serial->parent->port_spec & HSO_INTF_MUX)) in hso_unthrottle_tasklet()
1240 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1245 struct hso_serial *serial = tty->driver_data; in hso_unthrottle()
1247 tasklet_hi_schedule(&serial->unthrottle_tasklet); in hso_unthrottle()
1253 struct hso_serial *serial = get_serial_by_index(tty->index); in hso_serial_open()
1257 if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { in hso_serial_open()
1259 tty->driver_data = NULL; in hso_serial_open()
1261 return -ENODEV; in hso_serial_open()
1264 mutex_lock(&serial->parent->mutex); in hso_serial_open()
1265 result = usb_autopm_get_interface(serial->parent->interface); in hso_serial_open()
1269 hso_dbg(0x1, "Opening %d\n", serial->minor); in hso_serial_open()
1272 tty->driver_data = serial; in hso_serial_open()
1273 tty_port_tty_set(&serial->port, tty); in hso_serial_open()
1276 serial->port.count++; in hso_serial_open()
1277 if (serial->port.count == 1) { in hso_serial_open()
1278 serial->rx_state = RX_IDLE; in hso_serial_open()
1281 tasklet_init(&serial->unthrottle_tasklet, in hso_serial_open()
1284 result = hso_start_serial_device(serial->parent, GFP_KERNEL); in hso_serial_open()
1286 hso_stop_serial_device(serial->parent); in hso_serial_open()
1287 serial->port.count--; in hso_serial_open()
1289 kref_get(&serial->parent->ref); in hso_serial_open()
1295 usb_autopm_put_interface(serial->parent->interface); in hso_serial_open()
1301 mutex_unlock(&serial->parent->mutex); in hso_serial_open()
1308 struct hso_serial *serial = tty->driver_data; in hso_serial_close()
1317 mutex_lock(&serial->parent->mutex); in hso_serial_close()
1318 usb_gone = serial->parent->usb_gone; in hso_serial_close()
1321 usb_autopm_get_interface(serial->parent->interface); in hso_serial_close()
1325 serial->port.count--; in hso_serial_close()
1327 if (serial->port.count <= 0) { in hso_serial_close()
1328 serial->port.count = 0; in hso_serial_close()
1329 tty_port_tty_set(&serial->port, NULL); in hso_serial_close()
1331 hso_stop_serial_device(serial->parent); in hso_serial_close()
1332 tasklet_kill(&serial->unthrottle_tasklet); in hso_serial_close()
1336 usb_autopm_put_interface(serial->parent->interface); in hso_serial_close()
1338 mutex_unlock(&serial->parent->mutex); in hso_serial_close()
1345 struct hso_serial *serial = tty->driver_data; in hso_serial_write()
1352 return -ENODEV; in hso_serial_write()
1355 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write()
1357 space = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write()
1363 memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); in hso_serial_write()
1364 serial->tx_buffer_count += tx_bytes; in hso_serial_write()
1367 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write()
1377 struct hso_serial *serial = tty->driver_data; in hso_serial_write_room()
1381 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write_room()
1382 room = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write_room()
1383 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write_room()
1391 struct hso_serial *serial = tty->driver_data; in hso_serial_cleanup()
1396 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_serial_cleanup()
1402 struct hso_serial *serial = tty->driver_data; in hso_serial_set_termios()
1406 hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", in hso_serial_set_termios()
1407 (unsigned int)tty->termios.c_cflag, in hso_serial_set_termios()
1408 (unsigned int)old->c_cflag); in hso_serial_set_termios()
1411 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_set_termios()
1412 if (serial->port.count) in hso_serial_set_termios()
1415 tty->termios = *old; in hso_serial_set_termios()
1416 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_set_termios()
1424 struct hso_serial *serial = tty->driver_data; in hso_serial_chars_in_buffer()
1432 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1433 chars = serial->tx_buffer_count; in hso_serial_chars_in_buffer()
1434 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1444 if (serial->parent->usb_gone) in tiocmget_submit_urb()
1445 return -ENODEV; in tiocmget_submit_urb()
1446 usb_fill_int_urb(tiocmget->urb, usb, in tiocmget_submit_urb()
1448 tiocmget->endp-> in tiocmget_submit_urb()
1450 &tiocmget->serial_state_notification, in tiocmget_submit_urb()
1453 tiocmget->endp->bInterval); in tiocmget_submit_urb()
1454 result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); in tiocmget_submit_urb()
1456 dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, in tiocmget_submit_urb()
1465 struct hso_serial *serial = urb->context; in tiocmget_intr_callback()
1467 int status = urb->status; in tiocmget_intr_callback()
1479 handle_usb_error(status, __func__, serial->parent); in tiocmget_intr_callback()
1484 tiocmget = serial->tiocmget; in tiocmget_intr_callback()
1487 BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); in tiocmget_intr_callback()
1489 usb = serial->parent->usb; in tiocmget_intr_callback()
1490 interface = serial->parent->interface; in tiocmget_intr_callback()
1492 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in tiocmget_intr_callback()
1497 serial_state_notification = &tiocmget->serial_state_notification; in tiocmget_intr_callback()
1498 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || in tiocmget_intr_callback()
1499 serial_state_notification->bNotification != B_NOTIFICATION || in tiocmget_intr_callback()
1500 le16_to_cpu(serial_state_notification->wValue) != W_VALUE || in tiocmget_intr_callback()
1501 le16_to_cpu(serial_state_notification->wIndex) != if_num || in tiocmget_intr_callback()
1502 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { in tiocmget_intr_callback()
1503 dev_warn(&usb->dev, in tiocmget_intr_callback()
1510 UART_state_bitmap = le16_to_cpu(serial_state_notification-> in tiocmget_intr_callback()
1512 prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; in tiocmget_intr_callback()
1513 icount = &tiocmget->icount; in tiocmget_intr_callback()
1514 spin_lock_irqsave(&serial->serial_lock, flags); in tiocmget_intr_callback()
1517 icount->parity++; in tiocmget_intr_callback()
1520 icount->parity++; in tiocmget_intr_callback()
1523 icount->frame++; in tiocmget_intr_callback()
1526 icount->rng++; in tiocmget_intr_callback()
1529 icount->brk++; in tiocmget_intr_callback()
1532 icount->dsr++; in tiocmget_intr_callback()
1535 icount->dcd++; in tiocmget_intr_callback()
1536 tiocmget->prev_UART_state_bitmap = UART_state_bitmap; in tiocmget_intr_callback()
1537 spin_unlock_irqrestore(&serial->serial_lock, flags); in tiocmget_intr_callback()
1538 tiocmget->intr_completed = 1; in tiocmget_intr_callback()
1539 wake_up_interruptible(&tiocmget->waitq); in tiocmget_intr_callback()
1545 serial->parent->usb); in tiocmget_intr_callback()
1552 * - mask passed in arg for lines of interest
1564 tiocmget = serial->tiocmget; in hso_wait_modem_status()
1566 return -ENOENT; in hso_wait_modem_status()
1570 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1571 memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1572 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1573 add_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1575 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1576 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1577 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1588 ret = -ERESTARTSYS; in hso_wait_modem_status()
1594 remove_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1602 * NB: both 1->0 and 0->1 transitions are counted except for
1603 * RI where only 0->1 is counted.
1609 struct hso_serial *serial = tty->driver_data; in hso_get_count()
1610 struct hso_tiocmget *tiocmget = serial->tiocmget; in hso_get_count()
1615 return -ENOENT; in hso_get_count()
1616 spin_lock_irq(&serial->serial_lock); in hso_get_count()
1617 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_get_count()
1618 spin_unlock_irq(&serial->serial_lock); in hso_get_count()
1620 icount->cts = cnow.cts; in hso_get_count()
1621 icount->dsr = cnow.dsr; in hso_get_count()
1622 icount->rng = cnow.rng; in hso_get_count()
1623 icount->dcd = cnow.dcd; in hso_get_count()
1624 icount->rx = cnow.rx; in hso_get_count()
1625 icount->tx = cnow.tx; in hso_get_count()
1626 icount->frame = cnow.frame; in hso_get_count()
1627 icount->overrun = cnow.overrun; in hso_get_count()
1628 icount->parity = cnow.parity; in hso_get_count()
1629 icount->brk = cnow.brk; in hso_get_count()
1630 icount->buf_overrun = cnow.buf_overrun; in hso_get_count()
1639 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmget()
1646 return -EINVAL; in hso_serial_tiocmget()
1648 spin_lock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1649 retval = ((serial->rts_state) ? TIOCM_RTS : 0) | in hso_serial_tiocmget()
1650 ((serial->dtr_state) ? TIOCM_DTR : 0); in hso_serial_tiocmget()
1651 tiocmget = serial->tiocmget; in hso_serial_tiocmget()
1655 tiocmget->prev_UART_state_bitmap); in hso_serial_tiocmget()
1663 spin_unlock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1673 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmset()
1679 return -EINVAL; in hso_serial_tiocmset()
1682 if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) in hso_serial_tiocmset()
1683 return -EINVAL; in hso_serial_tiocmset()
1685 interface = serial->parent->interface; in hso_serial_tiocmset()
1686 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_serial_tiocmset()
1688 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_tiocmset()
1690 serial->rts_state = 1; in hso_serial_tiocmset()
1692 serial->dtr_state = 1; in hso_serial_tiocmset()
1695 serial->rts_state = 0; in hso_serial_tiocmset()
1697 serial->dtr_state = 0; in hso_serial_tiocmset()
1699 if (serial->dtr_state) in hso_serial_tiocmset()
1701 if (serial->rts_state) in hso_serial_tiocmset()
1704 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_tiocmset()
1706 return usb_control_msg(serial->parent->usb, in hso_serial_tiocmset()
1707 usb_rcvctrlpipe(serial->parent->usb, 0), 0x22, in hso_serial_tiocmset()
1715 struct hso_serial *serial = tty->driver_data; in hso_serial_ioctl()
1720 return -ENODEV; in hso_serial_ioctl()
1726 ret = -ENOIOCTLCMD; in hso_serial_ioctl()
1739 spin_lock_irqsave(&serial->serial_lock, flags); in hso_kick_transmit()
1740 if (!serial->tx_buffer_count) in hso_kick_transmit()
1743 if (serial->tx_urb_used) in hso_kick_transmit()
1747 if (hso_get_activity(serial->parent) == -EAGAIN) in hso_kick_transmit()
1751 swap(serial->tx_buffer, serial->tx_data); in hso_kick_transmit()
1752 serial->tx_data_count = serial->tx_buffer_count; in hso_kick_transmit()
1753 serial->tx_buffer_count = 0; in hso_kick_transmit()
1755 /* If serial->tx_data is set, it means we switched buffers */ in hso_kick_transmit()
1756 if (serial->tx_data && serial->write_data) { in hso_kick_transmit()
1757 res = serial->write_data(serial); in hso_kick_transmit()
1759 serial->tx_urb_used = 1; in hso_kick_transmit()
1762 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_kick_transmit()
1765 /* make a request (for reading and writing data to muxed serial port) */
1777 return -EINVAL; in mux_device_request()
1781 ctrl_req->wValue = 0; in mux_device_request()
1782 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); in mux_device_request()
1783 ctrl_req->wLength = cpu_to_le16(size); in mux_device_request()
1787 ctrl_req->bRequestType = USB_DIR_IN | in mux_device_request()
1790 ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; in mux_device_request()
1791 pipe = usb_rcvctrlpipe(serial->parent->usb, 0); in mux_device_request()
1794 ctrl_req->bRequestType = USB_DIR_OUT | in mux_device_request()
1797 ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; in mux_device_request()
1798 pipe = usb_sndctrlpipe(serial->parent->usb, 0); in mux_device_request()
1803 ctrl_req->bRequestType, ctrl_req->wLength, port); in mux_device_request()
1806 ctrl_urb->transfer_flags = 0; in mux_device_request()
1808 serial->parent->usb, in mux_device_request()
1815 dev_err(&ctrl_urb->dev->dev, in mux_device_request()
1829 return -EINVAL; in hso_mux_serial_read()
1832 memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); in hso_mux_serial_read()
1835 if (serial->num_rx_urbs != 1) { in hso_mux_serial_read()
1836 dev_err(&serial->parent->interface->dev, in hso_mux_serial_read()
1843 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_read()
1844 serial->rx_urb[0], in hso_mux_serial_read()
1845 &serial->ctrl_req_rx, in hso_mux_serial_read()
1846 serial->rx_data[0], serial->rx_data_length); in hso_mux_serial_read()
1849 /* used for muxed serial port callback (muxed serial read) */
1852 struct hso_shared_int *shared_int = urb->context; in intr_callback()
1855 int status = urb->status; in intr_callback()
1859 usb_mark_last_busy(urb->dev); in intr_callback()
1870 hso_dbg(0x8, "--- Got intr callback 0x%02X ---\n", status); in intr_callback()
1873 port_req = urb->transfer_buffer; in intr_callback()
1875 /* loop over all muxed ports to find the one sending this */ in intr_callback()
1884 spin_lock_irqsave(&serial->serial_lock, flags); in intr_callback()
1885 if (serial->rx_state == RX_IDLE && in intr_callback()
1886 serial->port.count > 0) { in intr_callback()
1889 if (!serial->rx_urb_filled[0]) { in intr_callback()
1890 serial->rx_state = RX_SENT; in intr_callback()
1893 serial->rx_state = RX_PENDING; in intr_callback()
1898 spin_unlock_irqrestore(&serial->serial_lock, in intr_callback()
1904 hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); in intr_callback()
1907 /* called for writing to muxed serial port */
1911 return -EINVAL; in hso_mux_serial_write_data()
1915 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_write_data()
1916 serial->tx_urb, in hso_mux_serial_write_data()
1917 &serial->ctrl_req_tx, in hso_mux_serial_write_data()
1918 serial->tx_data, serial->tx_data_count); in hso_mux_serial_write_data()
1924 struct hso_serial *serial = urb->context; in hso_std_serial_write_bulk_callback()
1925 int status = urb->status; in hso_std_serial_write_bulk_callback()
1934 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1935 serial->tx_urb_used = 0; in hso_std_serial_write_bulk_callback()
1936 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1938 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_write_bulk_callback()
1941 hso_put_activity(serial->parent); in hso_std_serial_write_bulk_callback()
1942 tty_port_tty_wakeup(&serial->port); in hso_std_serial_write_bulk_callback()
1951 int count = serial->tx_data_count; in hso_std_serial_write_data()
1954 usb_fill_bulk_urb(serial->tx_urb, in hso_std_serial_write_data()
1955 serial->parent->usb, in hso_std_serial_write_data()
1956 usb_sndbulkpipe(serial->parent->usb, in hso_std_serial_write_data()
1957 serial->out_endp-> in hso_std_serial_write_data()
1959 serial->tx_data, serial->tx_data_count, in hso_std_serial_write_data()
1962 result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); in hso_std_serial_write_data()
1964 dev_warn(&serial->parent->usb->dev, in hso_std_serial_write_data()
1965 "Failed to submit urb - res %d\n", result); in hso_std_serial_write_data()
1972 /* callback after read or write on muxed serial port */
1975 struct hso_serial *serial = urb->context; in ctrl_callback()
1977 int status = urb->status; in ctrl_callback()
1984 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1985 serial->tx_urb_used = 0; in ctrl_callback()
1986 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1988 handle_usb_error(status, __func__, serial->parent); in ctrl_callback()
1993 req = (struct usb_ctrlrequest *)(urb->setup_packet); in ctrl_callback()
1994 hso_dbg(0x8, "--- Got muxed ctrl callback 0x%02X ---\n", status); in ctrl_callback()
1995 hso_dbg(0x8, "Actual length of urb = %d\n", urb->actual_length); in ctrl_callback()
1996 DUMP1(urb->transfer_buffer, urb->actual_length); in ctrl_callback()
1998 if (req->bRequestType == in ctrl_callback()
2001 serial->rx_urb_filled[0] = 1; in ctrl_callback()
2002 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
2004 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
2006 hso_put_activity(serial->parent); in ctrl_callback()
2007 tty_port_tty_wakeup(&serial->port); in ctrl_callback()
2022 return -2; in put_rxbuf_data()
2025 tty = tty_port_tty_get(&serial->port); in put_rxbuf_data()
2029 return -1; in put_rxbuf_data()
2034 count = tty_buffer_request_room(&serial->port, urb->actual_length); in put_rxbuf_data()
2035 if (count >= urb->actual_length) { in put_rxbuf_data()
2036 tty_insert_flip_string(&serial->port, urb->transfer_buffer, in put_rxbuf_data()
2037 urb->actual_length); in put_rxbuf_data()
2038 tty_flip_buffer_push(&serial->port); in put_rxbuf_data()
2040 dev_warn(&serial->parent->usb->dev, in put_rxbuf_data()
2041 "dropping data, %d bytes lost\n", urb->actual_length); in put_rxbuf_data()
2046 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; in put_rxbuf_data()
2059 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_log_port()
2094 if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { in hso_log_port()
2095 sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); in hso_log_port()
2098 dev2ser(hso_dev)->minor); in hso_log_port()
2100 dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", in hso_log_port()
2110 return -ENODEV; in hso_start_net_device()
2116 usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2117 hso_dev->usb, in hso_start_net_device()
2118 usb_rcvbulkpipe(hso_dev->usb, in hso_start_net_device()
2119 hso_net->in_endp-> in hso_start_net_device()
2121 hso_net->mux_bulk_rx_buf_pool[i], in hso_start_net_device()
2126 result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2129 dev_warn(&hso_dev->usb->dev, in hso_start_net_device()
2143 return -ENODEV; in hso_stop_net_device()
2146 if (hso_net->mux_bulk_rx_urb_pool[i]) in hso_stop_net_device()
2147 usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_stop_net_device()
2150 if (hso_net->mux_bulk_tx_urb) in hso_stop_net_device()
2151 usb_kill_urb(hso_net->mux_bulk_tx_urb); in hso_stop_net_device()
2162 return -ENODEV; in hso_start_serial_device()
2166 if (!(serial->parent->port_spec & HSO_INTF_MUX)) { in hso_start_serial_device()
2167 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_start_serial_device()
2168 usb_fill_bulk_urb(serial->rx_urb[i], in hso_start_serial_device()
2169 serial->parent->usb, in hso_start_serial_device()
2170 usb_rcvbulkpipe(serial->parent->usb, in hso_start_serial_device()
2171 serial->in_endp-> in hso_start_serial_device()
2174 serial->rx_data[i], in hso_start_serial_device()
2175 serial->rx_data_length, in hso_start_serial_device()
2178 result = usb_submit_urb(serial->rx_urb[i], flags); in hso_start_serial_device()
2180 dev_warn(&serial->parent->usb->dev, in hso_start_serial_device()
2181 "Failed to submit urb - res %d\n", in hso_start_serial_device()
2187 mutex_lock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2188 if (!serial->shared_int->use_count) { in hso_start_serial_device()
2190 hso_mux_submit_intr_urb(serial->shared_int, in hso_start_serial_device()
2191 hso_dev->usb, flags); in hso_start_serial_device()
2193 serial->shared_int->use_count++; in hso_start_serial_device()
2194 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2196 if (serial->tiocmget) in hso_start_serial_device()
2198 serial->tiocmget, in hso_start_serial_device()
2199 serial->parent->usb); in hso_start_serial_device()
2210 return -ENODEV; in hso_stop_serial_device()
2212 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_stop_serial_device()
2213 if (serial->rx_urb[i]) { in hso_stop_serial_device()
2214 usb_kill_urb(serial->rx_urb[i]); in hso_stop_serial_device()
2215 serial->rx_urb_filled[i] = 0; in hso_stop_serial_device()
2218 serial->curr_rx_urb_idx = 0; in hso_stop_serial_device()
2220 if (serial->tx_urb) in hso_stop_serial_device()
2221 usb_kill_urb(serial->tx_urb); in hso_stop_serial_device()
2223 if (serial->shared_int) { in hso_stop_serial_device()
2224 mutex_lock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2225 if (serial->shared_int->use_count && in hso_stop_serial_device()
2226 (--serial->shared_int->use_count == 0)) { in hso_stop_serial_device()
2229 urb = serial->shared_int->shared_intr_urb; in hso_stop_serial_device()
2233 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2235 tiocmget = serial->tiocmget; in hso_stop_serial_device()
2237 wake_up_interruptible(&tiocmget->waitq); in hso_stop_serial_device()
2238 usb_kill_urb(tiocmget->urb); in hso_stop_serial_device()
2246 tty_unregister_device(tty_drv, serial->minor); in hso_serial_tty_unregister()
2253 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_free()
2255 usb_free_urb(serial->rx_urb[i]); in hso_serial_common_free()
2257 kfree(serial->rx_data[i]); in hso_serial_common_free()
2261 usb_free_urb(serial->tx_urb); in hso_serial_common_free()
2262 kfree(serial->tx_buffer); in hso_serial_common_free()
2263 kfree(serial->tx_data); in hso_serial_common_free()
2264 tty_port_destroy(&serial->port); in hso_serial_common_free()
2273 tty_port_init(&serial->port); in hso_serial_common_create()
2280 serial->parent->dev = tty_port_register_device_attr(&serial->port, in hso_serial_common_create()
2281 tty_drv, minor, &serial->parent->interface->dev, in hso_serial_common_create()
2282 serial->parent, hso_serial_dev_groups); in hso_serial_common_create()
2283 if (IS_ERR(serial->parent->dev)) in hso_serial_common_create()
2287 serial->minor = minor; in hso_serial_common_create()
2288 serial->magic = HSO_SERIAL_MAGIC; in hso_serial_common_create()
2289 spin_lock_init(&serial->serial_lock); in hso_serial_common_create()
2290 serial->num_rx_urbs = num_urbs; in hso_serial_common_create()
2295 serial->rx_data_length = rx_size; in hso_serial_common_create()
2296 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_create()
2297 serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2298 if (!serial->rx_urb[i]) in hso_serial_common_create()
2300 serial->rx_urb[i]->transfer_buffer = NULL; in hso_serial_common_create()
2301 serial->rx_urb[i]->transfer_buffer_length = 0; in hso_serial_common_create()
2302 serial->rx_data[i] = kzalloc(serial->rx_data_length, in hso_serial_common_create()
2304 if (!serial->rx_data[i]) in hso_serial_common_create()
2309 serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2310 if (!serial->tx_urb) in hso_serial_common_create()
2312 serial->tx_urb->transfer_buffer = NULL; in hso_serial_common_create()
2313 serial->tx_urb->transfer_buffer_length = 0; in hso_serial_common_create()
2315 serial->tx_data_count = 0; in hso_serial_common_create()
2316 serial->tx_buffer_count = 0; in hso_serial_common_create()
2317 serial->tx_data_length = tx_size; in hso_serial_common_create()
2318 serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2319 if (!serial->tx_data) in hso_serial_common_create()
2322 serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2323 if (!serial->tx_buffer) in hso_serial_common_create()
2331 return -1; in hso_serial_common_create()
2344 hso_dev->port_spec = port_spec; in hso_create_device()
2345 hso_dev->usb = interface_to_usbdev(intf); in hso_create_device()
2346 hso_dev->interface = intf; in hso_create_device()
2347 kref_init(&hso_dev->ref); in hso_create_device()
2348 mutex_init(&hso_dev->mutex); in hso_create_device()
2350 INIT_WORK(&hso_dev->async_get_intf, async_get_intf); in hso_create_device()
2351 INIT_WORK(&hso_dev->async_put_intf, async_put_intf); in hso_create_device()
2368 return -1; in remove_net_device()
2381 remove_net_device(hso_net->parent); in hso_free_net_device()
2383 if (hso_net->net) in hso_free_net_device()
2384 unregister_netdev(hso_net->net); in hso_free_net_device()
2388 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_free_net_device()
2389 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_free_net_device()
2390 hso_net->mux_bulk_rx_buf_pool[i] = NULL; in hso_free_net_device()
2392 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_free_net_device()
2393 kfree(hso_net->mux_bulk_tx_buf); in hso_free_net_device()
2394 hso_net->mux_bulk_tx_buf = NULL; in hso_free_net_device()
2396 if (hso_net->net && !bailout) in hso_free_net_device()
2397 free_netdev(hso_net->net); in hso_free_net_device()
2417 net->netdev_ops = &hso_netdev_ops; in hso_net_init()
2418 net->watchdog_timeo = HSO_NET_TX_TIMEOUT; in hso_net_init()
2419 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; in hso_net_init()
2420 net->type = ARPHRD_NONE; in hso_net_init()
2421 net->mtu = DEFAULT_MTU - 14; in hso_net_init()
2422 net->tx_queue_len = 10; in hso_net_init()
2423 net->ethtool_ops = &ops; in hso_net_init()
2426 spin_lock_init(&hso_net->net_lock); in hso_net_init()
2441 return -1; in add_net_device()
2451 mutex_lock(&hso_dev->mutex); in hso_rfkill_set_block()
2452 if (hso_dev->usb_gone) in hso_rfkill_set_block()
2455 rv = usb_control_msg(hso_dev->usb, usb_rcvctrlpipe(hso_dev->usb, 0), in hso_rfkill_set_block()
2458 mutex_unlock(&hso_dev->mutex); in hso_rfkill_set_block()
2471 struct device *dev = &hso_net->net->dev; in hso_create_rfkill()
2474 snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d", in hso_create_rfkill()
2477 hso_net->rfkill = rfkill_alloc(hso_net->name, in hso_create_rfkill()
2478 &interface_to_usbdev(interface)->dev, in hso_create_rfkill()
2481 if (!hso_net->rfkill) { in hso_create_rfkill()
2482 dev_err(dev, "%s - Out of memory\n", __func__); in hso_create_rfkill()
2485 if (rfkill_register(hso_net->rfkill) < 0) { in hso_create_rfkill()
2486 rfkill_destroy(hso_net->rfkill); in hso_create_rfkill()
2487 hso_net->rfkill = NULL; in hso_create_rfkill()
2488 dev_err(dev, "%s - Failed to register rfkill\n", __func__); in hso_create_rfkill()
2515 dev_err(&interface->dev, "Unable to create ethernet device\n"); in hso_create_net_device()
2521 hso_dev->port_data.dev_net = hso_net; in hso_create_net_device()
2522 hso_net->net = net; in hso_create_net_device()
2523 hso_net->parent = hso_dev; in hso_create_net_device()
2525 hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2527 if (!hso_net->in_endp) { in hso_create_net_device()
2528 dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); in hso_create_net_device()
2531 hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2533 if (!hso_net->out_endp) { in hso_create_net_device()
2534 dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); in hso_create_net_device()
2537 SET_NETDEV_DEV(net, &interface->dev); in hso_create_net_device()
2542 hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2543 if (!hso_net->mux_bulk_rx_urb_pool[i]) in hso_create_net_device()
2545 hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, in hso_create_net_device()
2547 if (!hso_net->mux_bulk_rx_buf_pool[i]) in hso_create_net_device()
2550 hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2551 if (!hso_net->mux_bulk_tx_urb) in hso_create_net_device()
2553 hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); in hso_create_net_device()
2554 if (!hso_net->mux_bulk_tx_buf) in hso_create_net_device()
2562 dev_err(&interface->dev, "Failed to register device\n"); in hso_create_net_device()
2574 kfree(hso_net->mux_bulk_tx_buf); in hso_create_net_device()
2576 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_create_net_device()
2579 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_create_net_device()
2580 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_create_net_device()
2594 tiocmget = serial->tiocmget; in hso_free_tiomget()
2596 usb_free_urb(tiocmget->urb); in hso_free_tiomget()
2597 tiocmget->urb = NULL; in hso_free_tiomget()
2598 serial->tiocmget = NULL; in hso_free_tiomget()
2603 /* Frees an AT channel ( goes for both mux and non-mux ) */
2613 if (serial->shared_int) { in hso_free_serial_device()
2614 mutex_lock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2615 if (--serial->shared_int->ref_count == 0) in hso_free_serial_device()
2616 hso_free_shared_int(serial->shared_int); in hso_free_serial_device()
2618 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2642 serial->parent = hso_dev; in hso_create_bulk_serial_device()
2643 hso_dev->port_data.dev_serial = serial; in hso_create_bulk_serial_device()
2647 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), in hso_create_bulk_serial_device()
2649 /* it isn't going to break our heart if serial->tiocmget in hso_create_bulk_serial_device()
2652 if (serial->tiocmget) { in hso_create_bulk_serial_device()
2653 tiocmget = serial->tiocmget; in hso_create_bulk_serial_device()
2654 tiocmget->endp = hso_get_ep(interface, in hso_create_bulk_serial_device()
2657 if (!tiocmget->endp) { in hso_create_bulk_serial_device()
2658 dev_err(&interface->dev, "Failed to find INT IN ep\n"); in hso_create_bulk_serial_device()
2662 tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_bulk_serial_device()
2663 if (tiocmget->urb) { in hso_create_bulk_serial_device()
2664 mutex_init(&tiocmget->mutex); in hso_create_bulk_serial_device()
2665 init_waitqueue_head(&tiocmget->waitq); in hso_create_bulk_serial_device()
2677 serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_bulk_serial_device()
2679 if (!serial->in_endp) { in hso_create_bulk_serial_device()
2680 dev_err(&interface->dev, "Failed to find BULK IN ep\n"); in hso_create_bulk_serial_device()
2685 (serial->out_endp = in hso_create_bulk_serial_device()
2687 dev_err(&interface->dev, "Failed to find BULK IN ep\n"); in hso_create_bulk_serial_device()
2691 serial->write_data = hso_std_serial_write_data; in hso_create_bulk_serial_device()
2694 set_serial_by_index(serial->minor, serial); in hso_create_bulk_serial_device()
2737 hso_dev->port_data.dev_serial = serial; in hso_create_mux_serial_device()
2738 serial->parent = hso_dev; in hso_create_mux_serial_device()
2744 serial->tx_data_length--; in hso_create_mux_serial_device()
2745 serial->write_data = hso_mux_serial_write_data; in hso_create_mux_serial_device()
2747 serial->shared_int = mux; in hso_create_mux_serial_device()
2748 mutex_lock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2749 serial->shared_int->ref_count++; in hso_create_mux_serial_device()
2750 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2753 set_serial_by_index(serial->minor, serial); in hso_create_mux_serial_device()
2763 tty_unregister_device(tty_drv, serial->minor); in hso_create_mux_serial_device()
2773 usb_free_urb(mux->shared_intr_urb); in hso_free_shared_int()
2774 kfree(mux->shared_intr_buf); in hso_free_shared_int()
2775 mutex_unlock(&mux->shared_int_lock); in hso_free_shared_int()
2787 mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, in hso_create_shared_int()
2789 if (!mux->intr_endp) { in hso_create_shared_int()
2790 dev_err(&interface->dev, "Can't find INT IN endpoint\n"); in hso_create_shared_int()
2794 mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_shared_int()
2795 if (!mux->shared_intr_urb) in hso_create_shared_int()
2797 mux->shared_intr_buf = in hso_create_shared_int()
2798 kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), in hso_create_shared_int()
2800 if (!mux->shared_intr_buf) in hso_create_shared_int()
2803 mutex_init(&mux->shared_int_lock); in hso_create_shared_int()
2808 kfree(mux->shared_intr_buf); in hso_create_shared_int()
2809 usb_free_urb(mux->shared_intr_urb); in hso_create_shared_int()
2819 u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_get_config_data()
2823 return -ENOMEM; in hso_get_config_data()
2828 return -EIO; in hso_get_config_data()
2834 return -EINVAL; in hso_get_config_data()
2898 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { in hso_probe()
2899 dev_err(&interface->dev, "Not our interface\n"); in hso_probe()
2900 return -ENODEV; in hso_probe()
2903 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_probe()
2907 if (id->driver_info) { in hso_probe()
2911 if (((u32 *)(id->driver_info))[i] == 0) in hso_probe()
2913 port_spec = ((u32 *)(id->driver_info))[if_num]; in hso_probe()
2922 if (interface->num_altsetting > 1) in hso_probe()
2924 interface->needs_remote_wakeup = 1; in hso_probe()
2941 /* TODO: de-allocate everything */ in hso_probe()
2985 return -ENODEV; in hso_probe()
3001 usb_autopm_get_interface(hso_dev->interface); in async_get_intf()
3008 usb_autopm_put_interface(hso_dev->interface); in async_put_intf()
3013 if (hso_dev->usb->state == USB_STATE_SUSPENDED) { in hso_get_activity()
3014 if (!hso_dev->is_active) { in hso_get_activity()
3015 hso_dev->is_active = 1; in hso_get_activity()
3016 schedule_work(&hso_dev->async_get_intf); in hso_get_activity()
3020 if (hso_dev->usb->state != USB_STATE_CONFIGURED) in hso_get_activity()
3021 return -EAGAIN; in hso_get_activity()
3023 usb_mark_last_busy(hso_dev->usb); in hso_get_activity()
3030 if (hso_dev->usb->state != USB_STATE_SUSPENDED) { in hso_put_activity()
3031 if (hso_dev->is_active) { in hso_put_activity()
3032 hso_dev->is_active = 0; in hso_put_activity()
3033 schedule_work(&hso_dev->async_put_intf); in hso_put_activity()
3034 return -EAGAIN; in hso_put_activity()
3037 hso_dev->is_active = 0; in hso_put_activity()
3048 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_suspend()
3058 (network_table[i]->interface == iface)) { in hso_suspend()
3077 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_resume()
3078 if (dev2ser(serial_table[i])->port.count) { in hso_resume()
3091 (network_table[i]->interface == iface)) { in hso_resume()
3093 if (hso_net->flags & IFF_UP) { in hso_resume()
3096 if (hso_net->skb_tx_buf) { in hso_resume()
3097 dev_dbg(&iface->dev, in hso_resume()
3100 hso_net_start_xmit(hso_net->skb_tx_buf, in hso_resume()
3101 hso_net->net); in hso_resume()
3102 hso_net->skb_tx_buf = NULL; in hso_resume()
3129 (serial_table[i]->interface == interface)) { in hso_free_interface()
3131 tty_port_tty_hangup(&serial->port, false); in hso_free_interface()
3132 mutex_lock(&serial->parent->mutex); in hso_free_interface()
3133 serial->parent->usb_gone = 1; in hso_free_interface()
3134 mutex_unlock(&serial->parent->mutex); in hso_free_interface()
3135 cancel_work_sync(&serial_table[i]->async_put_intf); in hso_free_interface()
3136 cancel_work_sync(&serial_table[i]->async_get_intf); in hso_free_interface()
3138 kref_put(&serial_table[i]->ref, hso_serial_ref_free); in hso_free_interface()
3145 (network_table[i]->interface == interface)) { in hso_free_interface()
3146 struct rfkill *rfk = dev2net(network_table[i])->rfkill; in hso_free_interface()
3149 netif_stop_queue(dev2net(network_table[i])->net); in hso_free_interface()
3151 cancel_work_sync(&network_table[i]->async_put_intf); in hso_free_interface()
3152 cancel_work_sync(&network_table[i]->async_get_intf); in hso_free_interface()
3169 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_ep()
3172 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_ep()
3173 endp = &iface->endpoint[i].desc; in hso_get_ep()
3174 if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && in hso_get_ep()
3186 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_mux_ports()
3188 if (iface->extralen == 3) { in hso_get_mux_ports()
3189 *ports = iface->extra[2]; in hso_get_mux_ports()
3193 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_mux_ports()
3194 if (iface->endpoint[i].extralen == 3) { in hso_get_mux_ports()
3195 *ports = iface->endpoint[i].extra[2]; in hso_get_mux_ports()
3200 return -1; in hso_get_mux_ports()
3203 /* interrupt urb needs to be submitted, used for serial read of muxed port */
3209 usb_fill_int_urb(shared_int->shared_intr_urb, usb, in hso_mux_submit_intr_urb()
3211 shared_int->intr_endp->bEndpointAddress & 0x7F), in hso_mux_submit_intr_urb()
3212 shared_int->shared_intr_buf, in hso_mux_submit_intr_urb()
3215 shared_int->intr_endp->bInterval); in hso_mux_submit_intr_urb()
3217 result = usb_submit_urb(shared_int->shared_intr_urb, gfp); in hso_mux_submit_intr_urb()
3219 dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, in hso_mux_submit_intr_urb()
3269 return -ENOMEM; in hso_init()
3272 tty_drv->driver_name = driver_name; in hso_init()
3273 tty_drv->name = tty_filename; in hso_init()
3277 tty_drv->major = tty_major; in hso_init()
3279 tty_drv->minor_start = 0; in hso_init()
3280 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; in hso_init()
3281 tty_drv->subtype = SERIAL_TYPE_NORMAL; in hso_init()
3282 tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; in hso_init()
3283 tty_drv->init_termios = tty_std_termios; in hso_init()
3284 hso_init_termios(&tty_drv->init_termios); in hso_init()
3290 pr_err("%s - tty_register_driver failed(%d)\n", in hso_init()
3298 pr_err("Could not register hso driver - error: %d\n", result); in hso_init()