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()
417 {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */
419 {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */
420 {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */
468 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hsotype_show()
519 for (idx = 0; idx < serial->num_rx_urbs; idx++) in hso_urb_to_index()
520 if (serial->rx_urb[idx] == urb) in hso_urb_to_index()
522 dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); in hso_urb_to_index()
523 return -1; in hso_urb_to_index()
590 (dev2ser(serial_table[i])->shared_int == shared_int) && in get_serial_by_shared_int_and_type()
591 ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { in get_serial_by_shared_int_and_type()
620 serial_table[index] = serial->parent; in obtain_minor()
621 serial->minor = index; in obtain_minor()
629 return -1; in obtain_minor()
637 serial_table[serial->minor] = NULL; in release_minor()
647 case -ENODEV: in handle_usb_error()
650 case -ENOENT: in handle_usb_error()
653 case -EPIPE: in handle_usb_error()
656 case -ENOSPC: in handle_usb_error()
659 case -ESHUTDOWN: in handle_usb_error()
662 case -EHOSTUNREACH: in handle_usb_error()
665 case -EINVAL: in handle_usb_error()
666 case -EAGAIN: in handle_usb_error()
667 case -EFBIG: in handle_usb_error()
668 case -EMSGSIZE: in handle_usb_error()
671 case -EILSEQ: in handle_usb_error()
672 case -EPROTO: in handle_usb_error()
673 case -ETIME: in handle_usb_error()
674 case -ETIMEDOUT: in handle_usb_error()
677 usb_queue_reset_device(hso_dev->interface); in handle_usb_error()
685 hso_dbg(0x1, "%s: received USB status - %s (%d)\n", in handle_usb_error()
698 dev_err(&net->dev, "No net device !\n"); in hso_net_open()
699 return -ENODEV; in hso_net_open()
702 odev->skb_tx_buf = NULL; in hso_net_open()
705 spin_lock_irqsave(&odev->net_lock, flags); in hso_net_open()
706 odev->rx_parse_state = WAIT_IP; in hso_net_open()
707 odev->rx_buf_size = 0; in hso_net_open()
708 odev->rx_buf_missing = sizeof(struct iphdr); in hso_net_open()
709 spin_unlock_irqrestore(&odev->net_lock, flags); in hso_net_open()
712 set_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_open()
713 hso_start_net_device(odev->parent); in hso_net_open()
729 clear_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_close()
731 hso_stop_net_device(odev->parent); in hso_net_close()
740 struct hso_net *odev = urb->context; in write_bulk_callback()
741 int status = urb->status; in write_bulk_callback()
744 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in write_bulk_callback()
745 dev_err(&urb->dev->dev, "%s: device not running\n", __func__); in write_bulk_callback()
750 if (!netif_device_present(odev->net)) { in write_bulk_callback()
751 dev_err(&urb->dev->dev, "%s: net device not present\n", in write_bulk_callback()
759 handle_usb_error(status, __func__, odev->parent); in write_bulk_callback()
761 hso_put_activity(odev->parent); in write_bulk_callback()
764 netif_wake_queue(odev->net); in write_bulk_callback()
776 if (hso_get_activity(odev->parent) == -EAGAIN) { in hso_net_start_xmit()
777 odev->skb_tx_buf = skb; in hso_net_start_xmit()
782 DUMP1(skb->data, skb->len); in hso_net_start_xmit()
784 memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); in hso_net_start_xmit()
785 hso_dbg(0x1, "len: %d/%d\n", skb->len, MUX_BULK_TX_BUF_SIZE); in hso_net_start_xmit()
788 usb_fill_bulk_urb(odev->mux_bulk_tx_urb, in hso_net_start_xmit()
789 odev->parent->usb, in hso_net_start_xmit()
790 usb_sndbulkpipe(odev->parent->usb, in hso_net_start_xmit()
791 odev->out_endp-> in hso_net_start_xmit()
793 odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, in hso_net_start_xmit()
797 odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; in hso_net_start_xmit()
800 result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); in hso_net_start_xmit()
802 dev_warn(&odev->parent->interface->dev, in hso_net_start_xmit()
804 net->stats.tx_errors++; in hso_net_start_xmit()
807 net->stats.tx_packets++; in hso_net_start_xmit()
808 net->stats.tx_bytes += skb->len; in hso_net_start_xmit()
828 dev_warn(&net->dev, "Tx timed out.\n"); in hso_net_tx_timeout()
831 if (odev->mux_bulk_tx_urb) in hso_net_tx_timeout()
832 usb_unlink_urb(odev->mux_bulk_tx_urb); in hso_net_tx_timeout()
835 net->stats.tx_errors++; in hso_net_tx_timeout()
851 switch (odev->rx_parse_state) { in packetizeRx()
854 /* wanted bytes - size of ip header */ in packetizeRx()
857 odev->rx_buf_missing) ? count : odev-> in packetizeRx()
860 memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + in packetizeRx()
861 odev->rx_buf_size, ip_pkt + buffer_offset, in packetizeRx()
864 odev->rx_buf_size += temp_bytes; in packetizeRx()
866 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
867 count -= temp_bytes; in packetizeRx()
869 if (!odev->rx_buf_missing) { in packetizeRx()
872 frame_len = ntohs(odev->rx_ip_hdr.tot_len); in packetizeRx()
876 dev_err(&odev->net->dev, in packetizeRx()
879 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
883 odev->skb_rx_buf = netdev_alloc_skb(odev->net, in packetizeRx()
885 if (!odev->skb_rx_buf) { in packetizeRx()
888 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
894 skb_put_data(odev->skb_rx_buf, in packetizeRx()
895 (char *)&(odev->rx_ip_hdr), in packetizeRx()
899 odev->rx_buf_size = sizeof(struct iphdr); in packetizeRx()
902 odev->rx_buf_missing = in packetizeRx()
903 frame_len - sizeof(struct iphdr); in packetizeRx()
904 odev->rx_parse_state = WAIT_DATA; in packetizeRx()
909 temp_bytes = (count < odev->rx_buf_missing) in packetizeRx()
910 ? count : odev->rx_buf_missing; in packetizeRx()
915 skb_put_data(odev->skb_rx_buf, in packetizeRx()
919 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
920 count -= temp_bytes; in packetizeRx()
922 odev->rx_buf_size += temp_bytes; in packetizeRx()
923 if (!odev->rx_buf_missing) { in packetizeRx()
926 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); in packetizeRx()
927 skb_reset_mac_header(odev->skb_rx_buf); in packetizeRx()
930 netif_rx(odev->skb_rx_buf); in packetizeRx()
932 odev->skb_rx_buf = NULL; in packetizeRx()
935 odev->net->stats.rx_packets++; in packetizeRx()
937 odev->net->stats.rx_bytes += odev->rx_buf_size; in packetizeRx()
939 odev->rx_buf_size = 0; in packetizeRx()
940 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
941 odev->rx_parse_state = WAIT_IP; in packetizeRx()
951 count--; in packetizeRx()
958 if (odev->rx_parse_state == WAIT_SYNC) { in packetizeRx()
959 odev->rx_parse_state = WAIT_IP; in packetizeRx()
960 odev->rx_buf_size = 0; in packetizeRx()
961 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
969 u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); in fix_crc_bug()
972 !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, in fix_crc_bug()
974 urb->actual_length -= 4; in fix_crc_bug()
981 struct hso_net *odev = urb->context; in read_bulk_callback()
985 int status = urb->status; in read_bulk_callback()
989 handle_usb_error(status, __func__, odev->parent); in read_bulk_callback()
994 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in read_bulk_callback()
998 usb_mark_last_busy(urb->dev); in read_bulk_callback()
1000 net = odev->net; in read_bulk_callback()
1007 if (odev->parent->port_spec & HSO_INFO_CRC_BUG) in read_bulk_callback()
1008 fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); in read_bulk_callback()
1011 if (urb->actual_length) { in read_bulk_callback()
1014 spin_lock_irqsave(&odev->net_lock, flags); in read_bulk_callback()
1015 packetizeRx(odev, urb->transfer_buffer, urb->actual_length, in read_bulk_callback()
1016 (urb->transfer_buffer_length > in read_bulk_callback()
1017 urb->actual_length) ? 1 : 0); in read_bulk_callback()
1018 spin_unlock_irqrestore(&odev->net_lock, flags); in read_bulk_callback()
1024 odev->parent->usb, in read_bulk_callback()
1025 usb_rcvbulkpipe(odev->parent->usb, in read_bulk_callback()
1026 odev->in_endp-> in read_bulk_callback()
1028 urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, in read_bulk_callback()
1035 dev_warn(&odev->parent->interface->dev, in read_bulk_callback()
1047 termios->c_iflag &= in hso_init_termios()
1058 termios->c_oflag &= ~OPOST; in hso_init_termios()
1060 termios->c_lflag &= in hso_init_termios()
1067 | IEXTEN); /* disable non-POSIX special characters */ in hso_init_termios()
1069 termios->c_cflag &= in hso_init_termios()
1075 termios->c_cflag |= CS8; /* character size 8 bits */ in hso_init_termios()
1083 struct hso_serial *serial = tty->driver_data; in _hso_serial_set_termios()
1090 hso_dbg(0x8, "port %d\n", serial->minor); in _hso_serial_set_termios()
1095 tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ in _hso_serial_set_termios()
1097 tty->termios.c_cflag &= in _hso_serial_set_termios()
1103 tty->termios.c_cflag |= CS8; /* character size 8 bits */ in _hso_serial_set_termios()
1114 usb_fill_bulk_urb(urb, serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1115 usb_rcvbulkpipe(serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1116 serial->in_endp-> in hso_resubmit_rx_bulk_urb()
1118 urb->transfer_buffer, serial->rx_data_length, in hso_resubmit_rx_bulk_urb()
1124 dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", in hso_resubmit_rx_bulk_urb()
1137 while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { in put_rxbuf_data_and_resubmit_bulk_urb()
1138 curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; in put_rxbuf_data_and_resubmit_bulk_urb()
1140 if (count == -1) in put_rxbuf_data_and_resubmit_bulk_urb()
1143 serial->curr_rx_urb_idx++; in put_rxbuf_data_and_resubmit_bulk_urb()
1144 if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) in put_rxbuf_data_and_resubmit_bulk_urb()
1145 serial->curr_rx_urb_idx = 0; in put_rxbuf_data_and_resubmit_bulk_urb()
1156 urb = serial->rx_urb[0]; in put_rxbuf_data_and_resubmit_ctrl_urb()
1157 if (serial->port.count > 0) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1159 if (count == -1) in put_rxbuf_data_and_resubmit_ctrl_urb()
1164 if (count == 0 && ((urb->actual_length != 0) || in put_rxbuf_data_and_resubmit_ctrl_urb()
1165 (serial->rx_state == RX_PENDING))) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1166 serial->rx_state = RX_SENT; in put_rxbuf_data_and_resubmit_ctrl_urb()
1169 serial->rx_state = RX_IDLE; in put_rxbuf_data_and_resubmit_ctrl_urb()
1176 struct hso_serial *serial = urb->context; in hso_std_serial_read_bulk_callback()
1177 int status = urb->status; in hso_std_serial_read_bulk_callback()
1180 hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status); in hso_std_serial_read_bulk_callback()
1188 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_read_bulk_callback()
1192 hso_dbg(0x1, "Actual length = %d\n", urb->actual_length); in hso_std_serial_read_bulk_callback()
1193 DUMP1(urb->transfer_buffer, urb->actual_length); in hso_std_serial_read_bulk_callback()
1196 if (serial->port.count == 0) in hso_std_serial_read_bulk_callback()
1199 if (serial->parent->port_spec & HSO_INFO_CRC_BUG) in hso_std_serial_read_bulk_callback()
1200 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); in hso_std_serial_read_bulk_callback()
1202 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1203 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; in hso_std_serial_read_bulk_callback()
1205 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1218 spin_lock_irqsave(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1219 if ((serial->parent->port_spec & HSO_INTF_MUX)) in hso_unthrottle_tasklet()
1223 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1228 struct hso_serial *serial = tty->driver_data; in hso_unthrottle()
1230 tasklet_hi_schedule(&serial->unthrottle_tasklet); in hso_unthrottle()
1236 struct hso_serial *serial = get_serial_by_index(tty->index); in hso_serial_open()
1240 if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { in hso_serial_open()
1242 tty->driver_data = NULL; in hso_serial_open()
1244 return -ENODEV; in hso_serial_open()
1247 mutex_lock(&serial->parent->mutex); in hso_serial_open()
1248 result = usb_autopm_get_interface(serial->parent->interface); in hso_serial_open()
1252 hso_dbg(0x1, "Opening %d\n", serial->minor); in hso_serial_open()
1255 tty->driver_data = serial; in hso_serial_open()
1256 tty_port_tty_set(&serial->port, tty); in hso_serial_open()
1259 serial->port.count++; in hso_serial_open()
1260 if (serial->port.count == 1) { in hso_serial_open()
1261 serial->rx_state = RX_IDLE; in hso_serial_open()
1264 tasklet_setup(&serial->unthrottle_tasklet, in hso_serial_open()
1266 result = hso_start_serial_device(serial->parent, GFP_KERNEL); in hso_serial_open()
1268 hso_stop_serial_device(serial->parent); in hso_serial_open()
1269 serial->port.count--; in hso_serial_open()
1271 kref_get(&serial->parent->ref); in hso_serial_open()
1277 usb_autopm_put_interface(serial->parent->interface); in hso_serial_open()
1283 mutex_unlock(&serial->parent->mutex); in hso_serial_open()
1290 struct hso_serial *serial = tty->driver_data; in hso_serial_close()
1299 mutex_lock(&serial->parent->mutex); in hso_serial_close()
1300 usb_gone = serial->parent->usb_gone; in hso_serial_close()
1303 usb_autopm_get_interface(serial->parent->interface); in hso_serial_close()
1305 /* reset the rts and dtr */ in hso_serial_close()
1307 serial->port.count--; in hso_serial_close()
1309 if (serial->port.count <= 0) { in hso_serial_close()
1310 serial->port.count = 0; in hso_serial_close()
1311 tty_port_tty_set(&serial->port, NULL); in hso_serial_close()
1313 hso_stop_serial_device(serial->parent); in hso_serial_close()
1314 tasklet_kill(&serial->unthrottle_tasklet); in hso_serial_close()
1318 usb_autopm_put_interface(serial->parent->interface); in hso_serial_close()
1320 mutex_unlock(&serial->parent->mutex); in hso_serial_close()
1327 struct hso_serial *serial = tty->driver_data; in hso_serial_write()
1333 return -ENODEV; in hso_serial_write()
1336 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write()
1338 count = min_t(size_t, serial->tx_data_length - serial->tx_buffer_count, in hso_serial_write()
1340 memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, count); in hso_serial_write()
1341 serial->tx_buffer_count += count; in hso_serial_write()
1343 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write()
1353 struct hso_serial *serial = tty->driver_data; in hso_serial_write_room()
1357 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write_room()
1358 room = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write_room()
1359 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write_room()
1367 struct hso_serial *serial = tty->driver_data; in hso_serial_cleanup()
1372 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_serial_cleanup()
1379 struct hso_serial *serial = tty->driver_data; in hso_serial_set_termios()
1383 hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", in hso_serial_set_termios()
1384 (unsigned int)tty->termios.c_cflag, in hso_serial_set_termios()
1385 (unsigned int)old->c_cflag); in hso_serial_set_termios()
1388 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_set_termios()
1389 if (serial->port.count) in hso_serial_set_termios()
1392 tty->termios = *old; in hso_serial_set_termios()
1393 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_set_termios()
1401 struct hso_serial *serial = tty->driver_data; in hso_serial_chars_in_buffer()
1409 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1410 chars = serial->tx_buffer_count; in hso_serial_chars_in_buffer()
1411 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1421 if (serial->parent->usb_gone) in tiocmget_submit_urb()
1422 return -ENODEV; in tiocmget_submit_urb()
1423 usb_fill_int_urb(tiocmget->urb, usb, in tiocmget_submit_urb()
1425 tiocmget->endp-> in tiocmget_submit_urb()
1427 tiocmget->serial_state_notification, in tiocmget_submit_urb()
1430 tiocmget->endp->bInterval); in tiocmget_submit_urb()
1431 result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); in tiocmget_submit_urb()
1433 dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, in tiocmget_submit_urb()
1442 struct hso_serial *serial = urb->context; in tiocmget_intr_callback()
1444 int status = urb->status; in tiocmget_intr_callback()
1456 handle_usb_error(status, __func__, serial->parent); in tiocmget_intr_callback()
1461 tiocmget = serial->tiocmget; in tiocmget_intr_callback()
1464 BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); in tiocmget_intr_callback()
1466 usb = serial->parent->usb; in tiocmget_intr_callback()
1467 interface = serial->parent->interface; in tiocmget_intr_callback()
1469 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in tiocmget_intr_callback()
1474 serial_state_notification = tiocmget->serial_state_notification; in tiocmget_intr_callback()
1475 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || in tiocmget_intr_callback()
1476 serial_state_notification->bNotification != B_NOTIFICATION || in tiocmget_intr_callback()
1477 le16_to_cpu(serial_state_notification->wValue) != W_VALUE || in tiocmget_intr_callback()
1478 le16_to_cpu(serial_state_notification->wIndex) != if_num || in tiocmget_intr_callback()
1479 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { in tiocmget_intr_callback()
1480 dev_warn(&usb->dev, in tiocmget_intr_callback()
1487 UART_state_bitmap = le16_to_cpu(serial_state_notification-> in tiocmget_intr_callback()
1489 prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; in tiocmget_intr_callback()
1490 icount = &tiocmget->icount; in tiocmget_intr_callback()
1491 spin_lock_irqsave(&serial->serial_lock, flags); in tiocmget_intr_callback()
1494 icount->parity++; in tiocmget_intr_callback()
1497 icount->parity++; in tiocmget_intr_callback()
1500 icount->frame++; in tiocmget_intr_callback()
1503 icount->rng++; in tiocmget_intr_callback()
1506 icount->brk++; in tiocmget_intr_callback()
1509 icount->dsr++; in tiocmget_intr_callback()
1512 icount->dcd++; in tiocmget_intr_callback()
1513 tiocmget->prev_UART_state_bitmap = UART_state_bitmap; in tiocmget_intr_callback()
1514 spin_unlock_irqrestore(&serial->serial_lock, flags); in tiocmget_intr_callback()
1515 tiocmget->intr_completed = 1; in tiocmget_intr_callback()
1516 wake_up_interruptible(&tiocmget->waitq); in tiocmget_intr_callback()
1522 serial->parent->usb); in tiocmget_intr_callback()
1528 /* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1529 * - mask passed in arg for lines of interest
1530 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1541 tiocmget = serial->tiocmget; in hso_wait_modem_status()
1543 return -ENOENT; in hso_wait_modem_status()
1547 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1548 memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1549 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1550 add_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1552 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1553 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1554 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1565 ret = -ERESTARTSYS; in hso_wait_modem_status()
1571 remove_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1577 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1579 * NB: both 1->0 and 0->1 transitions are counted except for
1580 * RI where only 0->1 is counted.
1586 struct hso_serial *serial = tty->driver_data; in hso_get_count()
1587 struct hso_tiocmget *tiocmget = serial->tiocmget; in hso_get_count()
1592 return -ENOENT; in hso_get_count()
1593 spin_lock_irq(&serial->serial_lock); in hso_get_count()
1594 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_get_count()
1595 spin_unlock_irq(&serial->serial_lock); in hso_get_count()
1597 icount->cts = cnow.cts; in hso_get_count()
1598 icount->dsr = cnow.dsr; in hso_get_count()
1599 icount->rng = cnow.rng; in hso_get_count()
1600 icount->dcd = cnow.dcd; in hso_get_count()
1601 icount->rx = cnow.rx; in hso_get_count()
1602 icount->tx = cnow.tx; in hso_get_count()
1603 icount->frame = cnow.frame; in hso_get_count()
1604 icount->overrun = cnow.overrun; in hso_get_count()
1605 icount->parity = cnow.parity; in hso_get_count()
1606 icount->brk = cnow.brk; in hso_get_count()
1607 icount->buf_overrun = cnow.buf_overrun; in hso_get_count()
1616 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmget()
1623 return -EINVAL; in hso_serial_tiocmget()
1625 spin_lock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1626 retval = ((serial->rts_state) ? TIOCM_RTS : 0) | in hso_serial_tiocmget()
1627 ((serial->dtr_state) ? TIOCM_DTR : 0); in hso_serial_tiocmget()
1628 tiocmget = serial->tiocmget; in hso_serial_tiocmget()
1632 tiocmget->prev_UART_state_bitmap); in hso_serial_tiocmget()
1640 spin_unlock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1650 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmset()
1656 return -EINVAL; in hso_serial_tiocmset()
1659 if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) in hso_serial_tiocmset()
1660 return -EINVAL; in hso_serial_tiocmset()
1662 interface = serial->parent->interface; in hso_serial_tiocmset()
1663 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_serial_tiocmset()
1665 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_tiocmset()
1667 serial->rts_state = 1; in hso_serial_tiocmset()
1669 serial->dtr_state = 1; in hso_serial_tiocmset()
1672 serial->rts_state = 0; in hso_serial_tiocmset()
1674 serial->dtr_state = 0; in hso_serial_tiocmset()
1676 if (serial->dtr_state) in hso_serial_tiocmset()
1678 if (serial->rts_state) in hso_serial_tiocmset()
1681 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_tiocmset()
1683 return usb_control_msg(serial->parent->usb, in hso_serial_tiocmset()
1684 usb_sndctrlpipe(serial->parent->usb, 0), 0x22, in hso_serial_tiocmset()
1692 struct hso_serial *serial = tty->driver_data; in hso_serial_ioctl()
1697 return -ENODEV; in hso_serial_ioctl()
1703 ret = -ENOIOCTLCMD; in hso_serial_ioctl()
1716 spin_lock_irqsave(&serial->serial_lock, flags); in hso_kick_transmit()
1717 if (!serial->tx_buffer_count) in hso_kick_transmit()
1720 if (serial->tx_urb_used) in hso_kick_transmit()
1724 if (hso_get_activity(serial->parent) == -EAGAIN) in hso_kick_transmit()
1728 swap(serial->tx_buffer, serial->tx_data); in hso_kick_transmit()
1729 serial->tx_data_count = serial->tx_buffer_count; in hso_kick_transmit()
1730 serial->tx_buffer_count = 0; in hso_kick_transmit()
1732 /* If serial->tx_data is set, it means we switched buffers */ in hso_kick_transmit()
1733 if (serial->tx_data && serial->write_data) { in hso_kick_transmit()
1734 res = serial->write_data(serial); in hso_kick_transmit()
1736 serial->tx_urb_used = 1; in hso_kick_transmit()
1739 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_kick_transmit()
1754 return -EINVAL; in mux_device_request()
1758 ctrl_req->wValue = 0; in mux_device_request()
1759 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); in mux_device_request()
1760 ctrl_req->wLength = cpu_to_le16(size); in mux_device_request()
1764 ctrl_req->bRequestType = USB_DIR_IN | in mux_device_request()
1767 ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; in mux_device_request()
1768 pipe = usb_rcvctrlpipe(serial->parent->usb, 0); in mux_device_request()
1771 ctrl_req->bRequestType = USB_DIR_OUT | in mux_device_request()
1774 ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; in mux_device_request()
1775 pipe = usb_sndctrlpipe(serial->parent->usb, 0); in mux_device_request()
1780 ctrl_req->bRequestType, ctrl_req->wLength, port); in mux_device_request()
1783 ctrl_urb->transfer_flags = 0; in mux_device_request()
1785 serial->parent->usb, in mux_device_request()
1792 dev_err(&ctrl_urb->dev->dev, in mux_device_request()
1806 return -EINVAL; in hso_mux_serial_read()
1809 memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); in hso_mux_serial_read()
1812 if (serial->num_rx_urbs != 1) { in hso_mux_serial_read()
1813 dev_err(&serial->parent->interface->dev, in hso_mux_serial_read()
1820 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_read()
1821 serial->rx_urb[0], in hso_mux_serial_read()
1822 &serial->ctrl_req_rx, in hso_mux_serial_read()
1823 serial->rx_data[0], serial->rx_data_length); in hso_mux_serial_read()
1829 struct hso_shared_int *shared_int = urb->context; in intr_callback()
1832 int status = urb->status; in intr_callback()
1836 usb_mark_last_busy(urb->dev); in intr_callback()
1847 hso_dbg(0x8, "--- Got intr callback 0x%02X ---\n", status); in intr_callback()
1850 port_req = urb->transfer_buffer; in intr_callback()
1861 spin_lock_irqsave(&serial->serial_lock, flags); in intr_callback()
1862 if (serial->rx_state == RX_IDLE && in intr_callback()
1863 serial->port.count > 0) { in intr_callback()
1866 if (!serial->rx_urb_filled[0]) { in intr_callback()
1867 serial->rx_state = RX_SENT; in intr_callback()
1870 serial->rx_state = RX_PENDING; in intr_callback()
1875 spin_unlock_irqrestore(&serial->serial_lock, in intr_callback()
1881 hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); in intr_callback()
1888 return -EINVAL; in hso_mux_serial_write_data()
1892 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_write_data()
1893 serial->tx_urb, in hso_mux_serial_write_data()
1894 &serial->ctrl_req_tx, in hso_mux_serial_write_data()
1895 serial->tx_data, serial->tx_data_count); in hso_mux_serial_write_data()
1901 struct hso_serial *serial = urb->context; in hso_std_serial_write_bulk_callback()
1902 int status = urb->status; in hso_std_serial_write_bulk_callback()
1911 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1912 serial->tx_urb_used = 0; in hso_std_serial_write_bulk_callback()
1913 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1915 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_write_bulk_callback()
1918 hso_put_activity(serial->parent); in hso_std_serial_write_bulk_callback()
1919 tty_port_tty_wakeup(&serial->port); in hso_std_serial_write_bulk_callback()
1928 int count = serial->tx_data_count; in hso_std_serial_write_data()
1931 usb_fill_bulk_urb(serial->tx_urb, in hso_std_serial_write_data()
1932 serial->parent->usb, in hso_std_serial_write_data()
1933 usb_sndbulkpipe(serial->parent->usb, in hso_std_serial_write_data()
1934 serial->out_endp-> in hso_std_serial_write_data()
1936 serial->tx_data, serial->tx_data_count, in hso_std_serial_write_data()
1939 result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); in hso_std_serial_write_data()
1941 dev_warn(&serial->parent->usb->dev, in hso_std_serial_write_data()
1942 "Failed to submit urb - res %d\n", result); in hso_std_serial_write_data()
1952 struct hso_serial *serial = urb->context; in ctrl_callback()
1954 int status = urb->status; in ctrl_callback()
1961 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1962 serial->tx_urb_used = 0; in ctrl_callback()
1963 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1965 handle_usb_error(status, __func__, serial->parent); in ctrl_callback()
1970 req = (struct usb_ctrlrequest *)(urb->setup_packet); in ctrl_callback()
1971 hso_dbg(0x8, "--- Got muxed ctrl callback 0x%02X ---\n", status); in ctrl_callback()
1972 hso_dbg(0x8, "Actual length of urb = %d\n", urb->actual_length); in ctrl_callback()
1973 DUMP1(urb->transfer_buffer, urb->actual_length); in ctrl_callback()
1975 if (req->bRequestType == in ctrl_callback()
1978 serial->rx_urb_filled[0] = 1; in ctrl_callback()
1979 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1981 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1983 hso_put_activity(serial->parent); in ctrl_callback()
1984 tty_port_tty_wakeup(&serial->port); in ctrl_callback()
1999 return -2; in put_rxbuf_data()
2002 tty = tty_port_tty_get(&serial->port); in put_rxbuf_data()
2006 return -1; in put_rxbuf_data()
2011 count = tty_buffer_request_room(&serial->port, urb->actual_length); in put_rxbuf_data()
2012 if (count >= urb->actual_length) { in put_rxbuf_data()
2013 tty_insert_flip_string(&serial->port, urb->transfer_buffer, in put_rxbuf_data()
2014 urb->actual_length); in put_rxbuf_data()
2015 tty_flip_buffer_push(&serial->port); in put_rxbuf_data()
2017 dev_warn(&serial->parent->usb->dev, in put_rxbuf_data()
2018 "dropping data, %d bytes lost\n", urb->actual_length); in put_rxbuf_data()
2023 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; in put_rxbuf_data()
2036 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_log_port()
2071 if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { in hso_log_port()
2072 sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); in hso_log_port()
2075 dev2ser(hso_dev)->minor); in hso_log_port()
2077 dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", in hso_log_port()
2087 return -ENODEV; in hso_start_net_device()
2093 usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2094 hso_dev->usb, in hso_start_net_device()
2095 usb_rcvbulkpipe(hso_dev->usb, in hso_start_net_device()
2096 hso_net->in_endp-> in hso_start_net_device()
2098 hso_net->mux_bulk_rx_buf_pool[i], in hso_start_net_device()
2103 result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2106 dev_warn(&hso_dev->usb->dev, in hso_start_net_device()
2120 return -ENODEV; in hso_stop_net_device()
2123 if (hso_net->mux_bulk_rx_urb_pool[i]) in hso_stop_net_device()
2124 usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_stop_net_device()
2127 if (hso_net->mux_bulk_tx_urb) in hso_stop_net_device()
2128 usb_kill_urb(hso_net->mux_bulk_tx_urb); in hso_stop_net_device()
2139 return -ENODEV; in hso_start_serial_device()
2143 if (!(serial->parent->port_spec & HSO_INTF_MUX)) { in hso_start_serial_device()
2144 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_start_serial_device()
2145 usb_fill_bulk_urb(serial->rx_urb[i], in hso_start_serial_device()
2146 serial->parent->usb, in hso_start_serial_device()
2147 usb_rcvbulkpipe(serial->parent->usb, in hso_start_serial_device()
2148 serial->in_endp-> in hso_start_serial_device()
2151 serial->rx_data[i], in hso_start_serial_device()
2152 serial->rx_data_length, in hso_start_serial_device()
2155 result = usb_submit_urb(serial->rx_urb[i], flags); in hso_start_serial_device()
2157 dev_warn(&serial->parent->usb->dev, in hso_start_serial_device()
2158 "Failed to submit urb - res %d\n", in hso_start_serial_device()
2164 mutex_lock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2165 if (!serial->shared_int->use_count) { in hso_start_serial_device()
2167 hso_mux_submit_intr_urb(serial->shared_int, in hso_start_serial_device()
2168 hso_dev->usb, flags); in hso_start_serial_device()
2170 serial->shared_int->use_count++; in hso_start_serial_device()
2171 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2173 if (serial->tiocmget) in hso_start_serial_device()
2175 serial->tiocmget, in hso_start_serial_device()
2176 serial->parent->usb); in hso_start_serial_device()
2187 return -ENODEV; in hso_stop_serial_device()
2189 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_stop_serial_device()
2190 if (serial->rx_urb[i]) { in hso_stop_serial_device()
2191 usb_kill_urb(serial->rx_urb[i]); in hso_stop_serial_device()
2192 serial->rx_urb_filled[i] = 0; in hso_stop_serial_device()
2195 serial->curr_rx_urb_idx = 0; in hso_stop_serial_device()
2197 if (serial->tx_urb) in hso_stop_serial_device()
2198 usb_kill_urb(serial->tx_urb); in hso_stop_serial_device()
2200 if (serial->shared_int) { in hso_stop_serial_device()
2201 mutex_lock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2202 if (serial->shared_int->use_count && in hso_stop_serial_device()
2203 (--serial->shared_int->use_count == 0)) { in hso_stop_serial_device()
2206 urb = serial->shared_int->shared_intr_urb; in hso_stop_serial_device()
2210 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2212 tiocmget = serial->tiocmget; in hso_stop_serial_device()
2214 wake_up_interruptible(&tiocmget->waitq); in hso_stop_serial_device()
2215 usb_kill_urb(tiocmget->urb); in hso_stop_serial_device()
2223 tty_unregister_device(tty_drv, serial->minor); in hso_serial_tty_unregister()
2231 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_free()
2233 usb_free_urb(serial->rx_urb[i]); in hso_serial_common_free()
2235 kfree(serial->rx_data[i]); in hso_serial_common_free()
2239 usb_free_urb(serial->tx_urb); in hso_serial_common_free()
2240 kfree(serial->tx_buffer); in hso_serial_common_free()
2241 kfree(serial->tx_data); in hso_serial_common_free()
2242 tty_port_destroy(&serial->port); in hso_serial_common_free()
2250 tty_port_init(&serial->port); in hso_serial_common_create()
2256 serial->parent->dev = tty_port_register_device_attr(&serial->port, in hso_serial_common_create()
2257 tty_drv, serial->minor, &serial->parent->interface->dev, in hso_serial_common_create()
2258 serial->parent, hso_serial_dev_groups); in hso_serial_common_create()
2259 if (IS_ERR(serial->parent->dev)) { in hso_serial_common_create()
2264 serial->magic = HSO_SERIAL_MAGIC; in hso_serial_common_create()
2265 spin_lock_init(&serial->serial_lock); in hso_serial_common_create()
2266 serial->num_rx_urbs = num_urbs; in hso_serial_common_create()
2271 serial->rx_data_length = rx_size; in hso_serial_common_create()
2272 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_create()
2273 serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2274 if (!serial->rx_urb[i]) in hso_serial_common_create()
2276 serial->rx_urb[i]->transfer_buffer = NULL; in hso_serial_common_create()
2277 serial->rx_urb[i]->transfer_buffer_length = 0; in hso_serial_common_create()
2278 serial->rx_data[i] = kzalloc(serial->rx_data_length, in hso_serial_common_create()
2280 if (!serial->rx_data[i]) in hso_serial_common_create()
2285 serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2286 if (!serial->tx_urb) in hso_serial_common_create()
2288 serial->tx_urb->transfer_buffer = NULL; in hso_serial_common_create()
2289 serial->tx_urb->transfer_buffer_length = 0; in hso_serial_common_create()
2291 serial->tx_data_count = 0; in hso_serial_common_create()
2292 serial->tx_buffer_count = 0; in hso_serial_common_create()
2293 serial->tx_data_length = tx_size; in hso_serial_common_create()
2294 serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2295 if (!serial->tx_data) in hso_serial_common_create()
2298 serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2299 if (!serial->tx_buffer) in hso_serial_common_create()
2307 return -1; in hso_serial_common_create()
2320 hso_dev->port_spec = port_spec; in hso_create_device()
2321 hso_dev->usb = interface_to_usbdev(intf); in hso_create_device()
2322 hso_dev->interface = intf; in hso_create_device()
2323 kref_init(&hso_dev->ref); in hso_create_device()
2324 mutex_init(&hso_dev->mutex); in hso_create_device()
2326 INIT_WORK(&hso_dev->async_get_intf, async_get_intf); in hso_create_device()
2327 INIT_WORK(&hso_dev->async_put_intf, async_put_intf); in hso_create_device()
2344 return -1; in remove_net_device()
2357 remove_net_device(hso_net->parent); in hso_free_net_device()
2359 if (hso_net->net) in hso_free_net_device()
2360 unregister_netdev(hso_net->net); in hso_free_net_device()
2364 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_free_net_device()
2365 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_free_net_device()
2366 hso_net->mux_bulk_rx_buf_pool[i] = NULL; in hso_free_net_device()
2368 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_free_net_device()
2369 kfree(hso_net->mux_bulk_tx_buf); in hso_free_net_device()
2370 hso_net->mux_bulk_tx_buf = NULL; in hso_free_net_device()
2372 if (hso_net->net) in hso_free_net_device()
2373 free_netdev(hso_net->net); in hso_free_net_device()
2393 net->netdev_ops = &hso_netdev_ops; in hso_net_init()
2394 net->watchdog_timeo = HSO_NET_TX_TIMEOUT; in hso_net_init()
2395 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; in hso_net_init()
2396 net->type = ARPHRD_NONE; in hso_net_init()
2397 net->mtu = DEFAULT_MTU - 14; in hso_net_init()
2398 net->tx_queue_len = 10; in hso_net_init()
2399 net->ethtool_ops = &ops; in hso_net_init()
2402 spin_lock_init(&hso_net->net_lock); in hso_net_init()
2417 return -1; in add_net_device()
2427 mutex_lock(&hso_dev->mutex); in hso_rfkill_set_block()
2428 if (hso_dev->usb_gone) in hso_rfkill_set_block()
2431 rv = usb_control_msg(hso_dev->usb, usb_sndctrlpipe(hso_dev->usb, 0), in hso_rfkill_set_block()
2434 mutex_unlock(&hso_dev->mutex); in hso_rfkill_set_block()
2447 struct device *dev = &hso_net->net->dev; in hso_create_rfkill()
2450 snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d", in hso_create_rfkill()
2453 hso_net->rfkill = rfkill_alloc(hso_net->name, in hso_create_rfkill()
2454 &interface_to_usbdev(interface)->dev, in hso_create_rfkill()
2457 if (!hso_net->rfkill) in hso_create_rfkill()
2460 if (rfkill_register(hso_net->rfkill) < 0) { in hso_create_rfkill()
2461 rfkill_destroy(hso_net->rfkill); in hso_create_rfkill()
2462 hso_net->rfkill = NULL; in hso_create_rfkill()
2463 dev_err(dev, "%s - Failed to register rfkill\n", __func__); in hso_create_rfkill()
2490 dev_err(&interface->dev, "Unable to create ethernet device\n"); in hso_create_net_device()
2496 hso_dev->port_data.dev_net = hso_net; in hso_create_net_device()
2497 hso_net->net = net; in hso_create_net_device()
2498 hso_net->parent = hso_dev; in hso_create_net_device()
2500 hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2502 if (!hso_net->in_endp) { in hso_create_net_device()
2503 dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); in hso_create_net_device()
2506 hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2508 if (!hso_net->out_endp) { in hso_create_net_device()
2509 dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); in hso_create_net_device()
2512 SET_NETDEV_DEV(net, &interface->dev); in hso_create_net_device()
2517 hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2518 if (!hso_net->mux_bulk_rx_urb_pool[i]) in hso_create_net_device()
2520 hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, in hso_create_net_device()
2522 if (!hso_net->mux_bulk_rx_buf_pool[i]) in hso_create_net_device()
2525 hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2526 if (!hso_net->mux_bulk_tx_urb) in hso_create_net_device()
2528 hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); in hso_create_net_device()
2529 if (!hso_net->mux_bulk_tx_buf) in hso_create_net_device()
2534 dev_err(&interface->dev, "Failed to add net device\n"); in hso_create_net_device()
2541 dev_err(&interface->dev, "Failed to register device\n"); in hso_create_net_device()
2554 kfree(hso_net->mux_bulk_tx_buf); in hso_create_net_device()
2556 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_create_net_device()
2559 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_create_net_device()
2560 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_create_net_device()
2574 tiocmget = serial->tiocmget; in hso_free_tiomget()
2576 usb_free_urb(tiocmget->urb); in hso_free_tiomget()
2577 tiocmget->urb = NULL; in hso_free_tiomget()
2578 serial->tiocmget = NULL; in hso_free_tiomget()
2579 kfree(tiocmget->serial_state_notification); in hso_free_tiomget()
2580 tiocmget->serial_state_notification = NULL; in hso_free_tiomget()
2585 /* Frees an AT channel ( goes for both mux and non-mux ) */
2595 if (serial->shared_int) { in hso_free_serial_device()
2596 mutex_lock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2597 if (--serial->shared_int->ref_count == 0) in hso_free_serial_device()
2598 hso_free_shared_int(serial->shared_int); in hso_free_serial_device()
2600 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2624 serial->parent = hso_dev; in hso_create_bulk_serial_device()
2625 hso_dev->port_data.dev_serial = serial; in hso_create_bulk_serial_device()
2629 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), in hso_create_bulk_serial_device()
2631 if (!serial->tiocmget) in hso_create_bulk_serial_device()
2633 serial->tiocmget->serial_state_notification in hso_create_bulk_serial_device()
2636 if (!serial->tiocmget->serial_state_notification) in hso_create_bulk_serial_device()
2638 tiocmget = serial->tiocmget; in hso_create_bulk_serial_device()
2639 tiocmget->endp = hso_get_ep(interface, in hso_create_bulk_serial_device()
2642 if (!tiocmget->endp) { in hso_create_bulk_serial_device()
2643 dev_err(&interface->dev, "Failed to find INT IN ep\n"); in hso_create_bulk_serial_device()
2647 tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_bulk_serial_device()
2648 if (!tiocmget->urb) in hso_create_bulk_serial_device()
2651 mutex_init(&tiocmget->mutex); in hso_create_bulk_serial_device()
2652 init_waitqueue_head(&tiocmget->waitq); in hso_create_bulk_serial_device()
2661 serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_bulk_serial_device()
2663 if (!serial->in_endp) { in hso_create_bulk_serial_device()
2664 dev_err(&interface->dev, "Failed to find BULK IN ep\n"); in hso_create_bulk_serial_device()
2669 (serial->out_endp = in hso_create_bulk_serial_device()
2671 dev_err(&interface->dev, "Failed to find BULK OUT ep\n"); in hso_create_bulk_serial_device()
2675 serial->write_data = hso_std_serial_write_data; in hso_create_bulk_serial_device()
2718 hso_dev->port_data.dev_serial = serial; in hso_create_mux_serial_device()
2719 serial->parent = hso_dev; in hso_create_mux_serial_device()
2725 serial->tx_data_length--; in hso_create_mux_serial_device()
2726 serial->write_data = hso_mux_serial_write_data; in hso_create_mux_serial_device()
2728 serial->shared_int = mux; in hso_create_mux_serial_device()
2729 mutex_lock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2730 serial->shared_int->ref_count++; in hso_create_mux_serial_device()
2731 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2749 usb_free_urb(mux->shared_intr_urb); in hso_free_shared_int()
2750 kfree(mux->shared_intr_buf); in hso_free_shared_int()
2751 mutex_unlock(&mux->shared_int_lock); in hso_free_shared_int()
2763 mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, in hso_create_shared_int()
2765 if (!mux->intr_endp) { in hso_create_shared_int()
2766 dev_err(&interface->dev, "Can't find INT IN endpoint\n"); in hso_create_shared_int()
2770 mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_shared_int()
2771 if (!mux->shared_intr_urb) in hso_create_shared_int()
2773 mux->shared_intr_buf = in hso_create_shared_int()
2774 kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), in hso_create_shared_int()
2776 if (!mux->shared_intr_buf) in hso_create_shared_int()
2779 mutex_init(&mux->shared_int_lock); in hso_create_shared_int()
2784 kfree(mux->shared_intr_buf); in hso_create_shared_int()
2785 usb_free_urb(mux->shared_intr_urb); in hso_create_shared_int()
2795 u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_get_config_data()
2799 return -ENOMEM; in hso_get_config_data()
2804 return -EIO; in hso_get_config_data()
2810 return -EINVAL; in hso_get_config_data()
2874 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { in hso_probe()
2875 dev_err(&interface->dev, "Not our interface\n"); in hso_probe()
2876 return -ENODEV; in hso_probe()
2879 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_probe()
2883 if (id->driver_info) { in hso_probe()
2887 if (((u32 *)(id->driver_info))[i] == 0) in hso_probe()
2889 port_spec = ((u32 *)(id->driver_info))[if_num]; in hso_probe()
2898 if (interface->num_altsetting > 1) in hso_probe()
2900 interface->needs_remote_wakeup = 1; in hso_probe()
2917 /* TODO: de-allocate everything */ in hso_probe()
2961 return -ENODEV; in hso_probe()
2977 usb_autopm_get_interface(hso_dev->interface); in async_get_intf()
2984 usb_autopm_put_interface(hso_dev->interface); in async_put_intf()
2989 if (hso_dev->usb->state == USB_STATE_SUSPENDED) { in hso_get_activity()
2990 if (!hso_dev->is_active) { in hso_get_activity()
2991 hso_dev->is_active = 1; in hso_get_activity()
2992 schedule_work(&hso_dev->async_get_intf); in hso_get_activity()
2996 if (hso_dev->usb->state != USB_STATE_CONFIGURED) in hso_get_activity()
2997 return -EAGAIN; in hso_get_activity()
2999 usb_mark_last_busy(hso_dev->usb); in hso_get_activity()
3006 if (hso_dev->usb->state != USB_STATE_SUSPENDED) { in hso_put_activity()
3007 if (hso_dev->is_active) { in hso_put_activity()
3008 hso_dev->is_active = 0; in hso_put_activity()
3009 schedule_work(&hso_dev->async_put_intf); in hso_put_activity()
3010 return -EAGAIN; in hso_put_activity()
3013 hso_dev->is_active = 0; in hso_put_activity()
3024 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_suspend()
3034 (network_table[i]->interface == iface)) { in hso_suspend()
3053 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_resume()
3054 if (dev2ser(serial_table[i])->port.count) { in hso_resume()
3067 (network_table[i]->interface == iface)) { in hso_resume()
3069 if (hso_net->flags & IFF_UP) { in hso_resume()
3072 if (hso_net->skb_tx_buf) { in hso_resume()
3073 dev_dbg(&iface->dev, in hso_resume()
3076 hso_net_start_xmit(hso_net->skb_tx_buf, in hso_resume()
3077 hso_net->net); in hso_resume()
3078 hso_net->skb_tx_buf = NULL; in hso_resume()
3105 (serial_table[i]->interface == interface)) { in hso_free_interface()
3107 tty_port_tty_hangup(&serial->port, false); in hso_free_interface()
3108 mutex_lock(&serial->parent->mutex); in hso_free_interface()
3109 serial->parent->usb_gone = 1; in hso_free_interface()
3110 mutex_unlock(&serial->parent->mutex); in hso_free_interface()
3111 cancel_work_sync(&serial_table[i]->async_put_intf); in hso_free_interface()
3112 cancel_work_sync(&serial_table[i]->async_get_intf); in hso_free_interface()
3114 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_free_interface()
3120 (network_table[i]->interface == interface)) { in hso_free_interface()
3121 struct rfkill *rfk = dev2net(network_table[i])->rfkill; in hso_free_interface()
3124 netif_stop_queue(dev2net(network_table[i])->net); in hso_free_interface()
3126 cancel_work_sync(&network_table[i]->async_put_intf); in hso_free_interface()
3127 cancel_work_sync(&network_table[i]->async_get_intf); in hso_free_interface()
3144 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_ep()
3147 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_ep()
3148 endp = &iface->endpoint[i].desc; in hso_get_ep()
3149 if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && in hso_get_ep()
3161 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_mux_ports()
3163 if (iface->extralen == 3) { in hso_get_mux_ports()
3164 *ports = iface->extra[2]; in hso_get_mux_ports()
3168 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_mux_ports()
3169 if (iface->endpoint[i].extralen == 3) { in hso_get_mux_ports()
3170 *ports = iface->endpoint[i].extra[2]; in hso_get_mux_ports()
3175 return -1; in hso_get_mux_ports()
3184 usb_fill_int_urb(shared_int->shared_intr_urb, usb, in hso_mux_submit_intr_urb()
3186 shared_int->intr_endp->bEndpointAddress & 0x7F), in hso_mux_submit_intr_urb()
3187 shared_int->shared_intr_buf, in hso_mux_submit_intr_urb()
3190 shared_int->intr_endp->bInterval); in hso_mux_submit_intr_urb()
3192 result = usb_submit_urb(shared_int->shared_intr_urb, gfp); in hso_mux_submit_intr_urb()
3194 dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, in hso_mux_submit_intr_urb()
3239 tty_drv->driver_name = driver_name; in hso_init()
3240 tty_drv->name = tty_filename; in hso_init()
3244 tty_drv->major = tty_major; in hso_init()
3246 tty_drv->minor_start = 0; in hso_init()
3247 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; in hso_init()
3248 tty_drv->subtype = SERIAL_TYPE_NORMAL; in hso_init()
3249 tty_drv->init_termios = tty_std_termios; in hso_init()
3250 hso_init_termios(&tty_drv->init_termios); in hso_init()
3256 pr_err("%s - tty_register_driver failed(%d)\n", in hso_init()
3264 pr_err("Could not register hso driver - error: %d\n", result); in hso_init()