diff mbox

net: cdc_ether: allow combined control and data interface

Message ID 1372432629-17245-1-git-send-email-bjorn@mork.no
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Bjørn Mork June 28, 2013, 3:17 p.m. UTC
Some Icera based Huawei modems handled by this driver are not
completely CDC ECM compliant, using the same USB interface for both
control and data. The CDC functional descriptors include a Union
naming this interface as both master and slave, so it is supportable
by relaxing the descriptor parsing in case these interfaces are
identical.

This has been tested on a Huawei K3806 and verified to add support
for that device.

Reported-and-tested-by: Enrico Mioso <mrkiko.rs@gmail.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/cdc_ether.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

Comments

Oliver Neukum June 28, 2013, 3:32 p.m. UTC | #1
On Friday 28 June 2013 17:17:08 Bjørn Mork wrote:
> Some Icera based Huawei modems handled by this driver are not
> completely CDC ECM compliant, using the same USB interface for both
> control and data. The CDC functional descriptors include a Union
> naming this interface as both master and slave, so it is supportable
> by relaxing the descriptor parsing in case these interfaces are
> identical.

The disconnect handler is uselessly complex. Just return if the
interfaces are identical. There's nothing to do in that case.

	Regards
		Oliver

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjørn Mork June 28, 2013, 3:44 p.m. UTC | #2
Oliver Neukum <oliver@neukum.org> writes:

> On Friday 28 June 2013 17:17:08 Bjørn Mork wrote:
>> Some Icera based Huawei modems handled by this driver are not
>> completely CDC ECM compliant, using the same USB interface for both
>> control and data. The CDC functional descriptors include a Union
>> naming this interface as both master and slave, so it is supportable
>> by relaxing the descriptor parsing in case these interfaces are
>> identical.
>
> The disconnect handler is uselessly complex. Just return if the
> interfaces are identical. There's nothing to do in that case.

Right.  Thanks. Will post a new version cleaning that up.



Bjørn
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 04ee044..7d88fef 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -215,6 +215,10 @@  int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 					goto bad_desc;
 			}
 
+			/* some devices merge these - skip class check */
+			if (info->control == info->data)
+				goto next_desc;
+
 			/* a data interface altsetting does the real i/o */
 			d = &info->data->cur_altsetting->desc;
 			if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
@@ -304,19 +308,23 @@  next_desc:
 	/* claim data interface and set it up ... with side effects.
 	 * network traffic can't flow until an altsetting is enabled.
 	 */
-	status = usb_driver_claim_interface(driver, info->data, dev);
-	if (status < 0)
-		return status;
+	if (info->data != info->control) {
+		status = usb_driver_claim_interface(driver, info->data, dev);
+		if (status < 0)
+			return status;
+	}
 	status = usbnet_get_endpoints(dev, info->data);
 	if (status < 0) {
 		/* ensure immediate exit from usbnet_disconnect */
 		usb_set_intfdata(info->data, NULL);
-		usb_driver_release_interface(driver, info->data);
+		if (info->data != info->control)
+			usb_driver_release_interface(driver, info->data);
 		return status;
 	}
 
 	/* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */
-	dev->status = NULL;
+	if (info->data != info->control)
+		dev->status = NULL;
 	if (info->control->cur_altsetting->desc.bNumEndpoints == 1) {
 		struct usb_endpoint_descriptor	*desc;
 
@@ -353,7 +361,8 @@  void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
 	if (intf == info->control && info->data) {
 		/* ensure immediate exit from usbnet_disconnect */
 		usb_set_intfdata(info->data, NULL);
-		usb_driver_release_interface(driver, info->data);
+		if (info->data != info->control)
+			usb_driver_release_interface(driver, info->data);
 		info->data = NULL;
 	}
 
@@ -361,7 +370,8 @@  void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
 	else if (intf == info->data && info->control) {
 		/* ensure immediate exit from usbnet_disconnect */
 		usb_set_intfdata(info->control, NULL);
-		usb_driver_release_interface(driver, info->control);
+		if (info->data != info->control)
+			usb_driver_release_interface(driver, info->control);
 		info->control = NULL;
 	}
 }