aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-12-09 01:14:38 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-12-09 01:14:38 -0500
commitbcd6acd51f3d4d1ada201e9bc5c40a31d6d80c71 (patch)
tree2f6dffd2d3e4dd67355a224de7e7a960335a92fd /drivers/net/usb
parent11c34c7deaeeebcee342cbc35e1bb2a6711b2431 (diff)
parent3ff6a468b45b5dfeb0e903e56f4eb27d34b2437c (diff)
Merge commit 'origin/master' into next
Conflicts: include/linux/kvm.h
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/asix.c24
-rw-r--r--drivers/net/usb/catc.c4
-rw-r--r--drivers/net/usb/cdc-phonet.c8
-rw-r--r--drivers/net/usb/cdc_eem.c4
-rw-r--r--drivers/net/usb/cdc_ether.c79
-rw-r--r--drivers/net/usb/dm9601.c2
-rw-r--r--drivers/net/usb/hso.c42
-rw-r--r--drivers/net/usb/kaweth.c11
-rw-r--r--drivers/net/usb/mcs7830.c4
-rw-r--r--drivers/net/usb/rndis_host.c10
-rw-r--r--drivers/net/usb/usbnet.c218
-rw-r--r--drivers/net/usb/zaurus.c4
12 files changed, 269 insertions, 141 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 6ce7f775bb74..a516185cbc9f 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -365,8 +365,8 @@ static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
365 365
366 padlen = ((skb->len + 4) % 512) ? 0 : 4; 366 padlen = ((skb->len + 4) % 512) ? 0 : 4;
367 367
368 if ((!skb_cloned(skb)) 368 if ((!skb_cloned(skb)) &&
369 && ((headroom + tailroom) >= (4 + padlen))) { 369 ((headroom + tailroom) >= (4 + padlen))) {
370 if ((headroom < 4) || (tailroom < padlen)) { 370 if ((headroom < 4) || (tailroom < padlen)) {
371 skb->data = memmove(skb->head + 4, skb->data, skb->len); 371 skb->data = memmove(skb->head + 4, skb->data, skb->len);
372 skb_set_tail_pointer(skb, skb->len); 372 skb_set_tail_pointer(skb, skb->len);
@@ -541,8 +541,8 @@ static void asix_set_multicast(struct net_device *net)
541 541
542 if (net->flags & IFF_PROMISC) { 542 if (net->flags & IFF_PROMISC) {
543 rx_ctl |= AX_RX_CTL_PRO; 543 rx_ctl |= AX_RX_CTL_PRO;
544 } else if (net->flags & IFF_ALLMULTI 544 } else if (net->flags & IFF_ALLMULTI ||
545 || net->mc_count > AX_MAX_MCAST) { 545 net->mc_count > AX_MAX_MCAST) {
546 rx_ctl |= AX_RX_CTL_AMALL; 546 rx_ctl |= AX_RX_CTL_AMALL;
547 } else if (net->mc_count == 0) { 547 } else if (net->mc_count == 0) {
548 /* just broadcast and directed */ 548 /* just broadcast and directed */
@@ -753,8 +753,8 @@ static void ax88172_set_multicast(struct net_device *net)
753 753
754 if (net->flags & IFF_PROMISC) { 754 if (net->flags & IFF_PROMISC) {
755 rx_ctl |= 0x01; 755 rx_ctl |= 0x01;
756 } else if (net->flags & IFF_ALLMULTI 756 } else if (net->flags & IFF_ALLMULTI ||
757 || net->mc_count > AX_MAX_MCAST) { 757 net->mc_count > AX_MAX_MCAST) {
758 rx_ctl |= 0x02; 758 rx_ctl |= 0x02;
759 } else if (net->mc_count == 0) { 759 } else if (net->mc_count == 0) {
760 /* just broadcast and directed */ 760 /* just broadcast and directed */
@@ -1327,7 +1327,7 @@ static const struct driver_info ax8817x_info = {
1327 .status = asix_status, 1327 .status = asix_status,
1328 .link_reset = ax88172_link_reset, 1328 .link_reset = ax88172_link_reset,
1329 .reset = ax88172_link_reset, 1329 .reset = ax88172_link_reset,
1330 .flags = FLAG_ETHER, 1330 .flags = FLAG_ETHER | FLAG_LINK_INTR,
1331 .data = 0x00130103, 1331 .data = 0x00130103,
1332}; 1332};
1333 1333
@@ -1337,7 +1337,7 @@ static const struct driver_info dlink_dub_e100_info = {
1337 .status = asix_status, 1337 .status = asix_status,
1338 .link_reset = ax88172_link_reset, 1338 .link_reset = ax88172_link_reset,
1339 .reset = ax88172_link_reset, 1339 .reset = ax88172_link_reset,
1340 .flags = FLAG_ETHER, 1340 .flags = FLAG_ETHER | FLAG_LINK_INTR,
1341 .data = 0x009f9d9f, 1341 .data = 0x009f9d9f,
1342}; 1342};
1343 1343
@@ -1347,7 +1347,7 @@ static const struct driver_info netgear_fa120_info = {
1347 .status = asix_status, 1347 .status = asix_status,
1348 .link_reset = ax88172_link_reset, 1348 .link_reset = ax88172_link_reset,
1349 .reset = ax88172_link_reset, 1349 .reset = ax88172_link_reset,
1350 .flags = FLAG_ETHER, 1350 .flags = FLAG_ETHER | FLAG_LINK_INTR,
1351 .data = 0x00130103, 1351 .data = 0x00130103,
1352}; 1352};
1353 1353
@@ -1357,7 +1357,7 @@ static const struct driver_info hawking_uf200_info = {
1357 .status = asix_status, 1357 .status = asix_status,
1358 .link_reset = ax88172_link_reset, 1358 .link_reset = ax88172_link_reset,
1359 .reset = ax88172_link_reset, 1359 .reset = ax88172_link_reset,
1360 .flags = FLAG_ETHER, 1360 .flags = FLAG_ETHER | FLAG_LINK_INTR,
1361 .data = 0x001f1d1f, 1361 .data = 0x001f1d1f,
1362}; 1362};
1363 1363
@@ -1367,7 +1367,7 @@ static const struct driver_info ax88772_info = {
1367 .status = asix_status, 1367 .status = asix_status,
1368 .link_reset = ax88772_link_reset, 1368 .link_reset = ax88772_link_reset,
1369 .reset = ax88772_link_reset, 1369 .reset = ax88772_link_reset,
1370 .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1370 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR,
1371 .rx_fixup = asix_rx_fixup, 1371 .rx_fixup = asix_rx_fixup,
1372 .tx_fixup = asix_tx_fixup, 1372 .tx_fixup = asix_tx_fixup,
1373}; 1373};
@@ -1378,7 +1378,7 @@ static const struct driver_info ax88178_info = {
1378 .status = asix_status, 1378 .status = asix_status,
1379 .link_reset = ax88178_link_reset, 1379 .link_reset = ax88178_link_reset,
1380 .reset = ax88178_link_reset, 1380 .reset = ax88178_link_reset,
1381 .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1381 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR,
1382 .rx_fixup = asix_rx_fixup, 1382 .rx_fixup = asix_rx_fixup,
1383 .tx_fixup = asix_tx_fixup, 1383 .tx_fixup = asix_tx_fixup,
1384}; 1384};
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 2bed6b087d16..22b87e64a810 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -436,8 +436,8 @@ static netdev_tx_t catc_start_xmit(struct sk_buff *skb,
436 clear_bit(TX_RUNNING, &catc->flags); 436 clear_bit(TX_RUNNING, &catc->flags);
437 } 437 }
438 438
439 if ((catc->is_f5u011 && catc->tx_ptr) 439 if ((catc->is_f5u011 && catc->tx_ptr) ||
440 || (catc->tx_ptr >= ((TX_MAX_BURST - 1) * (PKT_SZ + 2)))) 440 (catc->tx_ptr >= ((TX_MAX_BURST - 1) * (PKT_SZ + 2))))
441 netif_stop_queue(netdev); 441 netif_stop_queue(netdev);
442 442
443 spin_unlock_irqrestore(&catc->tx_lock, flags); 443 spin_unlock_irqrestore(&catc->tx_lock, flags);
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 33d5c579c5ad..6491c9c00c83 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -372,12 +372,12 @@ int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id)
372 /* Data interface has one inactive and one active setting */ 372 /* Data interface has one inactive and one active setting */
373 if (data_intf->num_altsetting != 2) 373 if (data_intf->num_altsetting != 2)
374 return -EINVAL; 374 return -EINVAL;
375 if (data_intf->altsetting[0].desc.bNumEndpoints == 0 375 if (data_intf->altsetting[0].desc.bNumEndpoints == 0 &&
376 && data_intf->altsetting[1].desc.bNumEndpoints == 2) 376 data_intf->altsetting[1].desc.bNumEndpoints == 2)
377 data_desc = data_intf->altsetting + 1; 377 data_desc = data_intf->altsetting + 1;
378 else 378 else
379 if (data_intf->altsetting[0].desc.bNumEndpoints == 2 379 if (data_intf->altsetting[0].desc.bNumEndpoints == 2 &&
380 && data_intf->altsetting[1].desc.bNumEndpoints == 0) 380 data_intf->altsetting[1].desc.bNumEndpoints == 0)
381 data_desc = data_intf->altsetting; 381 data_desc = data_intf->altsetting;
382 else 382 else
383 return -EINVAL; 383 return -EINVAL;
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index 23300656c266..c337ffc3304a 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -121,8 +121,8 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
121 int headroom = skb_headroom(skb); 121 int headroom = skb_headroom(skb);
122 int tailroom = skb_tailroom(skb); 122 int tailroom = skb_tailroom(skb);
123 123
124 if ((tailroom >= ETH_FCS_LEN + padlen) 124 if ((tailroom >= ETH_FCS_LEN + padlen) &&
125 && (headroom >= EEM_HEAD)) 125 (headroom >= EEM_HEAD))
126 goto done; 126 goto done;
127 127
128 if ((headroom + tailroom) 128 if ((headroom + tailroom)
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 21e1ba160008..21e183a83b99 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -37,23 +37,23 @@
37 37
38static int is_rndis(struct usb_interface_descriptor *desc) 38static int is_rndis(struct usb_interface_descriptor *desc)
39{ 39{
40 return desc->bInterfaceClass == USB_CLASS_COMM 40 return (desc->bInterfaceClass == USB_CLASS_COMM &&
41 && desc->bInterfaceSubClass == 2 41 desc->bInterfaceSubClass == 2 &&
42 && desc->bInterfaceProtocol == 0xff; 42 desc->bInterfaceProtocol == 0xff);
43} 43}
44 44
45static int is_activesync(struct usb_interface_descriptor *desc) 45static int is_activesync(struct usb_interface_descriptor *desc)
46{ 46{
47 return desc->bInterfaceClass == USB_CLASS_MISC 47 return (desc->bInterfaceClass == USB_CLASS_MISC &&
48 && desc->bInterfaceSubClass == 1 48 desc->bInterfaceSubClass == 1 &&
49 && desc->bInterfaceProtocol == 1; 49 desc->bInterfaceProtocol == 1);
50} 50}
51 51
52static int is_wireless_rndis(struct usb_interface_descriptor *desc) 52static int is_wireless_rndis(struct usb_interface_descriptor *desc)
53{ 53{
54 return desc->bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER 54 return (desc->bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER &&
55 && desc->bInterfaceSubClass == 1 55 desc->bInterfaceSubClass == 1 &&
56 && desc->bInterfaceProtocol == 3; 56 desc->bInterfaceProtocol == 3);
57} 57}
58 58
59#else 59#else
@@ -116,9 +116,9 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
116 /* this assumes that if there's a non-RNDIS vendor variant 116 /* this assumes that if there's a non-RNDIS vendor variant
117 * of cdc-acm, it'll fail RNDIS requests cleanly. 117 * of cdc-acm, it'll fail RNDIS requests cleanly.
118 */ 118 */
119 rndis = is_rndis(&intf->cur_altsetting->desc) 119 rndis = (is_rndis(&intf->cur_altsetting->desc) ||
120 || is_activesync(&intf->cur_altsetting->desc) 120 is_activesync(&intf->cur_altsetting->desc) ||
121 || is_wireless_rndis(&intf->cur_altsetting->desc); 121 is_wireless_rndis(&intf->cur_altsetting->desc));
122 122
123 memset(info, 0, sizeof *info); 123 memset(info, 0, sizeof *info);
124 info->control = intf; 124 info->control = intf;
@@ -279,10 +279,10 @@ next_desc:
279 279
280 dev->status = &info->control->cur_altsetting->endpoint [0]; 280 dev->status = &info->control->cur_altsetting->endpoint [0];
281 desc = &dev->status->desc; 281 desc = &dev->status->desc;
282 if (!usb_endpoint_is_int_in(desc) 282 if (!usb_endpoint_is_int_in(desc) ||
283 || (le16_to_cpu(desc->wMaxPacketSize) 283 (le16_to_cpu(desc->wMaxPacketSize)
284 < sizeof(struct usb_cdc_notification)) 284 < sizeof(struct usb_cdc_notification)) ||
285 || !desc->bInterval) { 285 !desc->bInterval) {
286 dev_dbg(&intf->dev, "bad notification endpoint\n"); 286 dev_dbg(&intf->dev, "bad notification endpoint\n");
287 dev->status = NULL; 287 dev->status = NULL;
288 } 288 }
@@ -411,13 +411,28 @@ static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
411 return 0; 411 return 0;
412} 412}
413 413
414static int cdc_manage_power(struct usbnet *dev, int on)
415{
416 dev->intf->needs_remote_wakeup = on;
417 return 0;
418}
419
414static const struct driver_info cdc_info = { 420static const struct driver_info cdc_info = {
415 .description = "CDC Ethernet Device", 421 .description = "CDC Ethernet Device",
416 .flags = FLAG_ETHER, 422 .flags = FLAG_ETHER | FLAG_LINK_INTR,
417 // .check_connect = cdc_check_connect, 423 // .check_connect = cdc_check_connect,
418 .bind = cdc_bind, 424 .bind = cdc_bind,
419 .unbind = usbnet_cdc_unbind, 425 .unbind = usbnet_cdc_unbind,
420 .status = cdc_status, 426 .status = cdc_status,
427 .manage_power = cdc_manage_power,
428};
429
430static const struct driver_info mbm_info = {
431 .description = "Mobile Broadband Network Device",
432 .flags = FLAG_WWAN,
433 .bind = cdc_bind,
434 .unbind = usbnet_cdc_unbind,
435 .status = cdc_status,
421}; 436};
422 437
423/*-------------------------------------------------------------------------*/ 438/*-------------------------------------------------------------------------*/
@@ -532,72 +547,72 @@ static const struct usb_device_id products [] = {
532 /* Ericsson F3507g */ 547 /* Ericsson F3507g */
533 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1900, USB_CLASS_COMM, 548 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1900, USB_CLASS_COMM,
534 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 549 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
535 .driver_info = (unsigned long) &cdc_info, 550 .driver_info = (unsigned long) &mbm_info,
536}, { 551}, {
537 /* Ericsson F3507g ver. 2 */ 552 /* Ericsson F3507g ver. 2 */
538 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1902, USB_CLASS_COMM, 553 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1902, USB_CLASS_COMM,
539 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 554 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
540 .driver_info = (unsigned long) &cdc_info, 555 .driver_info = (unsigned long) &mbm_info,
541}, { 556}, {
542 /* Ericsson F3607gw */ 557 /* Ericsson F3607gw */
543 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1904, USB_CLASS_COMM, 558 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1904, USB_CLASS_COMM,
544 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 559 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
545 .driver_info = (unsigned long) &cdc_info, 560 .driver_info = (unsigned long) &mbm_info,
546}, { 561}, {
547 /* Ericsson F3607gw ver 2 */ 562 /* Ericsson F3607gw ver 2 */
548 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1905, USB_CLASS_COMM, 563 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1905, USB_CLASS_COMM,
549 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 564 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
550 .driver_info = (unsigned long) &cdc_info, 565 .driver_info = (unsigned long) &mbm_info,
551}, { 566}, {
552 /* Ericsson F3607gw ver 3 */ 567 /* Ericsson F3607gw ver 3 */
553 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1906, USB_CLASS_COMM, 568 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1906, USB_CLASS_COMM,
554 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 569 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
555 .driver_info = (unsigned long) &cdc_info, 570 .driver_info = (unsigned long) &mbm_info,
556}, { 571}, {
557 /* Ericsson F3307 */ 572 /* Ericsson F3307 */
558 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x190a, USB_CLASS_COMM, 573 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x190a, USB_CLASS_COMM,
559 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 574 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
560 .driver_info = (unsigned long) &cdc_info, 575 .driver_info = (unsigned long) &mbm_info,
561}, { 576}, {
562 /* Ericsson F3307 ver 2 */ 577 /* Ericsson F3307 ver 2 */
563 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1909, USB_CLASS_COMM, 578 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1909, USB_CLASS_COMM,
564 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 579 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
565 .driver_info = (unsigned long) &cdc_info, 580 .driver_info = (unsigned long) &mbm_info,
566}, { 581}, {
567 /* Ericsson C3607w */ 582 /* Ericsson C3607w */
568 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1049, USB_CLASS_COMM, 583 USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1049, USB_CLASS_COMM,
569 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 584 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
570 .driver_info = (unsigned long) &cdc_info, 585 .driver_info = (unsigned long) &mbm_info,
571}, { 586}, {
572 /* Toshiba F3507g */ 587 /* Toshiba F3507g */
573 USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x130b, USB_CLASS_COMM, 588 USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x130b, USB_CLASS_COMM,
574 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 589 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
575 .driver_info = (unsigned long) &cdc_info, 590 .driver_info = (unsigned long) &mbm_info,
576}, { 591}, {
577 /* Toshiba F3607gw */ 592 /* Toshiba F3607gw */
578 USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x130c, USB_CLASS_COMM, 593 USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x130c, USB_CLASS_COMM,
579 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 594 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
580 .driver_info = (unsigned long) &cdc_info, 595 .driver_info = (unsigned long) &mbm_info,
581}, { 596}, {
582 /* Toshiba F3607gw ver 2 */ 597 /* Toshiba F3607gw ver 2 */
583 USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x1311, USB_CLASS_COMM, 598 USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x1311, USB_CLASS_COMM,
584 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 599 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
585 .driver_info = (unsigned long) &cdc_info, 600 .driver_info = (unsigned long) &mbm_info,
586}, { 601}, {
587 /* Dell F3507g */ 602 /* Dell F3507g */
588 USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8147, USB_CLASS_COMM, 603 USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8147, USB_CLASS_COMM,
589 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 604 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
590 .driver_info = (unsigned long) &cdc_info, 605 .driver_info = (unsigned long) &mbm_info,
591}, { 606}, {
592 /* Dell F3607gw */ 607 /* Dell F3607gw */
593 USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8183, USB_CLASS_COMM, 608 USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8183, USB_CLASS_COMM,
594 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 609 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
595 .driver_info = (unsigned long) &cdc_info, 610 .driver_info = (unsigned long) &mbm_info,
596}, { 611}, {
597 /* Dell F3607gw ver 2 */ 612 /* Dell F3607gw ver 2 */
598 USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8184, USB_CLASS_COMM, 613 USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8184, USB_CLASS_COMM,
599 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), 614 USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
600 .driver_info = (unsigned long) &cdc_info, 615 .driver_info = (unsigned long) &mbm_info,
601}, 616},
602 { }, // END 617 { }, // END
603}; 618};
@@ -610,6 +625,8 @@ static struct usb_driver cdc_driver = {
610 .disconnect = usbnet_disconnect, 625 .disconnect = usbnet_disconnect,
611 .suspend = usbnet_suspend, 626 .suspend = usbnet_suspend,
612 .resume = usbnet_resume, 627 .resume = usbnet_resume,
628 .reset_resume = usbnet_resume,
629 .supports_autosuspend = 1,
613}; 630};
614 631
615 632
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index a2b30a10064f..3d406f9b2f29 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -611,7 +611,7 @@ static int dm9601_link_reset(struct usbnet *dev)
611 611
612static const struct driver_info dm9601_info = { 612static const struct driver_info dm9601_info = {
613 .description = "Davicom DM9601 USB Ethernet", 613 .description = "Davicom DM9601 USB Ethernet",
614 .flags = FLAG_ETHER, 614 .flags = FLAG_ETHER | FLAG_LINK_INTR,
615 .bind = dm9601_bind, 615 .bind = dm9601_bind,
616 .rx_fixup = dm9601_rx_fixup, 616 .rx_fixup = dm9601_rx_fixup,
617 .tx_fixup = dm9601_tx_fixup, 617 .tx_fixup = dm9601_tx_fixup,
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index fa4e58196c21..f78f0903b073 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -378,7 +378,7 @@ static void dbg_dump(int line_count, const char *func_name, unsigned char *buf,
378} 378}
379 379
380#define DUMP(buf_, len_) \ 380#define DUMP(buf_, len_) \
381 dbg_dump(__LINE__, __func__, buf_, len_) 381 dbg_dump(__LINE__, __func__, (unsigned char *)buf_, len_)
382 382
383#define DUMP1(buf_, len_) \ 383#define DUMP1(buf_, len_) \
384 do { \ 384 do { \
@@ -602,9 +602,9 @@ static struct hso_serial *get_serial_by_shared_int_and_type(
602 port = hso_mux_to_port(mux); 602 port = hso_mux_to_port(mux);
603 603
604 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { 604 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
605 if (serial_table[i] 605 if (serial_table[i] &&
606 && (dev2ser(serial_table[i])->shared_int == shared_int) 606 (dev2ser(serial_table[i])->shared_int == shared_int) &&
607 && ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { 607 ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) {
608 return dev2ser(serial_table[i]); 608 return dev2ser(serial_table[i]);
609 } 609 }
610 } 610 }
@@ -846,8 +846,8 @@ static void hso_net_tx_timeout(struct net_device *net)
846 dev_warn(&net->dev, "Tx timed out.\n"); 846 dev_warn(&net->dev, "Tx timed out.\n");
847 847
848 /* Tear the waiting frame off the list */ 848 /* Tear the waiting frame off the list */
849 if (odev->mux_bulk_tx_urb 849 if (odev->mux_bulk_tx_urb &&
850 && (odev->mux_bulk_tx_urb->status == -EINPROGRESS)) 850 (odev->mux_bulk_tx_urb->status == -EINPROGRESS))
851 usb_unlink_urb(odev->mux_bulk_tx_urb); 851 usb_unlink_urb(odev->mux_bulk_tx_urb);
852 852
853 /* Update statistics */ 853 /* Update statistics */
@@ -1020,9 +1020,9 @@ static void read_bulk_callback(struct urb *urb)
1020 u32 rest; 1020 u32 rest;
1021 u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; 1021 u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF };
1022 rest = urb->actual_length % odev->in_endp->wMaxPacketSize; 1022 rest = urb->actual_length % odev->in_endp->wMaxPacketSize;
1023 if (((rest == 5) || (rest == 6)) 1023 if (((rest == 5) || (rest == 6)) &&
1024 && !memcmp(((u8 *) urb->transfer_buffer) + 1024 !memcmp(((u8 *) urb->transfer_buffer) +
1025 urb->actual_length - 4, crc_check, 4)) { 1025 urb->actual_length - 4, crc_check, 4)) {
1026 urb->actual_length -= 4; 1026 urb->actual_length -= 4;
1027 } 1027 }
1028 } 1028 }
@@ -1226,9 +1226,9 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
1226 rest = 1226 rest =
1227 urb->actual_length % 1227 urb->actual_length %
1228 serial->in_endp->wMaxPacketSize; 1228 serial->in_endp->wMaxPacketSize;
1229 if (((rest == 5) || (rest == 6)) 1229 if (((rest == 5) || (rest == 6)) &&
1230 && !memcmp(((u8 *) urb->transfer_buffer) + 1230 !memcmp(((u8 *) urb->transfer_buffer) +
1231 urb->actual_length - 4, crc_check, 4)) { 1231 urb->actual_length - 4, crc_check, 4)) {
1232 urb->actual_length -= 4; 1232 urb->actual_length -= 4;
1233 } 1233 }
1234 } 1234 }
@@ -1363,7 +1363,7 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
1363 /* reset the rts and dtr */ 1363 /* reset the rts and dtr */
1364 /* do the actual close */ 1364 /* do the actual close */
1365 serial->open_count--; 1365 serial->open_count--;
1366 kref_put(&serial->parent->ref, hso_serial_ref_free); 1366
1367 if (serial->open_count <= 0) { 1367 if (serial->open_count <= 0) {
1368 serial->open_count = 0; 1368 serial->open_count = 0;
1369 spin_lock_irq(&serial->serial_lock); 1369 spin_lock_irq(&serial->serial_lock);
@@ -1383,6 +1383,8 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
1383 usb_autopm_put_interface(serial->parent->interface); 1383 usb_autopm_put_interface(serial->parent->interface);
1384 1384
1385 mutex_unlock(&serial->parent->mutex); 1385 mutex_unlock(&serial->parent->mutex);
1386
1387 kref_put(&serial->parent->ref, hso_serial_ref_free);
1386} 1388}
1387 1389
1388/* close the requested serial port */ 1390/* close the requested serial port */
@@ -1527,7 +1529,7 @@ static void tiocmget_intr_callback(struct urb *urb)
1527 dev_warn(&usb->dev, 1529 dev_warn(&usb->dev,
1528 "hso received invalid serial state notification\n"); 1530 "hso received invalid serial state notification\n");
1529 DUMP(serial_state_notification, 1531 DUMP(serial_state_notification,
1530 sizeof(hso_serial_state_notifation)) 1532 sizeof(struct hso_serial_state_notification));
1531 } else { 1533 } else {
1532 1534
1533 UART_state_bitmap = le16_to_cpu(serial_state_notification-> 1535 UART_state_bitmap = le16_to_cpu(serial_state_notification->
@@ -2980,8 +2982,8 @@ static int hso_probe(struct usb_interface *interface,
2980 2982
2981 case HSO_INTF_BULK: 2983 case HSO_INTF_BULK:
2982 /* It's a regular bulk interface */ 2984 /* It's a regular bulk interface */
2983 if (((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) 2985 if (((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) &&
2984 && !disable_net) 2986 !disable_net)
2985 hso_dev = hso_create_net_device(interface, port_spec); 2987 hso_dev = hso_create_net_device(interface, port_spec);
2986 else 2988 else
2987 hso_dev = 2989 hso_dev =
@@ -3144,8 +3146,8 @@ static void hso_free_interface(struct usb_interface *interface)
3144 int i; 3146 int i;
3145 3147
3146 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { 3148 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
3147 if (serial_table[i] 3149 if (serial_table[i] &&
3148 && (serial_table[i]->interface == interface)) { 3150 (serial_table[i]->interface == interface)) {
3149 hso_dev = dev2ser(serial_table[i]); 3151 hso_dev = dev2ser(serial_table[i]);
3150 spin_lock_irq(&hso_dev->serial_lock); 3152 spin_lock_irq(&hso_dev->serial_lock);
3151 tty = tty_kref_get(hso_dev->tty); 3153 tty = tty_kref_get(hso_dev->tty);
@@ -3161,8 +3163,8 @@ static void hso_free_interface(struct usb_interface *interface)
3161 } 3163 }
3162 3164
3163 for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { 3165 for (i = 0; i < HSO_MAX_NET_DEVICES; i++) {
3164 if (network_table[i] 3166 if (network_table[i] &&
3165 && (network_table[i]->interface == interface)) { 3167 (network_table[i]->interface == interface)) {
3166 struct rfkill *rfk = dev2net(network_table[i])->rfkill; 3168 struct rfkill *rfk = dev2net(network_table[i])->rfkill;
3167 /* hso_stop_net_device doesn't stop the net queue since 3169 /* hso_stop_net_device doesn't stop the net queue since
3168 * traffic needs to start it again when suspended */ 3170 * traffic needs to start it again when suspended */
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index e391ef969c28..3b80e8d2d621 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -471,16 +471,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
471 int result; 471 int result;
472 472
473 dbg("kaweth_reset(%p)", kaweth); 473 dbg("kaweth_reset(%p)", kaweth);
474 result = kaweth_control(kaweth, 474 result = usb_reset_configuration(kaweth->dev);
475 usb_sndctrlpipe(kaweth->dev, 0),
476 USB_REQ_SET_CONFIGURATION,
477 0,
478 kaweth->dev->config[0].desc.bConfigurationValue,
479 0,
480 NULL,
481 0,
482 KAWETH_CONTROL_TIMEOUT);
483
484 mdelay(10); 475 mdelay(10);
485 476
486 dbg("kaweth_reset() returns %d.",result); 477 dbg("kaweth_reset() returns %d.",result);
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 10873d96b2da..87374317f480 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -391,8 +391,8 @@ static void mcs7830_set_multicast(struct net_device *net)
391 391
392 if (net->flags & IFF_PROMISC) { 392 if (net->flags & IFF_PROMISC) {
393 data->config |= HIF_REG_CONFIG_PROMISCIOUS; 393 data->config |= HIF_REG_CONFIG_PROMISCIOUS;
394 } else if (net->flags & IFF_ALLMULTI 394 } else if (net->flags & IFF_ALLMULTI ||
395 || net->mc_count > MCS7830_MAX_MCAST) { 395 net->mc_count > MCS7830_MAX_MCAST) {
396 data->config |= HIF_REG_CONFIG_ALLMULTICAST; 396 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
397 } else if (net->mc_count == 0) { 397 } else if (net->mc_count == 0) {
398 /* just broadcast and directed */ 398 /* just broadcast and directed */
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index f56dec6119c3..490fa8f55424 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -114,8 +114,8 @@ int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
114 */ 114 */
115 115
116 /* Issue the request; xid is unique, don't bother byteswapping it */ 116 /* Issue the request; xid is unique, don't bother byteswapping it */
117 if (likely(buf->msg_type != RNDIS_MSG_HALT 117 if (likely(buf->msg_type != RNDIS_MSG_HALT &&
118 && buf->msg_type != RNDIS_MSG_RESET)) { 118 buf->msg_type != RNDIS_MSG_RESET)) {
119 xid = dev->xid++; 119 xid = dev->xid++;
120 if (!xid) 120 if (!xid)
121 xid = dev->xid++; 121 xid = dev->xid++;
@@ -493,9 +493,9 @@ int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
493 data_len = le32_to_cpu(hdr->data_len); 493 data_len = le32_to_cpu(hdr->data_len);
494 494
495 /* don't choke if we see oob, per-packet data, etc */ 495 /* don't choke if we see oob, per-packet data, etc */
496 if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET 496 if (unlikely(hdr->msg_type != RNDIS_MSG_PACKET ||
497 || skb->len < msg_len 497 skb->len < msg_len ||
498 || (data_offset + data_len + 8) > msg_len)) { 498 (data_offset + data_len + 8) > msg_len)) {
499 dev->net->stats.rx_frame_errors++; 499 dev->net->stats.rx_frame_errors++;
500 devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d", 500 devdbg(dev, "bad rndis message %d/%d/%d/%d, len %d",
501 le32_to_cpu(hdr->msg_type), 501 le32_to_cpu(hdr->msg_type),
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ca5ca5ae061d..035fab04c0a0 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -140,8 +140,8 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
140 if (!alt || !in || !out) 140 if (!alt || !in || !out)
141 return -EINVAL; 141 return -EINVAL;
142 142
143 if (alt->desc.bAlternateSetting != 0 143 if (alt->desc.bAlternateSetting != 0 ||
144 || !(dev->driver_info->flags & FLAG_NO_SETINT)) { 144 !(dev->driver_info->flags & FLAG_NO_SETINT)) {
145 tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber, 145 tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber,
146 alt->desc.bAlternateSetting); 146 alt->desc.bAlternateSetting);
147 if (tmp < 0) 147 if (tmp < 0)
@@ -351,9 +351,10 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
351 351
352 spin_lock_irqsave (&dev->rxq.lock, lockflags); 352 spin_lock_irqsave (&dev->rxq.lock, lockflags);
353 353
354 if (netif_running (dev->net) 354 if (netif_running (dev->net) &&
355 && netif_device_present (dev->net) 355 netif_device_present (dev->net) &&
356 && !test_bit (EVENT_RX_HALT, &dev->flags)) { 356 !test_bit (EVENT_RX_HALT, &dev->flags) &&
357 !test_bit (EVENT_DEV_ASLEEP, &dev->flags)) {
357 switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) { 358 switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {
358 case -EPIPE: 359 case -EPIPE:
359 usbnet_defer_kevent (dev, EVENT_RX_HALT); 360 usbnet_defer_kevent (dev, EVENT_RX_HALT);
@@ -391,8 +392,8 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
391 392
392static inline void rx_process (struct usbnet *dev, struct sk_buff *skb) 393static inline void rx_process (struct usbnet *dev, struct sk_buff *skb)
393{ 394{
394 if (dev->driver_info->rx_fixup 395 if (dev->driver_info->rx_fixup &&
395 && !dev->driver_info->rx_fixup (dev, skb)) 396 !dev->driver_info->rx_fixup (dev, skb))
396 goto error; 397 goto error;
397 // else network stack removes extra byte if we forced a short packet 398 // else network stack removes extra byte if we forced a short packet
398 399
@@ -484,8 +485,8 @@ block:
484 defer_bh(dev, skb, &dev->rxq); 485 defer_bh(dev, skb, &dev->rxq);
485 486
486 if (urb) { 487 if (urb) {
487 if (netif_running (dev->net) 488 if (netif_running (dev->net) &&
488 && !test_bit (EVENT_RX_HALT, &dev->flags)) { 489 !test_bit (EVENT_RX_HALT, &dev->flags)) {
489 rx_submit (dev, urb, GFP_ATOMIC); 490 rx_submit (dev, urb, GFP_ATOMIC);
490 return; 491 return;
491 } 492 }
@@ -611,15 +612,39 @@ EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs);
611/*-------------------------------------------------------------------------*/ 612/*-------------------------------------------------------------------------*/
612 613
613// precondition: never called in_interrupt 614// precondition: never called in_interrupt
615static void usbnet_terminate_urbs(struct usbnet *dev)
616{
617 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup);
618 DECLARE_WAITQUEUE(wait, current);
619 int temp;
620
621 /* ensure there are no more active urbs */
622 add_wait_queue(&unlink_wakeup, &wait);
623 set_current_state(TASK_UNINTERRUPTIBLE);
624 dev->wait = &unlink_wakeup;
625 temp = unlink_urbs(dev, &dev->txq) +
626 unlink_urbs(dev, &dev->rxq);
627
628 /* maybe wait for deletions to finish. */
629 while (!skb_queue_empty(&dev->rxq)
630 && !skb_queue_empty(&dev->txq)
631 && !skb_queue_empty(&dev->done)) {
632 schedule_timeout(UNLINK_TIMEOUT_MS);
633 set_current_state(TASK_UNINTERRUPTIBLE);
634 if (netif_msg_ifdown(dev))
635 devdbg(dev, "waited for %d urb completions",
636 temp);
637 }
638 set_current_state(TASK_RUNNING);
639 dev->wait = NULL;
640 remove_wait_queue(&unlink_wakeup, &wait);
641}
614 642
615int usbnet_stop (struct net_device *net) 643int usbnet_stop (struct net_device *net)
616{ 644{
617 struct usbnet *dev = netdev_priv(net); 645 struct usbnet *dev = netdev_priv(net);
618 struct driver_info *info = dev->driver_info; 646 struct driver_info *info = dev->driver_info;
619 int temp;
620 int retval; 647 int retval;
621 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
622 DECLARE_WAITQUEUE (wait, current);
623 648
624 netif_stop_queue (net); 649 netif_stop_queue (net);
625 650
@@ -641,25 +666,8 @@ int usbnet_stop (struct net_device *net)
641 info->description); 666 info->description);
642 } 667 }
643 668
644 if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) { 669 if (!(info->flags & FLAG_AVOID_UNLINK_URBS))
645 /* ensure there are no more active urbs */ 670 usbnet_terminate_urbs(dev);
646 add_wait_queue(&unlink_wakeup, &wait);
647 dev->wait = &unlink_wakeup;
648 temp = unlink_urbs(dev, &dev->txq) +
649 unlink_urbs(dev, &dev->rxq);
650
651 /* maybe wait for deletions to finish. */
652 while (!skb_queue_empty(&dev->rxq)
653 && !skb_queue_empty(&dev->txq)
654 && !skb_queue_empty(&dev->done)) {
655 msleep(UNLINK_TIMEOUT_MS);
656 if (netif_msg_ifdown(dev))
657 devdbg(dev, "waited for %d urb completions",
658 temp);
659 }
660 dev->wait = NULL;
661 remove_wait_queue(&unlink_wakeup, &wait);
662 }
663 671
664 usb_kill_urb(dev->interrupt); 672 usb_kill_urb(dev->interrupt);
665 673
@@ -672,7 +680,10 @@ int usbnet_stop (struct net_device *net)
672 dev->flags = 0; 680 dev->flags = 0;
673 del_timer_sync (&dev->delay); 681 del_timer_sync (&dev->delay);
674 tasklet_kill (&dev->bh); 682 tasklet_kill (&dev->bh);
675 usb_autopm_put_interface(dev->intf); 683 if (info->manage_power)
684 info->manage_power(dev, 0);
685 else
686 usb_autopm_put_interface(dev->intf);
676 687
677 return 0; 688 return 0;
678} 689}
@@ -753,6 +764,12 @@ int usbnet_open (struct net_device *net)
753 764
754 // delay posting reads until we're fully open 765 // delay posting reads until we're fully open
755 tasklet_schedule (&dev->bh); 766 tasklet_schedule (&dev->bh);
767 if (info->manage_power) {
768 retval = info->manage_power(dev, 1);
769 if (retval < 0)
770 goto done;
771 usb_autopm_put_interface(dev->intf);
772 }
756 return retval; 773 return retval;
757done: 774done:
758 usb_autopm_put_interface(dev->intf); 775 usb_autopm_put_interface(dev->intf);
@@ -881,11 +898,16 @@ kevent (struct work_struct *work)
881 /* usb_clear_halt() needs a thread context */ 898 /* usb_clear_halt() needs a thread context */
882 if (test_bit (EVENT_TX_HALT, &dev->flags)) { 899 if (test_bit (EVENT_TX_HALT, &dev->flags)) {
883 unlink_urbs (dev, &dev->txq); 900 unlink_urbs (dev, &dev->txq);
901 status = usb_autopm_get_interface(dev->intf);
902 if (status < 0)
903 goto fail_pipe;
884 status = usb_clear_halt (dev->udev, dev->out); 904 status = usb_clear_halt (dev->udev, dev->out);
885 if (status < 0 905 usb_autopm_put_interface(dev->intf);
886 && status != -EPIPE 906 if (status < 0 &&
887 && status != -ESHUTDOWN) { 907 status != -EPIPE &&
908 status != -ESHUTDOWN) {
888 if (netif_msg_tx_err (dev)) 909 if (netif_msg_tx_err (dev))
910fail_pipe:
889 deverr (dev, "can't clear tx halt, status %d", 911 deverr (dev, "can't clear tx halt, status %d",
890 status); 912 status);
891 } else { 913 } else {
@@ -896,11 +918,16 @@ kevent (struct work_struct *work)
896 } 918 }
897 if (test_bit (EVENT_RX_HALT, &dev->flags)) { 919 if (test_bit (EVENT_RX_HALT, &dev->flags)) {
898 unlink_urbs (dev, &dev->rxq); 920 unlink_urbs (dev, &dev->rxq);
921 status = usb_autopm_get_interface(dev->intf);
922 if (status < 0)
923 goto fail_halt;
899 status = usb_clear_halt (dev->udev, dev->in); 924 status = usb_clear_halt (dev->udev, dev->in);
900 if (status < 0 925 usb_autopm_put_interface(dev->intf);
901 && status != -EPIPE 926 if (status < 0 &&
902 && status != -ESHUTDOWN) { 927 status != -EPIPE &&
928 status != -ESHUTDOWN) {
903 if (netif_msg_rx_err (dev)) 929 if (netif_msg_rx_err (dev))
930fail_halt:
904 deverr (dev, "can't clear rx halt, status %d", 931 deverr (dev, "can't clear rx halt, status %d",
905 status); 932 status);
906 } else { 933 } else {
@@ -919,7 +946,12 @@ kevent (struct work_struct *work)
919 clear_bit (EVENT_RX_MEMORY, &dev->flags); 946 clear_bit (EVENT_RX_MEMORY, &dev->flags);
920 if (urb != NULL) { 947 if (urb != NULL) {
921 clear_bit (EVENT_RX_MEMORY, &dev->flags); 948 clear_bit (EVENT_RX_MEMORY, &dev->flags);
949 status = usb_autopm_get_interface(dev->intf);
950 if (status < 0)
951 goto fail_lowmem;
922 rx_submit (dev, urb, GFP_KERNEL); 952 rx_submit (dev, urb, GFP_KERNEL);
953 usb_autopm_put_interface(dev->intf);
954fail_lowmem:
923 tasklet_schedule (&dev->bh); 955 tasklet_schedule (&dev->bh);
924 } 956 }
925 } 957 }
@@ -929,11 +961,18 @@ kevent (struct work_struct *work)
929 int retval = 0; 961 int retval = 0;
930 962
931 clear_bit (EVENT_LINK_RESET, &dev->flags); 963 clear_bit (EVENT_LINK_RESET, &dev->flags);
964 status = usb_autopm_get_interface(dev->intf);
965 if (status < 0)
966 goto skip_reset;
932 if(info->link_reset && (retval = info->link_reset(dev)) < 0) { 967 if(info->link_reset && (retval = info->link_reset(dev)) < 0) {
968 usb_autopm_put_interface(dev->intf);
969skip_reset:
933 devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s", 970 devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s",
934 retval, 971 retval,
935 dev->udev->bus->bus_name, dev->udev->devpath, 972 dev->udev->bus->bus_name, dev->udev->devpath,
936 info->description); 973 info->description);
974 } else {
975 usb_autopm_put_interface(dev->intf);
937 } 976 }
938 } 977 }
939 978
@@ -971,6 +1010,7 @@ static void tx_complete (struct urb *urb)
971 case -EPROTO: 1010 case -EPROTO:
972 case -ETIME: 1011 case -ETIME:
973 case -EILSEQ: 1012 case -EILSEQ:
1013 usb_mark_last_busy(dev->udev);
974 if (!timer_pending (&dev->delay)) { 1014 if (!timer_pending (&dev->delay)) {
975 mod_timer (&dev->delay, 1015 mod_timer (&dev->delay,
976 jiffies + THROTTLE_JIFFIES); 1016 jiffies + THROTTLE_JIFFIES);
@@ -987,6 +1027,7 @@ static void tx_complete (struct urb *urb)
987 } 1027 }
988 } 1028 }
989 1029
1030 usb_autopm_put_interface_async(dev->intf);
990 urb->dev = NULL; 1031 urb->dev = NULL;
991 entry->state = tx_done; 1032 entry->state = tx_done;
992 defer_bh(dev, skb, &dev->txq); 1033 defer_bh(dev, skb, &dev->txq);
@@ -1057,14 +1098,34 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1057 } 1098 }
1058 } 1099 }
1059 1100
1060 spin_lock_irqsave (&dev->txq.lock, flags); 1101 spin_lock_irqsave(&dev->txq.lock, flags);
1102 retval = usb_autopm_get_interface_async(dev->intf);
1103 if (retval < 0) {
1104 spin_unlock_irqrestore(&dev->txq.lock, flags);
1105 goto drop;
1106 }
1107
1108#ifdef CONFIG_PM
1109 /* if this triggers the device is still a sleep */
1110 if (test_bit(EVENT_DEV_ASLEEP, &dev->flags)) {
1111 /* transmission will be done in resume */
1112 usb_anchor_urb(urb, &dev->deferred);
1113 /* no use to process more packets */
1114 netif_stop_queue(net);
1115 spin_unlock_irqrestore(&dev->txq.lock, flags);
1116 devdbg(dev, "Delaying transmission for resumption");
1117 goto deferred;
1118 }
1119#endif
1061 1120
1062 switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) { 1121 switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) {
1063 case -EPIPE: 1122 case -EPIPE:
1064 netif_stop_queue (net); 1123 netif_stop_queue (net);
1065 usbnet_defer_kevent (dev, EVENT_TX_HALT); 1124 usbnet_defer_kevent (dev, EVENT_TX_HALT);
1125 usb_autopm_put_interface_async(dev->intf);
1066 break; 1126 break;
1067 default: 1127 default:
1128 usb_autopm_put_interface_async(dev->intf);
1068 if (netif_msg_tx_err (dev)) 1129 if (netif_msg_tx_err (dev))
1069 devdbg (dev, "tx: submit urb err %d", retval); 1130 devdbg (dev, "tx: submit urb err %d", retval);
1070 break; 1131 break;
@@ -1088,6 +1149,9 @@ drop:
1088 devdbg (dev, "> tx, len %d, type 0x%x", 1149 devdbg (dev, "> tx, len %d, type 0x%x",
1089 length, skb->protocol); 1150 length, skb->protocol);
1090 } 1151 }
1152#ifdef CONFIG_PM
1153deferred:
1154#endif
1091 return NETDEV_TX_OK; 1155 return NETDEV_TX_OK;
1092} 1156}
1093EXPORT_SYMBOL_GPL(usbnet_start_xmit); 1157EXPORT_SYMBOL_GPL(usbnet_start_xmit);
@@ -1126,10 +1190,10 @@ static void usbnet_bh (unsigned long param)
1126 } 1190 }
1127 1191
1128 // or are we maybe short a few urbs? 1192 // or are we maybe short a few urbs?
1129 } else if (netif_running (dev->net) 1193 } else if (netif_running (dev->net) &&
1130 && netif_device_present (dev->net) 1194 netif_device_present (dev->net) &&
1131 && !timer_pending (&dev->delay) 1195 !timer_pending (&dev->delay) &&
1132 && !test_bit (EVENT_RX_HALT, &dev->flags)) { 1196 !test_bit (EVENT_RX_HALT, &dev->flags)) {
1133 int temp = dev->rxq.qlen; 1197 int temp = dev->rxq.qlen;
1134 int qlen = RX_QLEN (dev); 1198 int qlen = RX_QLEN (dev);
1135 1199
@@ -1210,6 +1274,14 @@ static const struct net_device_ops usbnet_netdev_ops = {
1210 1274
1211// precondition: never called in_interrupt 1275// precondition: never called in_interrupt
1212 1276
1277static struct device_type wlan_type = {
1278 .name = "wlan",
1279};
1280
1281static struct device_type wwan_type = {
1282 .name = "wwan",
1283};
1284
1213int 1285int
1214usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) 1286usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1215{ 1287{
@@ -1255,6 +1327,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1255 dev->bh.func = usbnet_bh; 1327 dev->bh.func = usbnet_bh;
1256 dev->bh.data = (unsigned long) dev; 1328 dev->bh.data = (unsigned long) dev;
1257 INIT_WORK (&dev->kevent, kevent); 1329 INIT_WORK (&dev->kevent, kevent);
1330 init_usb_anchor(&dev->deferred);
1258 dev->delay.function = usbnet_bh; 1331 dev->delay.function = usbnet_bh;
1259 dev->delay.data = (unsigned long) dev; 1332 dev->delay.data = (unsigned long) dev;
1260 init_timer (&dev->delay); 1333 init_timer (&dev->delay);
@@ -1289,12 +1362,15 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1289 // heuristic: "usb%d" for links we know are two-host, 1362 // heuristic: "usb%d" for links we know are two-host,
1290 // else "eth%d" when there's reasonable doubt. userspace 1363 // else "eth%d" when there's reasonable doubt. userspace
1291 // can rename the link if it knows better. 1364 // can rename the link if it knows better.
1292 if ((dev->driver_info->flags & FLAG_ETHER) != 0 1365 if ((dev->driver_info->flags & FLAG_ETHER) != 0 &&
1293 && (net->dev_addr [0] & 0x02) == 0) 1366 (net->dev_addr [0] & 0x02) == 0)
1294 strcpy (net->name, "eth%d"); 1367 strcpy (net->name, "eth%d");
1295 /* WLAN devices should always be named "wlan%d" */ 1368 /* WLAN devices should always be named "wlan%d" */
1296 if ((dev->driver_info->flags & FLAG_WLAN) != 0) 1369 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1297 strcpy(net->name, "wlan%d"); 1370 strcpy(net->name, "wlan%d");
1371 /* WWAN devices should always be named "wwan%d" */
1372 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
1373 strcpy(net->name, "wwan%d");
1298 1374
1299 /* maybe the remote can't receive an Ethernet MTU */ 1375 /* maybe the remote can't receive an Ethernet MTU */
1300 if (net->mtu > (dev->hard_mtu - net->hard_header_len)) 1376 if (net->mtu > (dev->hard_mtu - net->hard_header_len))
@@ -1322,6 +1398,12 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1322 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); 1398 dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
1323 1399
1324 SET_NETDEV_DEV(net, &udev->dev); 1400 SET_NETDEV_DEV(net, &udev->dev);
1401
1402 if ((dev->driver_info->flags & FLAG_WLAN) != 0)
1403 SET_NETDEV_DEVTYPE(net, &wlan_type);
1404 if ((dev->driver_info->flags & FLAG_WWAN) != 0)
1405 SET_NETDEV_DEVTYPE(net, &wwan_type);
1406
1325 status = register_netdev (net); 1407 status = register_netdev (net);
1326 if (status) 1408 if (status)
1327 goto out3; 1409 goto out3;
@@ -1335,9 +1417,11 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1335 // ok, it's ready to go. 1417 // ok, it's ready to go.
1336 usb_set_intfdata (udev, dev); 1418 usb_set_intfdata (udev, dev);
1337 1419
1338 // start as if the link is up
1339 netif_device_attach (net); 1420 netif_device_attach (net);
1340 1421
1422 if (dev->driver_info->flags & FLAG_LINK_INTR)
1423 netif_carrier_off(net);
1424
1341 return 0; 1425 return 0;
1342 1426
1343out3: 1427out3:
@@ -1363,13 +1447,23 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
1363 struct usbnet *dev = usb_get_intfdata(intf); 1447 struct usbnet *dev = usb_get_intfdata(intf);
1364 1448
1365 if (!dev->suspend_count++) { 1449 if (!dev->suspend_count++) {
1450 spin_lock_irq(&dev->txq.lock);
1451 /* don't autosuspend while transmitting */
1452 if (dev->txq.qlen && (message.event & PM_EVENT_AUTO)) {
1453 spin_unlock_irq(&dev->txq.lock);
1454 return -EBUSY;
1455 } else {
1456 set_bit(EVENT_DEV_ASLEEP, &dev->flags);
1457 spin_unlock_irq(&dev->txq.lock);
1458 }
1366 /* 1459 /*
1367 * accelerate emptying of the rx and queues, to avoid 1460 * accelerate emptying of the rx and queues, to avoid
1368 * having everything error out. 1461 * having everything error out.
1369 */ 1462 */
1370 netif_device_detach (dev->net); 1463 netif_device_detach (dev->net);
1371 (void) unlink_urbs (dev, &dev->rxq); 1464 usbnet_terminate_urbs(dev);
1372 (void) unlink_urbs (dev, &dev->txq); 1465 usb_kill_urb(dev->interrupt);
1466
1373 /* 1467 /*
1374 * reattach so runtime management can use and 1468 * reattach so runtime management can use and
1375 * wake the device 1469 * wake the device
@@ -1383,10 +1477,34 @@ EXPORT_SYMBOL_GPL(usbnet_suspend);
1383int usbnet_resume (struct usb_interface *intf) 1477int usbnet_resume (struct usb_interface *intf)
1384{ 1478{
1385 struct usbnet *dev = usb_get_intfdata(intf); 1479 struct usbnet *dev = usb_get_intfdata(intf);
1480 struct sk_buff *skb;
1481 struct urb *res;
1482 int retval;
1483
1484 if (!--dev->suspend_count) {
1485 spin_lock_irq(&dev->txq.lock);
1486 while ((res = usb_get_from_anchor(&dev->deferred))) {
1487
1488 printk(KERN_INFO"%s has delayed data\n", __func__);
1489 skb = (struct sk_buff *)res->context;
1490 retval = usb_submit_urb(res, GFP_ATOMIC);
1491 if (retval < 0) {
1492 dev_kfree_skb_any(skb);
1493 usb_free_urb(res);
1494 usb_autopm_put_interface_async(dev->intf);
1495 } else {
1496 dev->net->trans_start = jiffies;
1497 __skb_queue_tail(&dev->txq, skb);
1498 }
1499 }
1386 1500
1387 if (!--dev->suspend_count) 1501 smp_mb();
1502 clear_bit(EVENT_DEV_ASLEEP, &dev->flags);
1503 spin_unlock_irq(&dev->txq.lock);
1504 if (!(dev->txq.qlen >= TX_QLEN(dev)))
1505 netif_start_queue(dev->net);
1388 tasklet_schedule (&dev->bh); 1506 tasklet_schedule (&dev->bh);
1389 1507 }
1390 return 0; 1508 return 0;
1391} 1509}
1392EXPORT_SYMBOL_GPL(usbnet_resume); 1510EXPORT_SYMBOL_GPL(usbnet_resume);
diff --git a/drivers/net/usb/zaurus.c b/drivers/net/usb/zaurus.c
index 04882c8f9bf1..3eb0b167b5b4 100644
--- a/drivers/net/usb/zaurus.c
+++ b/drivers/net/usb/zaurus.c
@@ -174,8 +174,8 @@ static int blan_mdlm_bind(struct usbnet *dev, struct usb_interface *intf)
174 goto bad_desc; 174 goto bad_desc;
175 } 175 }
176 /* expect bcdVersion 1.0, ignore */ 176 /* expect bcdVersion 1.0, ignore */
177 if (memcmp(&desc->bGUID, blan_guid, 16) 177 if (memcmp(&desc->bGUID, blan_guid, 16) &&
178 && memcmp(&desc->bGUID, safe_guid, 16) ) { 178 memcmp(&desc->bGUID, safe_guid, 16)) {
179 /* hey, this one might _really_ be MDLM! */ 179 /* hey, this one might _really_ be MDLM! */
180 dev_dbg(&intf->dev, "MDLM guid\n"); 180 dev_dbg(&intf->dev, "MDLM guid\n");
181 goto bad_desc; 181 goto bad_desc;