diff options
Diffstat (limited to 'drivers/net/usb/hso.c')
-rw-r--r-- | drivers/net/usb/hso.c | 105 |
1 files changed, 77 insertions, 28 deletions
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index f78f0903b073..6895f1531238 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -286,6 +286,7 @@ struct hso_device { | |||
286 | u8 usb_gone; | 286 | u8 usb_gone; |
287 | struct work_struct async_get_intf; | 287 | struct work_struct async_get_intf; |
288 | struct work_struct async_put_intf; | 288 | struct work_struct async_put_intf; |
289 | struct work_struct reset_device; | ||
289 | 290 | ||
290 | struct usb_device *usb; | 291 | struct usb_device *usb; |
291 | struct usb_interface *interface; | 292 | struct usb_interface *interface; |
@@ -332,7 +333,8 @@ static void hso_kick_transmit(struct hso_serial *serial); | |||
332 | /* Helper functions */ | 333 | /* Helper functions */ |
333 | static int hso_mux_submit_intr_urb(struct hso_shared_int *mux_int, | 334 | static int hso_mux_submit_intr_urb(struct hso_shared_int *mux_int, |
334 | struct usb_device *usb, gfp_t gfp); | 335 | struct usb_device *usb, gfp_t gfp); |
335 | static void log_usb_status(int status, const char *function); | 336 | static void handle_usb_error(int status, const char *function, |
337 | struct hso_device *hso_dev); | ||
336 | static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, | 338 | static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, |
337 | int type, int dir); | 339 | int type, int dir); |
338 | static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *ports); | 340 | static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *ports); |
@@ -350,6 +352,7 @@ static void async_put_intf(struct work_struct *data); | |||
350 | static int hso_put_activity(struct hso_device *hso_dev); | 352 | static int hso_put_activity(struct hso_device *hso_dev); |
351 | static int hso_get_activity(struct hso_device *hso_dev); | 353 | static int hso_get_activity(struct hso_device *hso_dev); |
352 | static void tiocmget_intr_callback(struct urb *urb); | 354 | static void tiocmget_intr_callback(struct urb *urb); |
355 | static void reset_device(struct work_struct *data); | ||
353 | /*****************************************************************************/ | 356 | /*****************************************************************************/ |
354 | /* Helping functions */ | 357 | /* Helping functions */ |
355 | /*****************************************************************************/ | 358 | /*****************************************************************************/ |
@@ -461,10 +464,17 @@ static const struct usb_device_id hso_ids[] = { | |||
461 | {USB_DEVICE(0x0af0, 0x7501)}, /* GTM 382 */ | 464 | {USB_DEVICE(0x0af0, 0x7501)}, /* GTM 382 */ |
462 | {USB_DEVICE(0x0af0, 0x7601)}, /* GE40x */ | 465 | {USB_DEVICE(0x0af0, 0x7601)}, /* GE40x */ |
463 | {USB_DEVICE(0x0af0, 0x7701)}, | 466 | {USB_DEVICE(0x0af0, 0x7701)}, |
467 | {USB_DEVICE(0x0af0, 0x7706)}, | ||
464 | {USB_DEVICE(0x0af0, 0x7801)}, | 468 | {USB_DEVICE(0x0af0, 0x7801)}, |
465 | {USB_DEVICE(0x0af0, 0x7901)}, | 469 | {USB_DEVICE(0x0af0, 0x7901)}, |
470 | {USB_DEVICE(0x0af0, 0x7A01)}, | ||
471 | {USB_DEVICE(0x0af0, 0x7A05)}, | ||
466 | {USB_DEVICE(0x0af0, 0x8200)}, | 472 | {USB_DEVICE(0x0af0, 0x8200)}, |
467 | {USB_DEVICE(0x0af0, 0x8201)}, | 473 | {USB_DEVICE(0x0af0, 0x8201)}, |
474 | {USB_DEVICE(0x0af0, 0x8300)}, | ||
475 | {USB_DEVICE(0x0af0, 0x8302)}, | ||
476 | {USB_DEVICE(0x0af0, 0x8304)}, | ||
477 | {USB_DEVICE(0x0af0, 0x8400)}, | ||
468 | {USB_DEVICE(0x0af0, 0xd035)}, | 478 | {USB_DEVICE(0x0af0, 0xd035)}, |
469 | {USB_DEVICE(0x0af0, 0xd055)}, | 479 | {USB_DEVICE(0x0af0, 0xd055)}, |
470 | {USB_DEVICE(0x0af0, 0xd155)}, | 480 | {USB_DEVICE(0x0af0, 0xd155)}, |
@@ -473,6 +483,8 @@ static const struct usb_device_id hso_ids[] = { | |||
473 | {USB_DEVICE(0x0af0, 0xd157)}, | 483 | {USB_DEVICE(0x0af0, 0xd157)}, |
474 | {USB_DEVICE(0x0af0, 0xd257)}, | 484 | {USB_DEVICE(0x0af0, 0xd257)}, |
475 | {USB_DEVICE(0x0af0, 0xd357)}, | 485 | {USB_DEVICE(0x0af0, 0xd357)}, |
486 | {USB_DEVICE(0x0af0, 0xd058)}, | ||
487 | {USB_DEVICE(0x0af0, 0xc100)}, | ||
476 | {} | 488 | {} |
477 | }; | 489 | }; |
478 | MODULE_DEVICE_TABLE(usb, hso_ids); | 490 | MODULE_DEVICE_TABLE(usb, hso_ids); |
@@ -655,8 +667,8 @@ static void set_serial_by_index(unsigned index, struct hso_serial *serial) | |||
655 | spin_unlock_irqrestore(&serial_table_lock, flags); | 667 | spin_unlock_irqrestore(&serial_table_lock, flags); |
656 | } | 668 | } |
657 | 669 | ||
658 | /* log a meaningful explanation of an USB status */ | 670 | static void handle_usb_error(int status, const char *function, |
659 | static void log_usb_status(int status, const char *function) | 671 | struct hso_device *hso_dev) |
660 | { | 672 | { |
661 | char *explanation; | 673 | char *explanation; |
662 | 674 | ||
@@ -685,10 +697,20 @@ static void log_usb_status(int status, const char *function) | |||
685 | case -EMSGSIZE: | 697 | case -EMSGSIZE: |
686 | explanation = "internal error"; | 698 | explanation = "internal error"; |
687 | break; | 699 | break; |
700 | case -EILSEQ: | ||
701 | case -EPROTO: | ||
702 | case -ETIME: | ||
703 | case -ETIMEDOUT: | ||
704 | explanation = "protocol error"; | ||
705 | if (hso_dev) | ||
706 | schedule_work(&hso_dev->reset_device); | ||
707 | break; | ||
688 | default: | 708 | default: |
689 | explanation = "unknown status"; | 709 | explanation = "unknown status"; |
690 | break; | 710 | break; |
691 | } | 711 | } |
712 | |||
713 | /* log a meaningful explanation of an USB status */ | ||
692 | D1("%s: received USB status - %s (%d)", function, explanation, status); | 714 | D1("%s: received USB status - %s (%d)", function, explanation, status); |
693 | } | 715 | } |
694 | 716 | ||
@@ -762,7 +784,7 @@ static void write_bulk_callback(struct urb *urb) | |||
762 | /* log status, but don't act on it, we don't need to resubmit anything | 784 | /* log status, but don't act on it, we don't need to resubmit anything |
763 | * anyhow */ | 785 | * anyhow */ |
764 | if (status) | 786 | if (status) |
765 | log_usb_status(status, __func__); | 787 | handle_usb_error(status, __func__, odev->parent); |
766 | 788 | ||
767 | hso_put_activity(odev->parent); | 789 | hso_put_activity(odev->parent); |
768 | 790 | ||
@@ -806,7 +828,7 @@ static netdev_tx_t hso_net_start_xmit(struct sk_buff *skb, | |||
806 | result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); | 828 | result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); |
807 | if (result) { | 829 | if (result) { |
808 | dev_warn(&odev->parent->interface->dev, | 830 | dev_warn(&odev->parent->interface->dev, |
809 | "failed mux_bulk_tx_urb %d", result); | 831 | "failed mux_bulk_tx_urb %d\n", result); |
810 | net->stats.tx_errors++; | 832 | net->stats.tx_errors++; |
811 | netif_start_queue(net); | 833 | netif_start_queue(net); |
812 | } else { | 834 | } else { |
@@ -998,7 +1020,7 @@ static void read_bulk_callback(struct urb *urb) | |||
998 | 1020 | ||
999 | /* is al ok? (Filip: Who's Al ?) */ | 1021 | /* is al ok? (Filip: Who's Al ?) */ |
1000 | if (status) { | 1022 | if (status) { |
1001 | log_usb_status(status, __func__); | 1023 | handle_usb_error(status, __func__, odev->parent); |
1002 | return; | 1024 | return; |
1003 | } | 1025 | } |
1004 | 1026 | ||
@@ -1019,7 +1041,8 @@ static void read_bulk_callback(struct urb *urb) | |||
1019 | if (odev->parent->port_spec & HSO_INFO_CRC_BUG) { | 1041 | if (odev->parent->port_spec & HSO_INFO_CRC_BUG) { |
1020 | u32 rest; | 1042 | u32 rest; |
1021 | u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; | 1043 | u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; |
1022 | rest = urb->actual_length % odev->in_endp->wMaxPacketSize; | 1044 | rest = urb->actual_length % |
1045 | le16_to_cpu(odev->in_endp->wMaxPacketSize); | ||
1023 | if (((rest == 5) || (rest == 6)) && | 1046 | if (((rest == 5) || (rest == 6)) && |
1024 | !memcmp(((u8 *) urb->transfer_buffer) + | 1047 | !memcmp(((u8 *) urb->transfer_buffer) + |
1025 | urb->actual_length - 4, crc_check, 4)) { | 1048 | urb->actual_length - 4, crc_check, 4)) { |
@@ -1053,7 +1076,7 @@ static void read_bulk_callback(struct urb *urb) | |||
1053 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1076 | result = usb_submit_urb(urb, GFP_ATOMIC); |
1054 | if (result) | 1077 | if (result) |
1055 | dev_warn(&odev->parent->interface->dev, | 1078 | dev_warn(&odev->parent->interface->dev, |
1056 | "%s failed submit mux_bulk_rx_urb %d", __func__, | 1079 | "%s failed submit mux_bulk_rx_urb %d\n", __func__, |
1057 | result); | 1080 | result); |
1058 | } | 1081 | } |
1059 | 1082 | ||
@@ -1207,7 +1230,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb) | |||
1207 | D1("serial == NULL"); | 1230 | D1("serial == NULL"); |
1208 | return; | 1231 | return; |
1209 | } else if (status) { | 1232 | } else if (status) { |
1210 | log_usb_status(status, __func__); | 1233 | handle_usb_error(status, __func__, serial->parent); |
1211 | return; | 1234 | return; |
1212 | } | 1235 | } |
1213 | 1236 | ||
@@ -1225,7 +1248,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb) | |||
1225 | u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; | 1248 | u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; |
1226 | rest = | 1249 | rest = |
1227 | urb->actual_length % | 1250 | urb->actual_length % |
1228 | serial->in_endp->wMaxPacketSize; | 1251 | le16_to_cpu(serial->in_endp->wMaxPacketSize); |
1229 | if (((rest == 5) || (rest == 6)) && | 1252 | if (((rest == 5) || (rest == 6)) && |
1230 | !memcmp(((u8 *) urb->transfer_buffer) + | 1253 | !memcmp(((u8 *) urb->transfer_buffer) + |
1231 | urb->actual_length - 4, crc_check, 4)) { | 1254 | urb->actual_length - 4, crc_check, 4)) { |
@@ -1513,7 +1536,7 @@ static void tiocmget_intr_callback(struct urb *urb) | |||
1513 | if (!serial) | 1536 | if (!serial) |
1514 | return; | 1537 | return; |
1515 | if (status) { | 1538 | if (status) { |
1516 | log_usb_status(status, __func__); | 1539 | handle_usb_error(status, __func__, serial->parent); |
1517 | return; | 1540 | return; |
1518 | } | 1541 | } |
1519 | tiocmget = serial->tiocmget; | 1542 | tiocmget = serial->tiocmget; |
@@ -1700,6 +1723,10 @@ static int hso_serial_tiocmset(struct tty_struct *tty, struct file *file, | |||
1700 | D1("no tty structures"); | 1723 | D1("no tty structures"); |
1701 | return -EINVAL; | 1724 | return -EINVAL; |
1702 | } | 1725 | } |
1726 | |||
1727 | if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) | ||
1728 | return -EINVAL; | ||
1729 | |||
1703 | if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber; | 1730 | if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber; |
1704 | 1731 | ||
1705 | spin_lock_irqsave(&serial->serial_lock, flags); | 1732 | spin_lock_irqsave(&serial->serial_lock, flags); |
@@ -1838,7 +1865,7 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port, | |||
1838 | result = usb_submit_urb(ctrl_urb, GFP_ATOMIC); | 1865 | result = usb_submit_urb(ctrl_urb, GFP_ATOMIC); |
1839 | if (result) { | 1866 | if (result) { |
1840 | dev_err(&ctrl_urb->dev->dev, | 1867 | dev_err(&ctrl_urb->dev->dev, |
1841 | "%s failed submit ctrl_urb %d type %d", __func__, | 1868 | "%s failed submit ctrl_urb %d type %d\n", __func__, |
1842 | result, type); | 1869 | result, type); |
1843 | return result; | 1870 | return result; |
1844 | } | 1871 | } |
@@ -1888,7 +1915,7 @@ static void intr_callback(struct urb *urb) | |||
1888 | 1915 | ||
1889 | /* status check */ | 1916 | /* status check */ |
1890 | if (status) { | 1917 | if (status) { |
1891 | log_usb_status(status, __func__); | 1918 | handle_usb_error(status, __func__, NULL); |
1892 | return; | 1919 | return; |
1893 | } | 1920 | } |
1894 | D4("\n--- Got intr callback 0x%02X ---", status); | 1921 | D4("\n--- Got intr callback 0x%02X ---", status); |
@@ -1905,18 +1932,18 @@ static void intr_callback(struct urb *urb) | |||
1905 | if (serial != NULL) { | 1932 | if (serial != NULL) { |
1906 | D1("Pending read interrupt on port %d\n", i); | 1933 | D1("Pending read interrupt on port %d\n", i); |
1907 | spin_lock(&serial->serial_lock); | 1934 | spin_lock(&serial->serial_lock); |
1908 | if (serial->rx_state == RX_IDLE) { | 1935 | if (serial->rx_state == RX_IDLE && |
1936 | serial->open_count > 0) { | ||
1909 | /* Setup and send a ctrl req read on | 1937 | /* Setup and send a ctrl req read on |
1910 | * port i */ | 1938 | * port i */ |
1911 | if (!serial->rx_urb_filled[0]) { | 1939 | if (!serial->rx_urb_filled[0]) { |
1912 | serial->rx_state = RX_SENT; | 1940 | serial->rx_state = RX_SENT; |
1913 | hso_mux_serial_read(serial); | 1941 | hso_mux_serial_read(serial); |
1914 | } else | 1942 | } else |
1915 | serial->rx_state = RX_PENDING; | 1943 | serial->rx_state = RX_PENDING; |
1916 | |||
1917 | } else { | 1944 | } else { |
1918 | D1("Already pending a read on " | 1945 | D1("Already a read pending on " |
1919 | "port %d\n", i); | 1946 | "port %d or port not open\n", i); |
1920 | } | 1947 | } |
1921 | spin_unlock(&serial->serial_lock); | 1948 | spin_unlock(&serial->serial_lock); |
1922 | } | 1949 | } |
@@ -1958,7 +1985,7 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb) | |||
1958 | tty = tty_kref_get(serial->tty); | 1985 | tty = tty_kref_get(serial->tty); |
1959 | spin_unlock(&serial->serial_lock); | 1986 | spin_unlock(&serial->serial_lock); |
1960 | if (status) { | 1987 | if (status) { |
1961 | log_usb_status(status, __func__); | 1988 | handle_usb_error(status, __func__, serial->parent); |
1962 | tty_kref_put(tty); | 1989 | tty_kref_put(tty); |
1963 | return; | 1990 | return; |
1964 | } | 1991 | } |
@@ -2014,7 +2041,7 @@ static void ctrl_callback(struct urb *urb) | |||
2014 | tty = tty_kref_get(serial->tty); | 2041 | tty = tty_kref_get(serial->tty); |
2015 | spin_unlock(&serial->serial_lock); | 2042 | spin_unlock(&serial->serial_lock); |
2016 | if (status) { | 2043 | if (status) { |
2017 | log_usb_status(status, __func__); | 2044 | handle_usb_error(status, __func__, serial->parent); |
2018 | tty_kref_put(tty); | 2045 | tty_kref_put(tty); |
2019 | return; | 2046 | return; |
2020 | } | 2047 | } |
@@ -2358,12 +2385,12 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, | |||
2358 | serial->tx_data_length = tx_size; | 2385 | serial->tx_data_length = tx_size; |
2359 | serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); | 2386 | serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); |
2360 | if (!serial->tx_data) { | 2387 | if (!serial->tx_data) { |
2361 | dev_err(dev, "%s - Out of memory", __func__); | 2388 | dev_err(dev, "%s - Out of memory\n", __func__); |
2362 | goto exit; | 2389 | goto exit; |
2363 | } | 2390 | } |
2364 | serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); | 2391 | serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); |
2365 | if (!serial->tx_buffer) { | 2392 | if (!serial->tx_buffer) { |
2366 | dev_err(dev, "%s - Out of memory", __func__); | 2393 | dev_err(dev, "%s - Out of memory\n", __func__); |
2367 | goto exit; | 2394 | goto exit; |
2368 | } | 2395 | } |
2369 | 2396 | ||
@@ -2391,6 +2418,7 @@ static struct hso_device *hso_create_device(struct usb_interface *intf, | |||
2391 | 2418 | ||
2392 | INIT_WORK(&hso_dev->async_get_intf, async_get_intf); | 2419 | INIT_WORK(&hso_dev->async_get_intf, async_get_intf); |
2393 | INIT_WORK(&hso_dev->async_put_intf, async_put_intf); | 2420 | INIT_WORK(&hso_dev->async_put_intf, async_put_intf); |
2421 | INIT_WORK(&hso_dev->reset_device, reset_device); | ||
2394 | 2422 | ||
2395 | return hso_dev; | 2423 | return hso_dev; |
2396 | } | 2424 | } |
@@ -2831,13 +2859,14 @@ struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface) | |||
2831 | 2859 | ||
2832 | mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); | 2860 | mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); |
2833 | if (!mux->shared_intr_urb) { | 2861 | if (!mux->shared_intr_urb) { |
2834 | dev_err(&interface->dev, "Could not allocate intr urb?"); | 2862 | dev_err(&interface->dev, "Could not allocate intr urb?\n"); |
2835 | goto exit; | 2863 | goto exit; |
2836 | } | 2864 | } |
2837 | mux->shared_intr_buf = kzalloc(mux->intr_endp->wMaxPacketSize, | 2865 | mux->shared_intr_buf = |
2838 | GFP_KERNEL); | 2866 | kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), |
2867 | GFP_KERNEL); | ||
2839 | if (!mux->shared_intr_buf) { | 2868 | if (!mux->shared_intr_buf) { |
2840 | dev_err(&interface->dev, "Could not allocate intr buf?"); | 2869 | dev_err(&interface->dev, "Could not allocate intr buf?\n"); |
2841 | goto exit; | 2870 | goto exit; |
2842 | } | 2871 | } |
2843 | 2872 | ||
@@ -3132,6 +3161,26 @@ out: | |||
3132 | return result; | 3161 | return result; |
3133 | } | 3162 | } |
3134 | 3163 | ||
3164 | static void reset_device(struct work_struct *data) | ||
3165 | { | ||
3166 | struct hso_device *hso_dev = | ||
3167 | container_of(data, struct hso_device, reset_device); | ||
3168 | struct usb_device *usb = hso_dev->usb; | ||
3169 | int result; | ||
3170 | |||
3171 | if (hso_dev->usb_gone) { | ||
3172 | D1("No reset during disconnect\n"); | ||
3173 | } else { | ||
3174 | result = usb_lock_device_for_reset(usb, hso_dev->interface); | ||
3175 | if (result < 0) | ||
3176 | D1("unable to lock device for reset: %d\n", result); | ||
3177 | else { | ||
3178 | usb_reset_device(usb); | ||
3179 | usb_unlock_device(usb); | ||
3180 | } | ||
3181 | } | ||
3182 | } | ||
3183 | |||
3135 | static void hso_serial_ref_free(struct kref *ref) | 3184 | static void hso_serial_ref_free(struct kref *ref) |
3136 | { | 3185 | { |
3137 | struct hso_device *hso_dev = container_of(ref, struct hso_device, ref); | 3186 | struct hso_device *hso_dev = container_of(ref, struct hso_device, ref); |
@@ -3232,13 +3281,13 @@ static int hso_mux_submit_intr_urb(struct hso_shared_int *shared_int, | |||
3232 | usb_rcvintpipe(usb, | 3281 | usb_rcvintpipe(usb, |
3233 | shared_int->intr_endp->bEndpointAddress & 0x7F), | 3282 | shared_int->intr_endp->bEndpointAddress & 0x7F), |
3234 | shared_int->shared_intr_buf, | 3283 | shared_int->shared_intr_buf, |
3235 | shared_int->intr_endp->wMaxPacketSize, | 3284 | 1, |
3236 | intr_callback, shared_int, | 3285 | intr_callback, shared_int, |
3237 | shared_int->intr_endp->bInterval); | 3286 | shared_int->intr_endp->bInterval); |
3238 | 3287 | ||
3239 | result = usb_submit_urb(shared_int->shared_intr_urb, gfp); | 3288 | result = usb_submit_urb(shared_int->shared_intr_urb, gfp); |
3240 | if (result) | 3289 | if (result) |
3241 | dev_warn(&usb->dev, "%s failed mux_intr_urb %d", __func__, | 3290 | dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, |
3242 | result); | 3291 | result); |
3243 | 3292 | ||
3244 | return result; | 3293 | return result; |