Lines Matching +full:usb +full:- +full:to +full:- +full:serial
1 // SPDX-License-Identifier: GPL-2.0-only
12 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
22 * The multiplexed serial ports are using the interrupt and
31 * Interface 2: Standard modem interface - circuit switched interface, this
32 * can be used to make a standard ppp connection however it
34 * enabled for USB performance reasons i.e. if using this set
48 #include <linux/usb.h>
56 #include <linux/usb/cdc.h>
60 #include <linux/serial.h>
64 #define MOD_DESCRIPTION "USB High Speed Option driver"
83 /* - use *_bit operations on it. (bit indices not values.) */
90 /* Number of ttys to handle */
122 struct usb_device *usb; member
203 on which serial port it is used on. */
230 int (*write_data) (struct hso_serial *serial);
232 /* Hacks required to get flow control
233 * working on the serial receive buffers
234 * so as not to drop characters on the floor.
254 struct usb_device *usb; member
290 /* Serial driver functions */
294 static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial);
295 static void hso_kick_transmit(struct hso_serial *serial);
298 struct usb_device *usb, gfp_t gfp);
312 static int hso_mux_serial_read(struct hso_serial *serial);
326 return hso_dev->port_data.dev_net; in dev2net()
331 return hso_dev->port_data.dev_serial; in dev2ser()
367 /* the usb driver itself (registered in hso_init) */
369 /* serial structures */
418 {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */
420 {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */
421 {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */
457 MODULE_DEVICE_TABLE(usb, hso_ids);
470 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_sysfs_show_porttype()
517 static int hso_urb_to_index(struct hso_serial *serial, struct urb *urb) in hso_urb_to_index() argument
521 for (idx = 0; idx < serial->num_rx_urbs; idx++) in hso_urb_to_index()
522 if (serial->rx_urb[idx] == urb) in hso_urb_to_index()
524 dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); in hso_urb_to_index()
525 return -1; in hso_urb_to_index()
528 /* converts mux value to a port spec value */
555 /* converts port spec value to a mux value */
592 (dev2ser(serial_table[i])->shared_int == shared_int) && in get_serial_by_shared_int_and_type()
593 ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { in get_serial_by_shared_int_and_type()
603 struct hso_serial *serial = NULL; in get_serial_by_index() local
608 serial = dev2ser(serial_table[index]); in get_serial_by_index()
611 return serial; in get_serial_by_index()
614 static int obtain_minor(struct hso_serial *serial) in obtain_minor() argument
622 serial_table[index] = serial->parent; in obtain_minor()
623 serial->minor = index; in obtain_minor()
630 pr_err("%s: no free serial devices in table\n", __func__); in obtain_minor()
631 return -1; in obtain_minor()
634 static void release_minor(struct hso_serial *serial) in release_minor() argument
639 serial_table[serial->minor] = NULL; in release_minor()
649 case -ENODEV: in handle_usb_error()
652 case -ENOENT: in handle_usb_error()
655 case -EPIPE: in handle_usb_error()
658 case -ENOSPC: in handle_usb_error()
661 case -ESHUTDOWN: in handle_usb_error()
664 case -EHOSTUNREACH: in handle_usb_error()
667 case -EINVAL: in handle_usb_error()
668 case -EAGAIN: in handle_usb_error()
669 case -EFBIG: in handle_usb_error()
670 case -EMSGSIZE: in handle_usb_error()
673 case -EILSEQ: in handle_usb_error()
674 case -EPROTO: in handle_usb_error()
675 case -ETIME: in handle_usb_error()
676 case -ETIMEDOUT: in handle_usb_error()
679 usb_queue_reset_device(hso_dev->interface); in handle_usb_error()
686 /* log a meaningful explanation of an USB status */ in handle_usb_error()
687 hso_dbg(0x1, "%s: received USB status - %s (%d)\n", in handle_usb_error()
700 dev_err(&net->dev, "No net device !\n"); in hso_net_open()
701 return -ENODEV; in hso_net_open()
704 odev->skb_tx_buf = NULL; in hso_net_open()
707 spin_lock_irqsave(&odev->net_lock, flags); in hso_net_open()
708 odev->rx_parse_state = WAIT_IP; in hso_net_open()
709 odev->rx_buf_size = 0; in hso_net_open()
710 odev->rx_buf_missing = sizeof(struct iphdr); in hso_net_open()
711 spin_unlock_irqrestore(&odev->net_lock, flags); in hso_net_open()
714 set_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_open()
715 hso_start_net_device(odev->parent); in hso_net_open()
717 /* Tell the kernel we are ready to start receiving from it */ in hso_net_open()
731 clear_bit(HSO_NET_RUNNING, &odev->flags); in hso_net_close()
733 hso_stop_net_device(odev->parent); in hso_net_close()
739 /* USB tells is xmit done, we should start the netqueue again */
742 struct hso_net *odev = urb->context; in write_bulk_callback()
743 int status = urb->status; in write_bulk_callback()
746 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in write_bulk_callback()
747 dev_err(&urb->dev->dev, "%s: device not running\n", __func__); in write_bulk_callback()
752 if (!netif_device_present(odev->net)) { in write_bulk_callback()
753 dev_err(&urb->dev->dev, "%s: net device not present\n", in write_bulk_callback()
758 /* log status, but don't act on it, we don't need to resubmit anything in write_bulk_callback()
761 handle_usb_error(status, __func__, odev->parent); in write_bulk_callback()
763 hso_put_activity(odev->parent); in write_bulk_callback()
766 netif_wake_queue(odev->net); in write_bulk_callback()
769 /* called by kernel when we need to transmit a packet */
778 if (hso_get_activity(odev->parent) == -EAGAIN) { in hso_net_start_xmit()
779 odev->skb_tx_buf = skb; in hso_net_start_xmit()
784 DUMP1(skb->data, skb->len); in hso_net_start_xmit()
785 /* Copy it from kernel memory to OUR memory */ in hso_net_start_xmit()
786 memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); in hso_net_start_xmit()
787 hso_dbg(0x1, "len: %d/%d\n", skb->len, MUX_BULK_TX_BUF_SIZE); in hso_net_start_xmit()
790 usb_fill_bulk_urb(odev->mux_bulk_tx_urb, in hso_net_start_xmit()
791 odev->parent->usb, in hso_net_start_xmit()
792 usb_sndbulkpipe(odev->parent->usb, in hso_net_start_xmit()
793 odev->out_endp-> in hso_net_start_xmit()
795 odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, in hso_net_start_xmit()
799 odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; in hso_net_start_xmit()
802 result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); in hso_net_start_xmit()
804 dev_warn(&odev->parent->interface->dev, in hso_net_start_xmit()
806 net->stats.tx_errors++; in hso_net_start_xmit()
809 net->stats.tx_packets++; in hso_net_start_xmit()
810 net->stats.tx_bytes += skb->len; in hso_net_start_xmit()
830 dev_warn(&net->dev, "Tx timed out.\n"); in hso_net_tx_timeout()
833 if (odev->mux_bulk_tx_urb) in hso_net_tx_timeout()
834 usb_unlink_urb(odev->mux_bulk_tx_urb); in hso_net_tx_timeout()
837 net->stats.tx_errors++; in hso_net_tx_timeout()
840 /* make a real packet from the received USB buffer */
853 switch (odev->rx_parse_state) { in packetizeRx()
856 /* wanted bytes - size of ip header */ in packetizeRx()
859 odev->rx_buf_missing) ? count : odev-> in packetizeRx()
862 memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + in packetizeRx()
863 odev->rx_buf_size, ip_pkt + buffer_offset, in packetizeRx()
866 odev->rx_buf_size += temp_bytes; in packetizeRx()
868 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
869 count -= temp_bytes; in packetizeRx()
871 if (!odev->rx_buf_missing) { in packetizeRx()
873 * continue to WAIT_DATA */ in packetizeRx()
874 frame_len = ntohs(odev->rx_ip_hdr.tot_len); in packetizeRx()
878 dev_err(&odev->net->dev, in packetizeRx()
881 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
885 odev->skb_rx_buf = netdev_alloc_skb(odev->net, in packetizeRx()
887 if (!odev->skb_rx_buf) { in packetizeRx()
890 odev->rx_parse_state = WAIT_SYNC; in packetizeRx()
896 skb_put_data(odev->skb_rx_buf, in packetizeRx()
897 (char *)&(odev->rx_ip_hdr), in packetizeRx()
901 odev->rx_buf_size = sizeof(struct iphdr); in packetizeRx()
904 odev->rx_buf_missing = in packetizeRx()
905 frame_len - sizeof(struct iphdr); in packetizeRx()
906 odev->rx_parse_state = WAIT_DATA; in packetizeRx()
911 temp_bytes = (count < odev->rx_buf_missing) in packetizeRx()
912 ? count : odev->rx_buf_missing; in packetizeRx()
917 skb_put_data(odev->skb_rx_buf, in packetizeRx()
921 odev->rx_buf_missing -= temp_bytes; in packetizeRx()
922 count -= temp_bytes; in packetizeRx()
924 odev->rx_buf_size += temp_bytes; in packetizeRx()
925 if (!odev->rx_buf_missing) { in packetizeRx()
928 odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); in packetizeRx()
929 skb_reset_mac_header(odev->skb_rx_buf); in packetizeRx()
931 /* Ship it off to the kernel */ in packetizeRx()
932 netif_rx(odev->skb_rx_buf); in packetizeRx()
934 odev->skb_rx_buf = NULL; in packetizeRx()
937 odev->net->stats.rx_packets++; in packetizeRx()
939 odev->net->stats.rx_bytes += odev->rx_buf_size; in packetizeRx()
941 odev->rx_buf_size = 0; in packetizeRx()
942 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
943 odev->rx_parse_state = WAIT_IP; in packetizeRx()
953 count--; in packetizeRx()
960 if (odev->rx_parse_state == WAIT_SYNC) { in packetizeRx()
961 odev->rx_parse_state = WAIT_IP; in packetizeRx()
962 odev->rx_buf_size = 0; in packetizeRx()
963 odev->rx_buf_missing = sizeof(struct iphdr); in packetizeRx()
971 u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); in fix_crc_bug()
974 !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, in fix_crc_bug()
976 urb->actual_length -= 4; in fix_crc_bug()
980 /* Moving data from usb to kernel (in interrupt state) */
983 struct hso_net *odev = urb->context; in read_bulk_callback()
987 int status = urb->status; in read_bulk_callback()
991 handle_usb_error(status, __func__, odev->parent); in read_bulk_callback()
996 if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { in read_bulk_callback()
1000 usb_mark_last_busy(urb->dev); in read_bulk_callback()
1002 net = odev->net; in read_bulk_callback()
1009 if (odev->parent->port_spec & HSO_INFO_CRC_BUG) in read_bulk_callback()
1010 fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); in read_bulk_callback()
1013 if (urb->actual_length) { in read_bulk_callback()
1016 spin_lock_irqsave(&odev->net_lock, flags); in read_bulk_callback()
1017 packetizeRx(odev, urb->transfer_buffer, urb->actual_length, in read_bulk_callback()
1018 (urb->transfer_buffer_length > in read_bulk_callback()
1019 urb->actual_length) ? 1 : 0); in read_bulk_callback()
1020 spin_unlock_irqrestore(&odev->net_lock, flags); in read_bulk_callback()
1023 /* We are done with this URB, resubmit it. Prep the USB to wait for in read_bulk_callback()
1026 odev->parent->usb, in read_bulk_callback()
1027 usb_rcvbulkpipe(odev->parent->usb, in read_bulk_callback()
1028 odev->in_endp-> in read_bulk_callback()
1030 urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, in read_bulk_callback()
1033 /* Give this to the USB subsystem so it can tell us when more data in read_bulk_callback()
1037 dev_warn(&odev->parent->interface->dev, in read_bulk_callback()
1042 /* Serial driver functions */
1049 termios->c_iflag &= in hso_init_termios()
1054 | INLCR /* disable translate NL to CR */ in hso_init_termios()
1056 | ICRNL /* disable translate CR to NL */ in hso_init_termios()
1060 termios->c_oflag &= ~OPOST; in hso_init_termios()
1062 termios->c_lflag &= in hso_init_termios()
1069 | IEXTEN); /* disable non-POSIX special characters */ in hso_init_termios()
1071 termios->c_cflag &= in hso_init_termios()
1077 termios->c_cflag |= CS8; /* character size 8 bits */ in hso_init_termios()
1086 struct hso_serial *serial = tty->driver_data; in _hso_serial_set_termios() local
1088 if (!serial) { in _hso_serial_set_termios()
1093 hso_dbg(0x8, "port %d\n", serial->minor); in _hso_serial_set_termios()
1098 tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ in _hso_serial_set_termios()
1100 tty->termios.c_cflag &= in _hso_serial_set_termios()
1106 tty->termios.c_cflag |= CS8; /* character size 8 bits */ in _hso_serial_set_termios()
1112 static void hso_resubmit_rx_bulk_urb(struct hso_serial *serial, struct urb *urb) in hso_resubmit_rx_bulk_urb() argument
1115 /* We are done with this URB, resubmit it. Prep the USB to wait for in hso_resubmit_rx_bulk_urb()
1117 usb_fill_bulk_urb(urb, serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1118 usb_rcvbulkpipe(serial->parent->usb, in hso_resubmit_rx_bulk_urb()
1119 serial->in_endp-> in hso_resubmit_rx_bulk_urb()
1121 urb->transfer_buffer, serial->rx_data_length, in hso_resubmit_rx_bulk_urb()
1122 hso_std_serial_read_bulk_callback, serial); in hso_resubmit_rx_bulk_urb()
1123 /* Give this to the USB subsystem so it can tell us when more data in hso_resubmit_rx_bulk_urb()
1127 dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", in hso_resubmit_rx_bulk_urb()
1135 static void put_rxbuf_data_and_resubmit_bulk_urb(struct hso_serial *serial) in put_rxbuf_data_and_resubmit_bulk_urb() argument
1140 while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { in put_rxbuf_data_and_resubmit_bulk_urb()
1141 curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; in put_rxbuf_data_and_resubmit_bulk_urb()
1142 count = put_rxbuf_data(curr_urb, serial); in put_rxbuf_data_and_resubmit_bulk_urb()
1143 if (count == -1) in put_rxbuf_data_and_resubmit_bulk_urb()
1146 serial->curr_rx_urb_idx++; in put_rxbuf_data_and_resubmit_bulk_urb()
1147 if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) in put_rxbuf_data_and_resubmit_bulk_urb()
1148 serial->curr_rx_urb_idx = 0; in put_rxbuf_data_and_resubmit_bulk_urb()
1149 hso_resubmit_rx_bulk_urb(serial, curr_urb); in put_rxbuf_data_and_resubmit_bulk_urb()
1154 static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial) in put_rxbuf_data_and_resubmit_ctrl_urb() argument
1159 urb = serial->rx_urb[0]; in put_rxbuf_data_and_resubmit_ctrl_urb()
1160 if (serial->port.count > 0) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1161 count = put_rxbuf_data(urb, serial); in put_rxbuf_data_and_resubmit_ctrl_urb()
1162 if (count == -1) in put_rxbuf_data_and_resubmit_ctrl_urb()
1167 if (count == 0 && ((urb->actual_length != 0) || in put_rxbuf_data_and_resubmit_ctrl_urb()
1168 (serial->rx_state == RX_PENDING))) { in put_rxbuf_data_and_resubmit_ctrl_urb()
1169 serial->rx_state = RX_SENT; in put_rxbuf_data_and_resubmit_ctrl_urb()
1170 hso_mux_serial_read(serial); in put_rxbuf_data_and_resubmit_ctrl_urb()
1172 serial->rx_state = RX_IDLE; in put_rxbuf_data_and_resubmit_ctrl_urb()
1179 struct hso_serial *serial = urb->context; in hso_std_serial_read_bulk_callback() local
1180 int status = urb->status; in hso_std_serial_read_bulk_callback()
1183 hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status); in hso_std_serial_read_bulk_callback()
1186 if (!serial) { in hso_std_serial_read_bulk_callback()
1187 hso_dbg(0x1, "serial == NULL\n"); in hso_std_serial_read_bulk_callback()
1191 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_read_bulk_callback()
1195 hso_dbg(0x1, "Actual length = %d\n", urb->actual_length); in hso_std_serial_read_bulk_callback()
1196 DUMP1(urb->transfer_buffer, urb->actual_length); in hso_std_serial_read_bulk_callback()
1199 if (serial->port.count == 0) in hso_std_serial_read_bulk_callback()
1202 if (serial->parent->port_spec & HSO_INFO_CRC_BUG) in hso_std_serial_read_bulk_callback()
1203 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); in hso_std_serial_read_bulk_callback()
1205 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1206 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; in hso_std_serial_read_bulk_callback()
1207 put_rxbuf_data_and_resubmit_bulk_urb(serial); in hso_std_serial_read_bulk_callback()
1208 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_read_bulk_callback()
1212 * This needs to be a tasklet otherwise we will
1217 struct hso_serial *serial = (struct hso_serial *)data; in hso_unthrottle_tasklet() local
1220 spin_lock_irqsave(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1221 if ((serial->parent->port_spec & HSO_INTF_MUX)) in hso_unthrottle_tasklet()
1222 put_rxbuf_data_and_resubmit_ctrl_urb(serial); in hso_unthrottle_tasklet()
1224 put_rxbuf_data_and_resubmit_bulk_urb(serial); in hso_unthrottle_tasklet()
1225 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_unthrottle_tasklet()
1230 struct hso_serial *serial = tty->driver_data; in hso_unthrottle() local
1232 tasklet_hi_schedule(&serial->unthrottle_tasklet); in hso_unthrottle()
1235 /* open the requested serial port */
1238 struct hso_serial *serial = get_serial_by_index(tty->index); in hso_serial_open() local
1242 if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { in hso_serial_open()
1244 tty->driver_data = NULL; in hso_serial_open()
1245 hso_dbg(0x1, "Failed to open port\n"); in hso_serial_open()
1246 return -ENODEV; in hso_serial_open()
1249 mutex_lock(&serial->parent->mutex); in hso_serial_open()
1250 result = usb_autopm_get_interface(serial->parent->interface); in hso_serial_open()
1254 hso_dbg(0x1, "Opening %d\n", serial->minor); in hso_serial_open()
1257 tty->driver_data = serial; in hso_serial_open()
1258 tty_port_tty_set(&serial->port, tty); in hso_serial_open()
1261 serial->port.count++; in hso_serial_open()
1262 if (serial->port.count == 1) { in hso_serial_open()
1263 serial->rx_state = RX_IDLE; in hso_serial_open()
1266 tasklet_init(&serial->unthrottle_tasklet, in hso_serial_open()
1268 (unsigned long)serial); in hso_serial_open()
1269 result = hso_start_serial_device(serial->parent, GFP_KERNEL); in hso_serial_open()
1271 hso_stop_serial_device(serial->parent); in hso_serial_open()
1272 serial->port.count--; in hso_serial_open()
1274 kref_get(&serial->parent->ref); in hso_serial_open()
1280 usb_autopm_put_interface(serial->parent->interface); in hso_serial_open()
1286 mutex_unlock(&serial->parent->mutex); in hso_serial_open()
1290 /* close the requested serial port */
1293 struct hso_serial *serial = tty->driver_data; in hso_serial_close() local
1296 hso_dbg(0x1, "Closing serial port\n"); in hso_serial_close()
1299 if (serial == NULL) in hso_serial_close()
1302 mutex_lock(&serial->parent->mutex); in hso_serial_close()
1303 usb_gone = serial->parent->usb_gone; in hso_serial_close()
1306 usb_autopm_get_interface(serial->parent->interface); in hso_serial_close()
1310 serial->port.count--; in hso_serial_close()
1312 if (serial->port.count <= 0) { in hso_serial_close()
1313 serial->port.count = 0; in hso_serial_close()
1314 tty_port_tty_set(&serial->port, NULL); in hso_serial_close()
1316 hso_stop_serial_device(serial->parent); in hso_serial_close()
1317 tasklet_kill(&serial->unthrottle_tasklet); in hso_serial_close()
1321 usb_autopm_put_interface(serial->parent->interface); in hso_serial_close()
1323 mutex_unlock(&serial->parent->mutex); in hso_serial_close()
1326 /* close the requested serial port */
1330 struct hso_serial *serial = tty->driver_data; in hso_serial_write() local
1335 if (serial == NULL) { in hso_serial_write()
1336 pr_err("%s: serial is NULL\n", __func__); in hso_serial_write()
1337 return -ENODEV; in hso_serial_write()
1340 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write()
1342 space = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write()
1348 memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); in hso_serial_write()
1349 serial->tx_buffer_count += tx_bytes; in hso_serial_write()
1352 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write()
1354 hso_kick_transmit(serial); in hso_serial_write()
1362 struct hso_serial *serial = tty->driver_data; in hso_serial_write_room() local
1366 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_write_room()
1367 room = serial->tx_data_length - serial->tx_buffer_count; in hso_serial_write_room()
1368 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_write_room()
1376 struct hso_serial *serial = tty->driver_data; in hso_serial_cleanup() local
1378 if (!serial) in hso_serial_cleanup()
1381 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_serial_cleanup()
1387 struct hso_serial *serial = tty->driver_data; in hso_serial_set_termios() local
1391 hso_dbg(0x16, "Termios called with: cflags new[%u] - old[%u]\n", in hso_serial_set_termios()
1392 (unsigned int)tty->termios.c_cflag, in hso_serial_set_termios()
1393 (unsigned int)old->c_cflag); in hso_serial_set_termios()
1396 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_set_termios()
1397 if (serial->port.count) in hso_serial_set_termios()
1400 tty->termios = *old; in hso_serial_set_termios()
1401 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_set_termios()
1409 struct hso_serial *serial = tty->driver_data; in hso_serial_chars_in_buffer() local
1414 if (serial == NULL) in hso_serial_chars_in_buffer()
1417 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1418 chars = serial->tx_buffer_count; in hso_serial_chars_in_buffer()
1419 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_chars_in_buffer()
1423 static int tiocmget_submit_urb(struct hso_serial *serial, in tiocmget_submit_urb() argument
1425 struct usb_device *usb) in tiocmget_submit_urb() argument
1429 if (serial->parent->usb_gone) in tiocmget_submit_urb()
1430 return -ENODEV; in tiocmget_submit_urb()
1431 usb_fill_int_urb(tiocmget->urb, usb, in tiocmget_submit_urb()
1432 usb_rcvintpipe(usb, in tiocmget_submit_urb()
1433 tiocmget->endp-> in tiocmget_submit_urb()
1435 tiocmget->serial_state_notification, in tiocmget_submit_urb()
1437 tiocmget_intr_callback, serial, in tiocmget_submit_urb()
1438 tiocmget->endp->bInterval); in tiocmget_submit_urb()
1439 result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); in tiocmget_submit_urb()
1441 dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, in tiocmget_submit_urb()
1450 struct hso_serial *serial = urb->context; in tiocmget_intr_callback() local
1452 int status = urb->status; in tiocmget_intr_callback()
1456 struct usb_device *usb; in tiocmget_intr_callback() local
1461 if (!serial) in tiocmget_intr_callback()
1464 handle_usb_error(status, __func__, serial->parent); in tiocmget_intr_callback()
1469 tiocmget = serial->tiocmget; in tiocmget_intr_callback()
1472 BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); in tiocmget_intr_callback()
1474 usb = serial->parent->usb; in tiocmget_intr_callback()
1475 interface = serial->parent->interface; in tiocmget_intr_callback()
1477 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in tiocmget_intr_callback()
1479 /* wIndex should be the USB interface number of the port to which the in tiocmget_intr_callback()
1482 serial_state_notification = tiocmget->serial_state_notification; in tiocmget_intr_callback()
1483 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || in tiocmget_intr_callback()
1484 serial_state_notification->bNotification != B_NOTIFICATION || in tiocmget_intr_callback()
1485 le16_to_cpu(serial_state_notification->wValue) != W_VALUE || in tiocmget_intr_callback()
1486 le16_to_cpu(serial_state_notification->wIndex) != if_num || in tiocmget_intr_callback()
1487 le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { in tiocmget_intr_callback()
1488 dev_warn(&usb->dev, in tiocmget_intr_callback()
1489 "hso received invalid serial state notification\n"); in tiocmget_intr_callback()
1495 UART_state_bitmap = le16_to_cpu(serial_state_notification-> in tiocmget_intr_callback()
1497 prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; in tiocmget_intr_callback()
1498 icount = &tiocmget->icount; in tiocmget_intr_callback()
1499 spin_lock_irqsave(&serial->serial_lock, flags); in tiocmget_intr_callback()
1502 icount->parity++; in tiocmget_intr_callback()
1505 icount->parity++; in tiocmget_intr_callback()
1508 icount->frame++; in tiocmget_intr_callback()
1511 icount->rng++; in tiocmget_intr_callback()
1514 icount->brk++; in tiocmget_intr_callback()
1517 icount->dsr++; in tiocmget_intr_callback()
1520 icount->dcd++; in tiocmget_intr_callback()
1521 tiocmget->prev_UART_state_bitmap = UART_state_bitmap; in tiocmget_intr_callback()
1522 spin_unlock_irqrestore(&serial->serial_lock, flags); in tiocmget_intr_callback()
1523 tiocmget->intr_completed = 1; in tiocmget_intr_callback()
1524 wake_up_interruptible(&tiocmget->waitq); in tiocmget_intr_callback()
1528 tiocmget_submit_urb(serial, in tiocmget_intr_callback()
1530 serial->parent->usb); in tiocmget_intr_callback()
1534 * next few functions largely stolen from drivers/serial/serial_core.c
1536 /* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1537 * - mask passed in arg for lines of interest
1539 * Caller should use TIOCGICOUNT to see which one it was
1542 hso_wait_modem_status(struct hso_serial *serial, unsigned long arg) in hso_wait_modem_status() argument
1549 tiocmget = serial->tiocmget; in hso_wait_modem_status()
1551 return -ENOENT; in hso_wait_modem_status()
1555 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1556 memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1557 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1558 add_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1560 spin_lock_irq(&serial->serial_lock); in hso_wait_modem_status()
1561 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_wait_modem_status()
1562 spin_unlock_irq(&serial->serial_lock); in hso_wait_modem_status()
1573 ret = -ERESTARTSYS; in hso_wait_modem_status()
1579 remove_wait_queue(&tiocmget->waitq, &wait); in hso_wait_modem_status()
1585 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1586 * Return: write counters to the user passed counter struct
1587 * NB: both 1->0 and 0->1 transitions are counted except for
1588 * RI where only 0->1 is counted.
1594 struct hso_serial *serial = tty->driver_data; in hso_get_count() local
1595 struct hso_tiocmget *tiocmget = serial->tiocmget; in hso_get_count()
1600 return -ENOENT; in hso_get_count()
1601 spin_lock_irq(&serial->serial_lock); in hso_get_count()
1602 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); in hso_get_count()
1603 spin_unlock_irq(&serial->serial_lock); in hso_get_count()
1605 icount->cts = cnow.cts; in hso_get_count()
1606 icount->dsr = cnow.dsr; in hso_get_count()
1607 icount->rng = cnow.rng; in hso_get_count()
1608 icount->dcd = cnow.dcd; in hso_get_count()
1609 icount->rx = cnow.rx; in hso_get_count()
1610 icount->tx = cnow.tx; in hso_get_count()
1611 icount->frame = cnow.frame; in hso_get_count()
1612 icount->overrun = cnow.overrun; in hso_get_count()
1613 icount->parity = cnow.parity; in hso_get_count()
1614 icount->brk = cnow.brk; in hso_get_count()
1615 icount->buf_overrun = cnow.buf_overrun; in hso_get_count()
1624 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmget() local
1629 if (!serial) { in hso_serial_tiocmget()
1631 return -EINVAL; in hso_serial_tiocmget()
1633 spin_lock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1634 retval = ((serial->rts_state) ? TIOCM_RTS : 0) | in hso_serial_tiocmget()
1635 ((serial->dtr_state) ? TIOCM_DTR : 0); in hso_serial_tiocmget()
1636 tiocmget = serial->tiocmget; in hso_serial_tiocmget()
1640 tiocmget->prev_UART_state_bitmap); in hso_serial_tiocmget()
1648 spin_unlock_irq(&serial->serial_lock); in hso_serial_tiocmget()
1658 struct hso_serial *serial = tty->driver_data; in hso_serial_tiocmset() local
1662 if (!serial) { in hso_serial_tiocmset()
1664 return -EINVAL; in hso_serial_tiocmset()
1667 if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) in hso_serial_tiocmset()
1668 return -EINVAL; in hso_serial_tiocmset()
1670 interface = serial->parent->interface; in hso_serial_tiocmset()
1671 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_serial_tiocmset()
1673 spin_lock_irqsave(&serial->serial_lock, flags); in hso_serial_tiocmset()
1675 serial->rts_state = 1; in hso_serial_tiocmset()
1677 serial->dtr_state = 1; in hso_serial_tiocmset()
1680 serial->rts_state = 0; in hso_serial_tiocmset()
1682 serial->dtr_state = 0; in hso_serial_tiocmset()
1684 if (serial->dtr_state) in hso_serial_tiocmset()
1686 if (serial->rts_state) in hso_serial_tiocmset()
1689 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_serial_tiocmset()
1691 return usb_control_msg(serial->parent->usb, in hso_serial_tiocmset()
1692 usb_sndctrlpipe(serial->parent->usb, 0), 0x22, in hso_serial_tiocmset()
1700 struct hso_serial *serial = tty->driver_data; in hso_serial_ioctl() local
1704 if (!serial) in hso_serial_ioctl()
1705 return -ENODEV; in hso_serial_ioctl()
1708 ret = hso_wait_modem_status(serial, arg); in hso_serial_ioctl()
1711 ret = -ENOIOCTLCMD; in hso_serial_ioctl()
1719 static void hso_kick_transmit(struct hso_serial *serial) in hso_kick_transmit() argument
1724 spin_lock_irqsave(&serial->serial_lock, flags); in hso_kick_transmit()
1725 if (!serial->tx_buffer_count) in hso_kick_transmit()
1728 if (serial->tx_urb_used) in hso_kick_transmit()
1731 /* Wakeup USB interface if necessary */ in hso_kick_transmit()
1732 if (hso_get_activity(serial->parent) == -EAGAIN) in hso_kick_transmit()
1735 /* Switch pointers around to avoid memcpy */ in hso_kick_transmit()
1736 swap(serial->tx_buffer, serial->tx_data); in hso_kick_transmit()
1737 serial->tx_data_count = serial->tx_buffer_count; in hso_kick_transmit()
1738 serial->tx_buffer_count = 0; in hso_kick_transmit()
1740 /* If serial->tx_data is set, it means we switched buffers */ in hso_kick_transmit()
1741 if (serial->tx_data && serial->write_data) { in hso_kick_transmit()
1742 res = serial->write_data(serial); in hso_kick_transmit()
1744 serial->tx_urb_used = 1; in hso_kick_transmit()
1747 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_kick_transmit()
1750 /* make a request (for reading and writing data to muxed serial port) */
1751 static int mux_device_request(struct hso_serial *serial, u8 type, u16 port, in mux_device_request() argument
1760 if (!serial || !ctrl_urb || !ctrl_req) { in mux_device_request()
1762 return -EINVAL; in mux_device_request()
1766 ctrl_req->wValue = 0; in mux_device_request()
1767 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); in mux_device_request()
1768 ctrl_req->wLength = cpu_to_le16(size); in mux_device_request()
1772 ctrl_req->bRequestType = USB_DIR_IN | in mux_device_request()
1775 ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; in mux_device_request()
1776 pipe = usb_rcvctrlpipe(serial->parent->usb, 0); in mux_device_request()
1779 ctrl_req->bRequestType = USB_DIR_OUT | in mux_device_request()
1782 ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; in mux_device_request()
1783 pipe = usb_sndctrlpipe(serial->parent->usb, 0); in mux_device_request()
1788 ctrl_req->bRequestType, ctrl_req->wLength, port); in mux_device_request()
1791 ctrl_urb->transfer_flags = 0; in mux_device_request()
1793 serial->parent->usb, in mux_device_request()
1796 ctrl_urb_data, size, ctrl_callback, serial); in mux_device_request()
1800 dev_err(&ctrl_urb->dev->dev, in mux_device_request()
1811 static int hso_mux_serial_read(struct hso_serial *serial) in hso_mux_serial_read() argument
1813 if (!serial) in hso_mux_serial_read()
1814 return -EINVAL; in hso_mux_serial_read()
1817 memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); in hso_mux_serial_read()
1820 if (serial->num_rx_urbs != 1) { in hso_mux_serial_read()
1821 dev_err(&serial->parent->interface->dev, in hso_mux_serial_read()
1826 return mux_device_request(serial, in hso_mux_serial_read()
1828 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_read()
1829 serial->rx_urb[0], in hso_mux_serial_read()
1830 &serial->ctrl_req_rx, in hso_mux_serial_read()
1831 serial->rx_data[0], serial->rx_data_length); in hso_mux_serial_read()
1834 /* used for muxed serial port callback (muxed serial read) */
1837 struct hso_shared_int *shared_int = urb->context; in intr_callback()
1838 struct hso_serial *serial; in intr_callback() local
1840 int status = urb->status; in intr_callback()
1844 usb_mark_last_busy(urb->dev); in intr_callback()
1855 hso_dbg(0x8, "--- Got intr callback 0x%02X ---\n", status); in intr_callback()
1858 port_req = urb->transfer_buffer; in intr_callback()
1860 /* loop over all muxed ports to find the one sending this */ in intr_callback()
1864 serial = get_serial_by_shared_int_and_type(shared_int, in intr_callback()
1866 if (serial != NULL) { in intr_callback()
1869 spin_lock_irqsave(&serial->serial_lock, flags); in intr_callback()
1870 if (serial->rx_state == RX_IDLE && in intr_callback()
1871 serial->port.count > 0) { in intr_callback()
1874 if (!serial->rx_urb_filled[0]) { in intr_callback()
1875 serial->rx_state = RX_SENT; in intr_callback()
1876 hso_mux_serial_read(serial); in intr_callback()
1878 serial->rx_state = RX_PENDING; in intr_callback()
1883 spin_unlock_irqrestore(&serial->serial_lock, in intr_callback()
1889 hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); in intr_callback()
1892 /* called for writing to muxed serial port */
1893 static int hso_mux_serial_write_data(struct hso_serial *serial) in hso_mux_serial_write_data() argument
1895 if (NULL == serial) in hso_mux_serial_write_data()
1896 return -EINVAL; in hso_mux_serial_write_data()
1898 return mux_device_request(serial, in hso_mux_serial_write_data()
1900 serial->parent->port_spec & HSO_PORT_MASK, in hso_mux_serial_write_data()
1901 serial->tx_urb, in hso_mux_serial_write_data()
1902 &serial->ctrl_req_tx, in hso_mux_serial_write_data()
1903 serial->tx_data, serial->tx_data_count); in hso_mux_serial_write_data()
1909 struct hso_serial *serial = urb->context; in hso_std_serial_write_bulk_callback() local
1910 int status = urb->status; in hso_std_serial_write_bulk_callback()
1914 if (!serial) { in hso_std_serial_write_bulk_callback()
1915 hso_dbg(0x1, "serial == NULL\n"); in hso_std_serial_write_bulk_callback()
1919 spin_lock_irqsave(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1920 serial->tx_urb_used = 0; in hso_std_serial_write_bulk_callback()
1921 spin_unlock_irqrestore(&serial->serial_lock, flags); in hso_std_serial_write_bulk_callback()
1923 handle_usb_error(status, __func__, serial->parent); in hso_std_serial_write_bulk_callback()
1926 hso_put_activity(serial->parent); in hso_std_serial_write_bulk_callback()
1927 tty_port_tty_wakeup(&serial->port); in hso_std_serial_write_bulk_callback()
1928 hso_kick_transmit(serial); in hso_std_serial_write_bulk_callback()
1933 /* called for writing diag or CS serial port */
1934 static int hso_std_serial_write_data(struct hso_serial *serial) in hso_std_serial_write_data() argument
1936 int count = serial->tx_data_count; in hso_std_serial_write_data()
1939 usb_fill_bulk_urb(serial->tx_urb, in hso_std_serial_write_data()
1940 serial->parent->usb, in hso_std_serial_write_data()
1941 usb_sndbulkpipe(serial->parent->usb, in hso_std_serial_write_data()
1942 serial->out_endp-> in hso_std_serial_write_data()
1944 serial->tx_data, serial->tx_data_count, in hso_std_serial_write_data()
1945 hso_std_serial_write_bulk_callback, serial); in hso_std_serial_write_data()
1947 result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); in hso_std_serial_write_data()
1949 dev_warn(&serial->parent->usb->dev, in hso_std_serial_write_data()
1950 "Failed to submit urb - res %d\n", result); in hso_std_serial_write_data()
1957 /* callback after read or write on muxed serial port */
1960 struct hso_serial *serial = urb->context; in ctrl_callback() local
1962 int status = urb->status; in ctrl_callback()
1966 if (!serial) in ctrl_callback()
1969 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1970 serial->tx_urb_used = 0; in ctrl_callback()
1971 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1973 handle_usb_error(status, __func__, serial->parent); in ctrl_callback()
1978 req = (struct usb_ctrlrequest *)(urb->setup_packet); in ctrl_callback()
1979 hso_dbg(0x8, "--- Got muxed ctrl callback 0x%02X ---\n", status); in ctrl_callback()
1980 hso_dbg(0x8, "Actual length of urb = %d\n", urb->actual_length); in ctrl_callback()
1981 DUMP1(urb->transfer_buffer, urb->actual_length); in ctrl_callback()
1983 if (req->bRequestType == in ctrl_callback()
1985 /* response to a read command */ in ctrl_callback()
1986 serial->rx_urb_filled[0] = 1; in ctrl_callback()
1987 spin_lock_irqsave(&serial->serial_lock, flags); in ctrl_callback()
1988 put_rxbuf_data_and_resubmit_ctrl_urb(serial); in ctrl_callback()
1989 spin_unlock_irqrestore(&serial->serial_lock, flags); in ctrl_callback()
1991 hso_put_activity(serial->parent); in ctrl_callback()
1992 tty_port_tty_wakeup(&serial->port); in ctrl_callback()
1993 /* response to a write command */ in ctrl_callback()
1994 hso_kick_transmit(serial); in ctrl_callback()
1998 /* handle RX data for serial port */
1999 static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) in put_rxbuf_data() argument
2005 if (urb == NULL || serial == NULL) { in put_rxbuf_data()
2006 hso_dbg(0x1, "serial = NULL\n"); in put_rxbuf_data()
2007 return -2; in put_rxbuf_data()
2010 tty = tty_port_tty_get(&serial->port); in put_rxbuf_data()
2014 return -1; in put_rxbuf_data()
2017 /* Push data to tty */ in put_rxbuf_data()
2018 hso_dbg(0x1, "data to push to tty\n"); in put_rxbuf_data()
2019 count = tty_buffer_request_room(&serial->port, urb->actual_length); in put_rxbuf_data()
2020 if (count >= urb->actual_length) { in put_rxbuf_data()
2021 tty_insert_flip_string(&serial->port, urb->transfer_buffer, in put_rxbuf_data()
2022 urb->actual_length); in put_rxbuf_data()
2023 tty_flip_buffer_push(&serial->port); in put_rxbuf_data()
2025 dev_warn(&serial->parent->usb->dev, in put_rxbuf_data()
2026 "dropping data, %d bytes lost\n", urb->actual_length); in put_rxbuf_data()
2031 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; in put_rxbuf_data()
2044 switch (hso_dev->port_spec & HSO_PORT_MASK) { in hso_log_port()
2079 if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { in hso_log_port()
2080 sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); in hso_log_port()
2083 dev2ser(hso_dev)->minor); in hso_log_port()
2085 dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", in hso_log_port()
2095 return -ENODEV; in hso_start_net_device()
2101 usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2102 hso_dev->usb, in hso_start_net_device()
2103 usb_rcvbulkpipe(hso_dev->usb, in hso_start_net_device()
2104 hso_net->in_endp-> in hso_start_net_device()
2106 hso_net->mux_bulk_rx_buf_pool[i], in hso_start_net_device()
2111 result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], in hso_start_net_device()
2114 dev_warn(&hso_dev->usb->dev, in hso_start_net_device()
2128 return -ENODEV; in hso_stop_net_device()
2131 if (hso_net->mux_bulk_rx_urb_pool[i]) in hso_stop_net_device()
2132 usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_stop_net_device()
2135 if (hso_net->mux_bulk_tx_urb) in hso_stop_net_device()
2136 usb_kill_urb(hso_net->mux_bulk_tx_urb); in hso_stop_net_device()
2144 struct hso_serial *serial = dev2ser(hso_dev); in hso_start_serial_device() local
2146 if (!serial) in hso_start_serial_device()
2147 return -ENODEV; in hso_start_serial_device()
2151 if (!(serial->parent->port_spec & HSO_INTF_MUX)) { in hso_start_serial_device()
2152 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_start_serial_device()
2153 usb_fill_bulk_urb(serial->rx_urb[i], in hso_start_serial_device()
2154 serial->parent->usb, in hso_start_serial_device()
2155 usb_rcvbulkpipe(serial->parent->usb, in hso_start_serial_device()
2156 serial->in_endp-> in hso_start_serial_device()
2159 serial->rx_data[i], in hso_start_serial_device()
2160 serial->rx_data_length, in hso_start_serial_device()
2162 serial); in hso_start_serial_device()
2163 result = usb_submit_urb(serial->rx_urb[i], flags); in hso_start_serial_device()
2165 dev_warn(&serial->parent->usb->dev, in hso_start_serial_device()
2166 "Failed to submit urb - res %d\n", in hso_start_serial_device()
2172 mutex_lock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2173 if (!serial->shared_int->use_count) { in hso_start_serial_device()
2175 hso_mux_submit_intr_urb(serial->shared_int, in hso_start_serial_device()
2176 hso_dev->usb, flags); in hso_start_serial_device()
2178 serial->shared_int->use_count++; in hso_start_serial_device()
2179 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_start_serial_device()
2181 if (serial->tiocmget) in hso_start_serial_device()
2182 tiocmget_submit_urb(serial, in hso_start_serial_device()
2183 serial->tiocmget, in hso_start_serial_device()
2184 serial->parent->usb); in hso_start_serial_device()
2191 struct hso_serial *serial = dev2ser(hso_dev); in hso_stop_serial_device() local
2194 if (!serial) in hso_stop_serial_device()
2195 return -ENODEV; in hso_stop_serial_device()
2197 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_stop_serial_device()
2198 if (serial->rx_urb[i]) { in hso_stop_serial_device()
2199 usb_kill_urb(serial->rx_urb[i]); in hso_stop_serial_device()
2200 serial->rx_urb_filled[i] = 0; in hso_stop_serial_device()
2203 serial->curr_rx_urb_idx = 0; in hso_stop_serial_device()
2205 if (serial->tx_urb) in hso_stop_serial_device()
2206 usb_kill_urb(serial->tx_urb); in hso_stop_serial_device()
2208 if (serial->shared_int) { in hso_stop_serial_device()
2209 mutex_lock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2210 if (serial->shared_int->use_count && in hso_stop_serial_device()
2211 (--serial->shared_int->use_count == 0)) { in hso_stop_serial_device()
2214 urb = serial->shared_int->shared_intr_urb; in hso_stop_serial_device()
2218 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_stop_serial_device()
2220 tiocmget = serial->tiocmget; in hso_stop_serial_device()
2222 wake_up_interruptible(&tiocmget->waitq); in hso_stop_serial_device()
2223 usb_kill_urb(tiocmget->urb); in hso_stop_serial_device()
2229 static void hso_serial_tty_unregister(struct hso_serial *serial) in hso_serial_tty_unregister() argument
2231 tty_unregister_device(tty_drv, serial->minor); in hso_serial_tty_unregister()
2232 release_minor(serial); in hso_serial_tty_unregister()
2235 static void hso_serial_common_free(struct hso_serial *serial) in hso_serial_common_free() argument
2239 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_free()
2241 usb_free_urb(serial->rx_urb[i]); in hso_serial_common_free()
2243 kfree(serial->rx_data[i]); in hso_serial_common_free()
2247 usb_free_urb(serial->tx_urb); in hso_serial_common_free()
2248 kfree(serial->tx_buffer); in hso_serial_common_free()
2249 kfree(serial->tx_data); in hso_serial_common_free()
2250 tty_port_destroy(&serial->port); in hso_serial_common_free()
2253 static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, in hso_serial_common_create() argument
2258 tty_port_init(&serial->port); in hso_serial_common_create()
2260 if (obtain_minor(serial)) in hso_serial_common_create()
2264 serial->parent->dev = tty_port_register_device_attr(&serial->port, in hso_serial_common_create()
2265 tty_drv, serial->minor, &serial->parent->interface->dev, in hso_serial_common_create()
2266 serial->parent, hso_serial_dev_groups); in hso_serial_common_create()
2267 if (IS_ERR(serial->parent->dev)) { in hso_serial_common_create()
2268 release_minor(serial); in hso_serial_common_create()
2272 serial->magic = HSO_SERIAL_MAGIC; in hso_serial_common_create()
2273 spin_lock_init(&serial->serial_lock); in hso_serial_common_create()
2274 serial->num_rx_urbs = num_urbs; in hso_serial_common_create()
2279 serial->rx_data_length = rx_size; in hso_serial_common_create()
2280 for (i = 0; i < serial->num_rx_urbs; i++) { in hso_serial_common_create()
2281 serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2282 if (!serial->rx_urb[i]) in hso_serial_common_create()
2284 serial->rx_urb[i]->transfer_buffer = NULL; in hso_serial_common_create()
2285 serial->rx_urb[i]->transfer_buffer_length = 0; in hso_serial_common_create()
2286 serial->rx_data[i] = kzalloc(serial->rx_data_length, in hso_serial_common_create()
2288 if (!serial->rx_data[i]) in hso_serial_common_create()
2293 serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_serial_common_create()
2294 if (!serial->tx_urb) in hso_serial_common_create()
2296 serial->tx_urb->transfer_buffer = NULL; in hso_serial_common_create()
2297 serial->tx_urb->transfer_buffer_length = 0; in hso_serial_common_create()
2299 serial->tx_data_count = 0; in hso_serial_common_create()
2300 serial->tx_buffer_count = 0; in hso_serial_common_create()
2301 serial->tx_data_length = tx_size; in hso_serial_common_create()
2302 serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2303 if (!serial->tx_data) in hso_serial_common_create()
2306 serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); in hso_serial_common_create()
2307 if (!serial->tx_buffer) in hso_serial_common_create()
2312 hso_serial_tty_unregister(serial); in hso_serial_common_create()
2314 hso_serial_common_free(serial); in hso_serial_common_create()
2315 return -1; in hso_serial_common_create()
2328 hso_dev->port_spec = port_spec; in hso_create_device()
2329 hso_dev->usb = interface_to_usbdev(intf); in hso_create_device()
2330 hso_dev->interface = intf; in hso_create_device()
2331 kref_init(&hso_dev->ref); in hso_create_device()
2332 mutex_init(&hso_dev->mutex); in hso_create_device()
2334 INIT_WORK(&hso_dev->async_get_intf, async_get_intf); in hso_create_device()
2335 INIT_WORK(&hso_dev->async_put_intf, async_put_intf); in hso_create_device()
2352 return -1; in remove_net_device()
2365 remove_net_device(hso_net->parent); in hso_free_net_device()
2367 if (hso_net->net) in hso_free_net_device()
2368 unregister_netdev(hso_net->net); in hso_free_net_device()
2372 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_free_net_device()
2373 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_free_net_device()
2374 hso_net->mux_bulk_rx_buf_pool[i] = NULL; in hso_free_net_device()
2376 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_free_net_device()
2377 kfree(hso_net->mux_bulk_tx_buf); in hso_free_net_device()
2378 hso_net->mux_bulk_tx_buf = NULL; in hso_free_net_device()
2380 if (hso_net->net) in hso_free_net_device()
2381 free_netdev(hso_net->net); in hso_free_net_device()
2401 net->netdev_ops = &hso_netdev_ops; in hso_net_init()
2402 net->watchdog_timeo = HSO_NET_TX_TIMEOUT; in hso_net_init()
2403 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; in hso_net_init()
2404 net->type = ARPHRD_NONE; in hso_net_init()
2405 net->mtu = DEFAULT_MTU - 14; in hso_net_init()
2406 net->tx_queue_len = 10; in hso_net_init()
2407 net->ethtool_ops = &ops; in hso_net_init()
2410 spin_lock_init(&hso_net->net_lock); in hso_net_init()
2425 return -1; in add_net_device()
2435 mutex_lock(&hso_dev->mutex); in hso_rfkill_set_block()
2436 if (hso_dev->usb_gone) in hso_rfkill_set_block()
2439 rv = usb_control_msg(hso_dev->usb, usb_sndctrlpipe(hso_dev->usb, 0), in hso_rfkill_set_block()
2442 mutex_unlock(&hso_dev->mutex); in hso_rfkill_set_block()
2455 struct device *dev = &hso_net->net->dev; in hso_create_rfkill()
2458 snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d", in hso_create_rfkill()
2461 hso_net->rfkill = rfkill_alloc(hso_net->name, in hso_create_rfkill()
2462 &interface_to_usbdev(interface)->dev, in hso_create_rfkill()
2465 if (!hso_net->rfkill) in hso_create_rfkill()
2468 if (rfkill_register(hso_net->rfkill) < 0) { in hso_create_rfkill()
2469 rfkill_destroy(hso_net->rfkill); in hso_create_rfkill()
2470 hso_net->rfkill = NULL; in hso_create_rfkill()
2471 dev_err(dev, "%s - Failed to register rfkill\n", __func__); in hso_create_rfkill()
2494 /* call hso_net_init to do the basic initialization */ in hso_create_net_device()
2498 dev_err(&interface->dev, "Unable to create ethernet device\n"); in hso_create_net_device()
2504 hso_dev->port_data.dev_net = hso_net; in hso_create_net_device()
2505 hso_net->net = net; in hso_create_net_device()
2506 hso_net->parent = hso_dev; in hso_create_net_device()
2508 hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2510 if (!hso_net->in_endp) { in hso_create_net_device()
2511 dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); in hso_create_net_device()
2514 hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_net_device()
2516 if (!hso_net->out_endp) { in hso_create_net_device()
2517 dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); in hso_create_net_device()
2520 SET_NETDEV_DEV(net, &interface->dev); in hso_create_net_device()
2525 hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2526 if (!hso_net->mux_bulk_rx_urb_pool[i]) in hso_create_net_device()
2528 hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, in hso_create_net_device()
2530 if (!hso_net->mux_bulk_rx_buf_pool[i]) in hso_create_net_device()
2533 hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_net_device()
2534 if (!hso_net->mux_bulk_tx_urb) in hso_create_net_device()
2536 hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); in hso_create_net_device()
2537 if (!hso_net->mux_bulk_tx_buf) in hso_create_net_device()
2542 dev_err(&interface->dev, "Failed to add net device\n"); in hso_create_net_device()
2549 dev_err(&interface->dev, "Failed to register device\n"); in hso_create_net_device()
2562 kfree(hso_net->mux_bulk_tx_buf); in hso_create_net_device()
2564 usb_free_urb(hso_net->mux_bulk_tx_urb); in hso_create_net_device()
2567 usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); in hso_create_net_device()
2568 kfree(hso_net->mux_bulk_rx_buf_pool[i]); in hso_create_net_device()
2577 static void hso_free_tiomget(struct hso_serial *serial) in hso_free_tiomget() argument
2580 if (!serial) in hso_free_tiomget()
2582 tiocmget = serial->tiocmget; in hso_free_tiomget()
2584 usb_free_urb(tiocmget->urb); in hso_free_tiomget()
2585 tiocmget->urb = NULL; in hso_free_tiomget()
2586 serial->tiocmget = NULL; in hso_free_tiomget()
2587 kfree(tiocmget->serial_state_notification); in hso_free_tiomget()
2588 tiocmget->serial_state_notification = NULL; in hso_free_tiomget()
2593 /* Frees an AT channel ( goes for both mux and non-mux ) */
2596 struct hso_serial *serial = dev2ser(hso_dev); in hso_free_serial_device() local
2598 if (!serial) in hso_free_serial_device()
2601 hso_serial_common_free(serial); in hso_free_serial_device()
2603 if (serial->shared_int) { in hso_free_serial_device()
2604 mutex_lock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2605 if (--serial->shared_int->ref_count == 0) in hso_free_serial_device()
2606 hso_free_shared_int(serial->shared_int); in hso_free_serial_device()
2608 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_free_serial_device()
2610 hso_free_tiomget(serial); in hso_free_serial_device()
2611 kfree(serial); in hso_free_serial_device()
2620 struct hso_serial *serial; in hso_create_bulk_serial_device() local
2628 serial = kzalloc(sizeof(*serial), GFP_KERNEL); in hso_create_bulk_serial_device()
2629 if (!serial) in hso_create_bulk_serial_device()
2632 serial->parent = hso_dev; in hso_create_bulk_serial_device()
2633 hso_dev->port_data.dev_serial = serial; in hso_create_bulk_serial_device()
2637 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), in hso_create_bulk_serial_device()
2639 if (!serial->tiocmget) in hso_create_bulk_serial_device()
2641 serial->tiocmget->serial_state_notification in hso_create_bulk_serial_device()
2644 if (!serial->tiocmget->serial_state_notification) in hso_create_bulk_serial_device()
2646 tiocmget = serial->tiocmget; in hso_create_bulk_serial_device()
2647 tiocmget->endp = hso_get_ep(interface, in hso_create_bulk_serial_device()
2650 if (!tiocmget->endp) { in hso_create_bulk_serial_device()
2651 dev_err(&interface->dev, "Failed to find INT IN ep\n"); in hso_create_bulk_serial_device()
2655 tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_bulk_serial_device()
2656 if (!tiocmget->urb) in hso_create_bulk_serial_device()
2659 mutex_init(&tiocmget->mutex); in hso_create_bulk_serial_device()
2660 init_waitqueue_head(&tiocmget->waitq); in hso_create_bulk_serial_device()
2665 if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE, in hso_create_bulk_serial_device()
2669 serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, in hso_create_bulk_serial_device()
2671 if (!serial->in_endp) { in hso_create_bulk_serial_device()
2672 dev_err(&interface->dev, "Failed to find BULK IN ep\n"); in hso_create_bulk_serial_device()
2677 (serial->out_endp = in hso_create_bulk_serial_device()
2679 dev_err(&interface->dev, "Failed to find BULK OUT ep\n"); in hso_create_bulk_serial_device()
2683 serial->write_data = hso_std_serial_write_data; in hso_create_bulk_serial_device()
2692 hso_serial_tty_unregister(serial); in hso_create_bulk_serial_device()
2693 hso_serial_common_free(serial); in hso_create_bulk_serial_device()
2695 hso_free_tiomget(serial); in hso_create_bulk_serial_device()
2696 kfree(serial); in hso_create_bulk_serial_device()
2708 struct hso_serial *serial; in hso_create_mux_serial_device() local
2722 serial = kzalloc(sizeof(*serial), GFP_KERNEL); in hso_create_mux_serial_device()
2723 if (!serial) in hso_create_mux_serial_device()
2726 hso_dev->port_data.dev_serial = serial; in hso_create_mux_serial_device()
2727 serial->parent = hso_dev; in hso_create_mux_serial_device()
2730 (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) in hso_create_mux_serial_device()
2733 serial->tx_data_length--; in hso_create_mux_serial_device()
2734 serial->write_data = hso_mux_serial_write_data; in hso_create_mux_serial_device()
2736 serial->shared_int = mux; in hso_create_mux_serial_device()
2737 mutex_lock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2738 serial->shared_int->ref_count++; in hso_create_mux_serial_device()
2739 mutex_unlock(&serial->shared_int->shared_int_lock); in hso_create_mux_serial_device()
2748 kfree(serial); in hso_create_mux_serial_device()
2757 usb_free_urb(mux->shared_intr_urb); in hso_free_shared_int()
2758 kfree(mux->shared_intr_buf); in hso_free_shared_int()
2759 mutex_unlock(&mux->shared_int_lock); in hso_free_shared_int()
2771 mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, in hso_create_shared_int()
2773 if (!mux->intr_endp) { in hso_create_shared_int()
2774 dev_err(&interface->dev, "Can't find INT IN endpoint\n"); in hso_create_shared_int()
2778 mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); in hso_create_shared_int()
2779 if (!mux->shared_intr_urb) in hso_create_shared_int()
2781 mux->shared_intr_buf = in hso_create_shared_int()
2782 kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), in hso_create_shared_int()
2784 if (!mux->shared_intr_buf) in hso_create_shared_int()
2787 mutex_init(&mux->shared_int_lock); in hso_create_shared_int()
2792 kfree(mux->shared_intr_buf); in hso_create_shared_int()
2793 usb_free_urb(mux->shared_intr_urb); in hso_create_shared_int()
2803 u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_get_config_data()
2807 return -ENOMEM; in hso_get_config_data()
2812 return -EIO; in hso_get_config_data()
2818 return -EINVAL; in hso_get_config_data()
2882 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { in hso_probe()
2883 dev_err(&interface->dev, "Not our interface\n"); in hso_probe()
2884 return -ENODEV; in hso_probe()
2887 if_num = interface->cur_altsetting->desc.bInterfaceNumber; in hso_probe()
2891 if (id->driver_info) { in hso_probe()
2895 if (((u32 *)(id->driver_info))[i] == 0) in hso_probe()
2897 port_spec = ((u32 *)(id->driver_info))[if_num]; in hso_probe()
2904 /* Check if we need to switch to alt interfaces prior to port in hso_probe()
2906 if (interface->num_altsetting > 1) in hso_probe()
2908 interface->needs_remote_wakeup = 1; in hso_probe()
2925 /* TODO: de-allocate everything */ in hso_probe()
2969 return -ENODEV; in hso_probe()
2985 usb_autopm_get_interface(hso_dev->interface); in async_get_intf()
2992 usb_autopm_put_interface(hso_dev->interface); in async_put_intf()
2997 if (hso_dev->usb->state == USB_STATE_SUSPENDED) { in hso_get_activity()
2998 if (!hso_dev->is_active) { in hso_get_activity()
2999 hso_dev->is_active = 1; in hso_get_activity()
3000 schedule_work(&hso_dev->async_get_intf); in hso_get_activity()
3004 if (hso_dev->usb->state != USB_STATE_CONFIGURED) in hso_get_activity()
3005 return -EAGAIN; in hso_get_activity()
3007 usb_mark_last_busy(hso_dev->usb); in hso_get_activity()
3014 if (hso_dev->usb->state != USB_STATE_SUSPENDED) { in hso_put_activity()
3015 if (hso_dev->is_active) { in hso_put_activity()
3016 hso_dev->is_active = 0; in hso_put_activity()
3017 schedule_work(&hso_dev->async_put_intf); in hso_put_activity()
3018 return -EAGAIN; in hso_put_activity()
3021 hso_dev->is_active = 0; in hso_put_activity()
3025 /* called by kernel when we need to suspend device */
3030 /* Stop all serial ports */ in hso_suspend()
3032 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_suspend()
3042 (network_table[i]->interface == iface)) { in hso_suspend()
3053 /* called by kernel when we need to resume device */
3059 /* Start all serial ports */ in hso_resume()
3061 if (serial_table[i] && (serial_table[i]->interface == iface)) { in hso_resume()
3062 if (dev2ser(serial_table[i])->port.count) { in hso_resume()
3075 (network_table[i]->interface == iface)) { in hso_resume()
3077 if (hso_net->flags & IFF_UP) { in hso_resume()
3080 if (hso_net->skb_tx_buf) { in hso_resume()
3081 dev_dbg(&iface->dev, in hso_resume()
3084 hso_net_start_xmit(hso_net->skb_tx_buf, in hso_resume()
3085 hso_net->net); in hso_resume()
3086 hso_net->skb_tx_buf = NULL; in hso_resume()
3108 struct hso_serial *serial; in hso_free_interface() local
3113 (serial_table[i]->interface == interface)) { in hso_free_interface()
3114 serial = dev2ser(serial_table[i]); in hso_free_interface()
3115 tty_port_tty_hangup(&serial->port, false); in hso_free_interface()
3116 mutex_lock(&serial->parent->mutex); in hso_free_interface()
3117 serial->parent->usb_gone = 1; in hso_free_interface()
3118 mutex_unlock(&serial->parent->mutex); in hso_free_interface()
3119 cancel_work_sync(&serial_table[i]->async_put_intf); in hso_free_interface()
3120 cancel_work_sync(&serial_table[i]->async_get_intf); in hso_free_interface()
3121 hso_serial_tty_unregister(serial); in hso_free_interface()
3122 kref_put(&serial->parent->ref, hso_serial_ref_free); in hso_free_interface()
3128 (network_table[i]->interface == interface)) { in hso_free_interface()
3129 struct rfkill *rfk = dev2net(network_table[i])->rfkill; in hso_free_interface()
3131 * traffic needs to start it again when suspended */ in hso_free_interface()
3132 netif_stop_queue(dev2net(network_table[i])->net); in hso_free_interface()
3134 cancel_work_sync(&network_table[i]->async_put_intf); in hso_free_interface()
3135 cancel_work_sync(&network_table[i]->async_get_intf); in hso_free_interface()
3152 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_ep()
3155 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_ep()
3156 endp = &iface->endpoint[i].desc; in hso_get_ep()
3157 if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && in hso_get_ep()
3169 struct usb_host_interface *iface = intf->cur_altsetting; in hso_get_mux_ports()
3171 if (iface->extralen == 3) { in hso_get_mux_ports()
3172 *ports = iface->extra[2]; in hso_get_mux_ports()
3176 for (i = 0; i < iface->desc.bNumEndpoints; i++) { in hso_get_mux_ports()
3177 if (iface->endpoint[i].extralen == 3) { in hso_get_mux_ports()
3178 *ports = iface->endpoint[i].extra[2]; in hso_get_mux_ports()
3183 return -1; in hso_get_mux_ports()
3186 /* interrupt urb needs to be submitted, used for serial read of muxed port */
3188 struct usb_device *usb, gfp_t gfp) in hso_mux_submit_intr_urb() argument
3192 usb_fill_int_urb(shared_int->shared_intr_urb, usb, in hso_mux_submit_intr_urb()
3193 usb_rcvintpipe(usb, in hso_mux_submit_intr_urb()
3194 shared_int->intr_endp->bEndpointAddress & 0x7F), in hso_mux_submit_intr_urb()
3195 shared_int->shared_intr_buf, in hso_mux_submit_intr_urb()
3198 shared_int->intr_endp->bInterval); in hso_mux_submit_intr_urb()
3200 result = usb_submit_urb(shared_int->shared_intr_urb, gfp); in hso_mux_submit_intr_urb()
3202 dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, in hso_mux_submit_intr_urb()
3208 /* operations setup of the serial interface */
3244 /* Initialise the serial table semaphore and table */ in hso_init()
3252 return -ENOMEM; in hso_init()
3255 tty_drv->driver_name = driver_name; in hso_init()
3256 tty_drv->name = tty_filename; in hso_init()
3260 tty_drv->major = tty_major; in hso_init()
3262 tty_drv->minor_start = 0; in hso_init()
3263 tty_drv->type = TTY_DRIVER_TYPE_SERIAL; in hso_init()
3264 tty_drv->subtype = SERIAL_TYPE_NORMAL; in hso_init()
3265 tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; in hso_init()
3266 tty_drv->init_termios = tty_std_termios; in hso_init()
3267 hso_init_termios(&tty_drv->init_termios); in hso_init()
3273 pr_err("%s - tty_register_driver failed(%d)\n", in hso_init()
3278 /* register this module as an usb driver */ in hso_init()
3281 pr_err("Could not register hso driver - error: %d\n", result); in hso_init()
3299 /* deregister the usb driver */ in hso_exit()