diff options
Diffstat (limited to 'drivers/net/usb')
-rw-r--r-- | drivers/net/usb/cdc_ether.c | 115 | ||||
-rw-r--r-- | drivers/net/usb/dm9601.c | 2 | ||||
-rw-r--r-- | drivers/net/usb/qmi_wwan.c | 2 | ||||
-rw-r--r-- | drivers/net/usb/usbnet.c | 27 |
4 files changed, 65 insertions, 81 deletions
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 03ad4dc293aa..2023f3ea891e 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/usb/usbnet.h> | 33 | #include <linux/usb/usbnet.h> |
34 | 34 | ||
35 | 35 | ||
36 | #if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE) | 36 | #if IS_ENABLED(CONFIG_USB_NET_RNDIS_HOST) |
37 | 37 | ||
38 | static int is_rndis(struct usb_interface_descriptor *desc) | 38 | static int is_rndis(struct usb_interface_descriptor *desc) |
39 | { | 39 | { |
@@ -69,8 +69,7 @@ static const u8 mbm_guid[16] = { | |||
69 | 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, | 69 | 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, |
70 | }; | 70 | }; |
71 | 71 | ||
72 | /* | 72 | /* probes control interface, claims data interface, collects the bulk |
73 | * probes control interface, claims data interface, collects the bulk | ||
74 | * endpoints, activates data interface (if needed), maybe sets MTU. | 73 | * endpoints, activates data interface (if needed), maybe sets MTU. |
75 | * all pure cdc, except for certain firmware workarounds, and knowing | 74 | * all pure cdc, except for certain firmware workarounds, and knowing |
76 | * that rndis uses one different rule. | 75 | * that rndis uses one different rule. |
@@ -88,7 +87,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |||
88 | struct usb_cdc_mdlm_desc *desc = NULL; | 87 | struct usb_cdc_mdlm_desc *desc = NULL; |
89 | struct usb_cdc_mdlm_detail_desc *detail = NULL; | 88 | struct usb_cdc_mdlm_detail_desc *detail = NULL; |
90 | 89 | ||
91 | if (sizeof dev->data < sizeof *info) | 90 | if (sizeof(dev->data) < sizeof(*info)) |
92 | return -EDOM; | 91 | return -EDOM; |
93 | 92 | ||
94 | /* expect strict spec conformance for the descriptors, but | 93 | /* expect strict spec conformance for the descriptors, but |
@@ -126,10 +125,10 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |||
126 | is_activesync(&intf->cur_altsetting->desc) || | 125 | is_activesync(&intf->cur_altsetting->desc) || |
127 | is_wireless_rndis(&intf->cur_altsetting->desc)); | 126 | is_wireless_rndis(&intf->cur_altsetting->desc)); |
128 | 127 | ||
129 | memset(info, 0, sizeof *info); | 128 | memset(info, 0, sizeof(*info)); |
130 | info->control = intf; | 129 | info->control = intf; |
131 | while (len > 3) { | 130 | while (len > 3) { |
132 | if (buf [1] != USB_DT_CS_INTERFACE) | 131 | if (buf[1] != USB_DT_CS_INTERFACE) |
133 | goto next_desc; | 132 | goto next_desc; |
134 | 133 | ||
135 | /* use bDescriptorSubType to identify the CDC descriptors. | 134 | /* use bDescriptorSubType to identify the CDC descriptors. |
@@ -139,14 +138,14 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |||
139 | * in favor of a complicated OID-based RPC scheme doing what | 138 | * in favor of a complicated OID-based RPC scheme doing what |
140 | * CDC Ethernet achieves with a simple descriptor. | 139 | * CDC Ethernet achieves with a simple descriptor. |
141 | */ | 140 | */ |
142 | switch (buf [2]) { | 141 | switch (buf[2]) { |
143 | case USB_CDC_HEADER_TYPE: | 142 | case USB_CDC_HEADER_TYPE: |
144 | if (info->header) { | 143 | if (info->header) { |
145 | dev_dbg(&intf->dev, "extra CDC header\n"); | 144 | dev_dbg(&intf->dev, "extra CDC header\n"); |
146 | goto bad_desc; | 145 | goto bad_desc; |
147 | } | 146 | } |
148 | info->header = (void *) buf; | 147 | info->header = (void *) buf; |
149 | if (info->header->bLength != sizeof *info->header) { | 148 | if (info->header->bLength != sizeof(*info->header)) { |
150 | dev_dbg(&intf->dev, "CDC header len %u\n", | 149 | dev_dbg(&intf->dev, "CDC header len %u\n", |
151 | info->header->bLength); | 150 | info->header->bLength); |
152 | goto bad_desc; | 151 | goto bad_desc; |
@@ -175,7 +174,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |||
175 | goto bad_desc; | 174 | goto bad_desc; |
176 | } | 175 | } |
177 | info->u = (void *) buf; | 176 | info->u = (void *) buf; |
178 | if (info->u->bLength != sizeof *info->u) { | 177 | if (info->u->bLength != sizeof(*info->u)) { |
179 | dev_dbg(&intf->dev, "CDC union len %u\n", | 178 | dev_dbg(&intf->dev, "CDC union len %u\n", |
180 | info->u->bLength); | 179 | info->u->bLength); |
181 | goto bad_desc; | 180 | goto bad_desc; |
@@ -233,7 +232,7 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |||
233 | goto bad_desc; | 232 | goto bad_desc; |
234 | } | 233 | } |
235 | info->ether = (void *) buf; | 234 | info->ether = (void *) buf; |
236 | if (info->ether->bLength != sizeof *info->ether) { | 235 | if (info->ether->bLength != sizeof(*info->ether)) { |
237 | dev_dbg(&intf->dev, "CDC ether len %u\n", | 236 | dev_dbg(&intf->dev, "CDC ether len %u\n", |
238 | info->ether->bLength); | 237 | info->ether->bLength); |
239 | goto bad_desc; | 238 | goto bad_desc; |
@@ -274,8 +273,8 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) | |||
274 | break; | 273 | break; |
275 | } | 274 | } |
276 | next_desc: | 275 | next_desc: |
277 | len -= buf [0]; /* bLength */ | 276 | len -= buf[0]; /* bLength */ |
278 | buf += buf [0]; | 277 | buf += buf[0]; |
279 | } | 278 | } |
280 | 279 | ||
281 | /* Microsoft ActiveSync based and some regular RNDIS devices lack the | 280 | /* Microsoft ActiveSync based and some regular RNDIS devices lack the |
@@ -379,9 +378,7 @@ void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf) | |||
379 | } | 378 | } |
380 | EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); | 379 | EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); |
381 | 380 | ||
382 | /*------------------------------------------------------------------------- | 381 | /* Communications Device Class, Ethernet Control model |
383 | * | ||
384 | * Communications Device Class, Ethernet Control model | ||
385 | * | 382 | * |
386 | * Takes two interfaces. The DATA interface is inactive till an altsetting | 383 | * Takes two interfaces. The DATA interface is inactive till an altsetting |
387 | * is selected. Configuration data includes class descriptors. There's | 384 | * is selected. Configuration data includes class descriptors. There's |
@@ -389,8 +386,7 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); | |||
389 | * | 386 | * |
390 | * This should interop with whatever the 2.4 "CDCEther.c" driver | 387 | * This should interop with whatever the 2.4 "CDCEther.c" driver |
391 | * (by Brad Hards) talked with, with more functionality. | 388 | * (by Brad Hards) talked with, with more functionality. |
392 | * | 389 | */ |
393 | *-------------------------------------------------------------------------*/ | ||
394 | 390 | ||
395 | static void dumpspeed(struct usbnet *dev, __le32 *speeds) | 391 | static void dumpspeed(struct usbnet *dev, __le32 *speeds) |
396 | { | 392 | { |
@@ -404,7 +400,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) | |||
404 | { | 400 | { |
405 | struct usb_cdc_notification *event; | 401 | struct usb_cdc_notification *event; |
406 | 402 | ||
407 | if (urb->actual_length < sizeof *event) | 403 | if (urb->actual_length < sizeof(*event)) |
408 | return; | 404 | return; |
409 | 405 | ||
410 | /* SPEED_CHANGE can get split into two 8-byte packets */ | 406 | /* SPEED_CHANGE can get split into two 8-byte packets */ |
@@ -423,7 +419,7 @@ void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) | |||
423 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ | 419 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ |
424 | netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n", | 420 | netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n", |
425 | urb->actual_length); | 421 | urb->actual_length); |
426 | if (urb->actual_length != (sizeof *event + 8)) | 422 | if (urb->actual_length != (sizeof(*event) + 8)) |
427 | set_bit(EVENT_STS_SPLIT, &dev->flags); | 423 | set_bit(EVENT_STS_SPLIT, &dev->flags); |
428 | else | 424 | else |
429 | dumpspeed(dev, (__le32 *) &event[1]); | 425 | dumpspeed(dev, (__le32 *) &event[1]); |
@@ -469,7 +465,6 @@ EXPORT_SYMBOL_GPL(usbnet_cdc_bind); | |||
469 | static const struct driver_info cdc_info = { | 465 | static const struct driver_info cdc_info = { |
470 | .description = "CDC Ethernet Device", | 466 | .description = "CDC Ethernet Device", |
471 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, | 467 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
472 | // .check_connect = cdc_check_connect, | ||
473 | .bind = usbnet_cdc_bind, | 468 | .bind = usbnet_cdc_bind, |
474 | .unbind = usbnet_cdc_unbind, | 469 | .unbind = usbnet_cdc_unbind, |
475 | .status = usbnet_cdc_status, | 470 | .status = usbnet_cdc_status, |
@@ -493,9 +488,8 @@ static const struct driver_info wwan_info = { | |||
493 | #define DELL_VENDOR_ID 0x413C | 488 | #define DELL_VENDOR_ID 0x413C |
494 | #define REALTEK_VENDOR_ID 0x0bda | 489 | #define REALTEK_VENDOR_ID 0x0bda |
495 | 490 | ||
496 | static const struct usb_device_id products [] = { | 491 | static const struct usb_device_id products[] = { |
497 | /* | 492 | /* BLACKLIST !! |
498 | * BLACKLIST !! | ||
499 | * | 493 | * |
500 | * First blacklist any products that are egregiously nonconformant | 494 | * First blacklist any products that are egregiously nonconformant |
501 | * with the CDC Ethernet specs. Minor braindamage we cope with; when | 495 | * with the CDC Ethernet specs. Minor braindamage we cope with; when |
@@ -542,7 +536,7 @@ static const struct usb_device_id products [] = { | |||
542 | .driver_info = 0, | 536 | .driver_info = 0, |
543 | }, { | 537 | }, { |
544 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO | 538 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
545 | | USB_DEVICE_ID_MATCH_DEVICE, | 539 | | USB_DEVICE_ID_MATCH_DEVICE, |
546 | .idVendor = 0x04DD, | 540 | .idVendor = 0x04DD, |
547 | .idProduct = 0x8007, /* C-700 */ | 541 | .idProduct = 0x8007, /* C-700 */ |
548 | ZAURUS_MASTER_INTERFACE, | 542 | ZAURUS_MASTER_INTERFACE, |
@@ -659,8 +653,7 @@ static const struct usb_device_id products [] = { | |||
659 | .driver_info = 0, | 653 | .driver_info = 0, |
660 | }, | 654 | }, |
661 | 655 | ||
662 | /* | 656 | /* WHITELIST!!! |
663 | * WHITELIST!!! | ||
664 | * | 657 | * |
665 | * CDC Ether uses two interfaces, not necessarily consecutive. | 658 | * CDC Ether uses two interfaces, not necessarily consecutive. |
666 | * We match the main interface, ignoring the optional device | 659 | * We match the main interface, ignoring the optional device |
@@ -672,60 +665,40 @@ static const struct usb_device_id products [] = { | |||
672 | */ | 665 | */ |
673 | { | 666 | { |
674 | /* ZTE (Vodafone) K3805-Z */ | 667 | /* ZTE (Vodafone) K3805-Z */ |
675 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 668 | USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1003, USB_CLASS_COMM, |
676 | | USB_DEVICE_ID_MATCH_PRODUCT | 669 | USB_CDC_SUBCLASS_ETHERNET, |
677 | | USB_DEVICE_ID_MATCH_INT_INFO, | 670 | USB_CDC_PROTO_NONE), |
678 | .idVendor = ZTE_VENDOR_ID, | ||
679 | .idProduct = 0x1003, | ||
680 | .bInterfaceClass = USB_CLASS_COMM, | ||
681 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
682 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | ||
683 | .driver_info = (unsigned long)&wwan_info, | 671 | .driver_info = (unsigned long)&wwan_info, |
684 | }, { | 672 | }, { |
685 | /* ZTE (Vodafone) K3806-Z */ | 673 | /* ZTE (Vodafone) K3806-Z */ |
686 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 674 | USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1015, USB_CLASS_COMM, |
687 | | USB_DEVICE_ID_MATCH_PRODUCT | 675 | USB_CDC_SUBCLASS_ETHERNET, |
688 | | USB_DEVICE_ID_MATCH_INT_INFO, | 676 | USB_CDC_PROTO_NONE), |
689 | .idVendor = ZTE_VENDOR_ID, | ||
690 | .idProduct = 0x1015, | ||
691 | .bInterfaceClass = USB_CLASS_COMM, | ||
692 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
693 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | ||
694 | .driver_info = (unsigned long)&wwan_info, | 677 | .driver_info = (unsigned long)&wwan_info, |
695 | }, { | 678 | }, { |
696 | /* ZTE (Vodafone) K4510-Z */ | 679 | /* ZTE (Vodafone) K4510-Z */ |
697 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 680 | USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1173, USB_CLASS_COMM, |
698 | | USB_DEVICE_ID_MATCH_PRODUCT | 681 | USB_CDC_SUBCLASS_ETHERNET, |
699 | | USB_DEVICE_ID_MATCH_INT_INFO, | 682 | USB_CDC_PROTO_NONE), |
700 | .idVendor = ZTE_VENDOR_ID, | ||
701 | .idProduct = 0x1173, | ||
702 | .bInterfaceClass = USB_CLASS_COMM, | ||
703 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
704 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | ||
705 | .driver_info = (unsigned long)&wwan_info, | 683 | .driver_info = (unsigned long)&wwan_info, |
706 | }, { | 684 | }, { |
707 | /* ZTE (Vodafone) K3770-Z */ | 685 | /* ZTE (Vodafone) K3770-Z */ |
708 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 686 | USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1177, USB_CLASS_COMM, |
709 | | USB_DEVICE_ID_MATCH_PRODUCT | 687 | USB_CDC_SUBCLASS_ETHERNET, |
710 | | USB_DEVICE_ID_MATCH_INT_INFO, | 688 | USB_CDC_PROTO_NONE), |
711 | .idVendor = ZTE_VENDOR_ID, | ||
712 | .idProduct = 0x1177, | ||
713 | .bInterfaceClass = USB_CLASS_COMM, | ||
714 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
715 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | ||
716 | .driver_info = (unsigned long)&wwan_info, | 689 | .driver_info = (unsigned long)&wwan_info, |
717 | }, { | 690 | }, { |
718 | /* ZTE (Vodafone) K3772-Z */ | 691 | /* ZTE (Vodafone) K3772-Z */ |
719 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 692 | USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1181, USB_CLASS_COMM, |
720 | | USB_DEVICE_ID_MATCH_PRODUCT | 693 | USB_CDC_SUBCLASS_ETHERNET, |
721 | | USB_DEVICE_ID_MATCH_INT_INFO, | 694 | USB_CDC_PROTO_NONE), |
722 | .idVendor = ZTE_VENDOR_ID, | ||
723 | .idProduct = 0x1181, | ||
724 | .bInterfaceClass = USB_CLASS_COMM, | ||
725 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
726 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, | ||
727 | .driver_info = (unsigned long)&wwan_info, | 695 | .driver_info = (unsigned long)&wwan_info, |
728 | }, { | 696 | }, { |
697 | /* Telit modules */ | ||
698 | USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM, | ||
699 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), | ||
700 | .driver_info = (kernel_ulong_t) &wwan_info, | ||
701 | }, { | ||
729 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, | 702 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, |
730 | USB_CDC_PROTO_NONE), | 703 | USB_CDC_PROTO_NONE), |
731 | .driver_info = (unsigned long) &cdc_info, | 704 | .driver_info = (unsigned long) &cdc_info, |
@@ -736,15 +709,11 @@ static const struct usb_device_id products [] = { | |||
736 | 709 | ||
737 | }, { | 710 | }, { |
738 | /* Various Huawei modems with a network port like the UMG1831 */ | 711 | /* Various Huawei modems with a network port like the UMG1831 */ |
739 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 712 | USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_COMM, |
740 | | USB_DEVICE_ID_MATCH_INT_INFO, | 713 | USB_CDC_SUBCLASS_ETHERNET, 255), |
741 | .idVendor = HUAWEI_VENDOR_ID, | ||
742 | .bInterfaceClass = USB_CLASS_COMM, | ||
743 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
744 | .bInterfaceProtocol = 255, | ||
745 | .driver_info = (unsigned long)&wwan_info, | 714 | .driver_info = (unsigned long)&wwan_info, |
746 | }, | 715 | }, |
747 | { }, // END | 716 | { }, /* END */ |
748 | }; | 717 | }; |
749 | MODULE_DEVICE_TABLE(usb, products); | 718 | MODULE_DEVICE_TABLE(usb, products); |
750 | 719 | ||
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c index 2dbb9460349d..c6867f926cff 100644 --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c | |||
@@ -303,7 +303,7 @@ static void dm9601_set_multicast(struct net_device *net) | |||
303 | rx_ctl |= 0x02; | 303 | rx_ctl |= 0x02; |
304 | } else if (net->flags & IFF_ALLMULTI || | 304 | } else if (net->flags & IFF_ALLMULTI || |
305 | netdev_mc_count(net) > DM_MAX_MCAST) { | 305 | netdev_mc_count(net) > DM_MAX_MCAST) { |
306 | rx_ctl |= 0x04; | 306 | rx_ctl |= 0x08; |
307 | } else if (!netdev_mc_empty(net)) { | 307 | } else if (!netdev_mc_empty(net)) { |
308 | struct netdev_hw_addr *ha; | 308 | struct netdev_hw_addr *ha; |
309 | 309 | ||
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 6312332afeba..3d6aaf79d8b2 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
@@ -714,7 +714,7 @@ static const struct usb_device_id products[] = { | |||
714 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ | 714 | {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ |
715 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ | 715 | {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ |
716 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ | 716 | {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ |
717 | {QMI_FIXED_INTF(0x1e2d, 0x12d1, 4)}, /* Cinterion PLxx */ | 717 | {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */ |
718 | 718 | ||
719 | /* 4. Gobi 1000 devices */ | 719 | /* 4. Gobi 1000 devices */ |
720 | {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ | 720 | {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 7b331e613e02..bf94e10a37c8 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -1241,7 +1241,9 @@ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb) | |||
1241 | if (num_sgs == 1) | 1241 | if (num_sgs == 1) |
1242 | return 0; | 1242 | return 0; |
1243 | 1243 | ||
1244 | urb->sg = kmalloc(num_sgs * sizeof(struct scatterlist), GFP_ATOMIC); | 1244 | /* reserve one for zero packet */ |
1245 | urb->sg = kmalloc((num_sgs + 1) * sizeof(struct scatterlist), | ||
1246 | GFP_ATOMIC); | ||
1245 | if (!urb->sg) | 1247 | if (!urb->sg) |
1246 | return -ENOMEM; | 1248 | return -ENOMEM; |
1247 | 1249 | ||
@@ -1305,7 +1307,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, | |||
1305 | if (build_dma_sg(skb, urb) < 0) | 1307 | if (build_dma_sg(skb, urb) < 0) |
1306 | goto drop; | 1308 | goto drop; |
1307 | } | 1309 | } |
1308 | entry->length = length = urb->transfer_buffer_length; | 1310 | length = urb->transfer_buffer_length; |
1309 | 1311 | ||
1310 | /* don't assume the hardware handles USB_ZERO_PACKET | 1312 | /* don't assume the hardware handles USB_ZERO_PACKET |
1311 | * NOTE: strictly conforming cdc-ether devices should expect | 1313 | * NOTE: strictly conforming cdc-ether devices should expect |
@@ -1317,15 +1319,18 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, | |||
1317 | if (length % dev->maxpacket == 0) { | 1319 | if (length % dev->maxpacket == 0) { |
1318 | if (!(info->flags & FLAG_SEND_ZLP)) { | 1320 | if (!(info->flags & FLAG_SEND_ZLP)) { |
1319 | if (!(info->flags & FLAG_MULTI_PACKET)) { | 1321 | if (!(info->flags & FLAG_MULTI_PACKET)) { |
1320 | urb->transfer_buffer_length++; | 1322 | length++; |
1321 | if (skb_tailroom(skb)) { | 1323 | if (skb_tailroom(skb) && !urb->num_sgs) { |
1322 | skb->data[skb->len] = 0; | 1324 | skb->data[skb->len] = 0; |
1323 | __skb_put(skb, 1); | 1325 | __skb_put(skb, 1); |
1324 | } | 1326 | } else if (urb->num_sgs) |
1327 | sg_set_buf(&urb->sg[urb->num_sgs++], | ||
1328 | dev->padding_pkt, 1); | ||
1325 | } | 1329 | } |
1326 | } else | 1330 | } else |
1327 | urb->transfer_flags |= URB_ZERO_PACKET; | 1331 | urb->transfer_flags |= URB_ZERO_PACKET; |
1328 | } | 1332 | } |
1333 | entry->length = urb->transfer_buffer_length = length; | ||
1329 | 1334 | ||
1330 | spin_lock_irqsave(&dev->txq.lock, flags); | 1335 | spin_lock_irqsave(&dev->txq.lock, flags); |
1331 | retval = usb_autopm_get_interface_async(dev->intf); | 1336 | retval = usb_autopm_get_interface_async(dev->intf); |
@@ -1509,6 +1514,7 @@ void usbnet_disconnect (struct usb_interface *intf) | |||
1509 | 1514 | ||
1510 | usb_kill_urb(dev->interrupt); | 1515 | usb_kill_urb(dev->interrupt); |
1511 | usb_free_urb(dev->interrupt); | 1516 | usb_free_urb(dev->interrupt); |
1517 | kfree(dev->padding_pkt); | ||
1512 | 1518 | ||
1513 | free_netdev(net); | 1519 | free_netdev(net); |
1514 | } | 1520 | } |
@@ -1679,9 +1685,16 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1679 | /* initialize max rx_qlen and tx_qlen */ | 1685 | /* initialize max rx_qlen and tx_qlen */ |
1680 | usbnet_update_max_qlen(dev); | 1686 | usbnet_update_max_qlen(dev); |
1681 | 1687 | ||
1688 | if (dev->can_dma_sg && !(info->flags & FLAG_SEND_ZLP) && | ||
1689 | !(info->flags & FLAG_MULTI_PACKET)) { | ||
1690 | dev->padding_pkt = kzalloc(1, GFP_KERNEL); | ||
1691 | if (!dev->padding_pkt) | ||
1692 | goto out4; | ||
1693 | } | ||
1694 | |||
1682 | status = register_netdev (net); | 1695 | status = register_netdev (net); |
1683 | if (status) | 1696 | if (status) |
1684 | goto out4; | 1697 | goto out5; |
1685 | netif_info(dev, probe, dev->net, | 1698 | netif_info(dev, probe, dev->net, |
1686 | "register '%s' at usb-%s-%s, %s, %pM\n", | 1699 | "register '%s' at usb-%s-%s, %s, %pM\n", |
1687 | udev->dev.driver->name, | 1700 | udev->dev.driver->name, |
@@ -1699,6 +1712,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1699 | 1712 | ||
1700 | return 0; | 1713 | return 0; |
1701 | 1714 | ||
1715 | out5: | ||
1716 | kfree(dev->padding_pkt); | ||
1702 | out4: | 1717 | out4: |
1703 | usb_free_urb(dev->interrupt); | 1718 | usb_free_urb(dev->interrupt); |
1704 | out3: | 1719 | out3: |