diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-10-07 10:43:04 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-10-07 10:43:04 -0400 |
commit | a56e74f546b64be93731e42d83baf5b538cc1b11 (patch) | |
tree | 18f6dee45d801e57ac9db2a31664b0d5c0762c50 /drivers/net/usb/cdc_ether.c | |
parent | d08e2e09042bd3f7ef66a35cb4bb92794ab26bb2 (diff) | |
parent | e4e7f10bfc4069925e99cc4b428c3434e30b6c3f (diff) |
Merge branch 'arm-aesbs' of git://git.linaro.org/people/ardbiesheuvel/linux-arm into devel-stable
Diffstat (limited to 'drivers/net/usb/cdc_ether.c')
-rw-r--r-- | drivers/net/usb/cdc_ether.c | 115 |
1 files changed, 42 insertions, 73 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 | ||