netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: cdc_ncm: fix probing of devices with multiple control interface altsettings
@ 2013-02-13 22:09 Bjørn Mork
  2013-02-14 18:15 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Bjørn Mork @ 2013-02-13 22:09 UTC (permalink / raw)
  To: netdev; +Cc: linux-usb, Bjørn Mork, Greg Suarez, Alexey Orishko

commit bd329e1 ("net: cdc_ncm: do not bind to NCM compatible MBIM devices")
added a test for a CDC MBIM altsetting, implementing the cdc_ncm part of
MBIM backward compatibility support.  This intentionally made the driver
behave differently for CDC NCM devices with 2 alternate settings for the
Communication interface, depending on whether or not CONFIG_USB_NET_CDC_MBIM
was enabled.  This is correct iff alternate setting #1 really *is* a MBIM
setting.  If not, then NCM probing will use a different altsetting than before,
possibly causing probing failures depending on CONFIG_USB_NET_CDC_MBIM.

Fix by setting the altsetting back to default after the test, restoring the
previous behaviour for non MBIM devices.

This bug causes probing of Huawei E3276 devices to fail when the MBIM driver
is enabled, because these devices have a second alternate setting with no CDC
functional descriptors.

Cc: Greg Suarez <gsuarez@smithmicro.com>
Cc: Alexey Orishko <alexey.orishko@stericsson.com>
Reported-and-tested-by: Jonathan A. <yo.natan@hotmail.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/cdc_ncm.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 00d3b2d..6d25439 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -576,9 +576,14 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
 	if ((intf->num_altsetting == 2) &&
 	    !usb_set_interface(dev->udev,
 			       intf->cur_altsetting->desc.bInterfaceNumber,
-			       CDC_NCM_COMM_ALTSETTING_MBIM) &&
-	    cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting))
-		return -ENODEV;
+			       CDC_NCM_COMM_ALTSETTING_MBIM)) {
+		if (cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting))
+			return -ENODEV;
+		else
+			usb_set_interface(dev->udev,
+					  intf->cur_altsetting->desc.bInterfaceNumber,
+					  CDC_NCM_COMM_ALTSETTING_NCM);
+	}
 #endif
 
 	/* NCM data altsetting is always 1 */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: cdc_ncm: fix probing of devices with multiple control interface altsettings
  2013-02-13 22:09 [PATCH] net: cdc_ncm: fix probing of devices with multiple control interface altsettings Bjørn Mork
@ 2013-02-14 18:15 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-02-14 18:15 UTC (permalink / raw)
  To: bjorn; +Cc: netdev, linux-usb, gsuarez, alexey.orishko

From: Bjørn Mork <bjorn@mork.no>
Date: Wed, 13 Feb 2013 23:09:52 +0100

> commit bd329e1 ("net: cdc_ncm: do not bind to NCM compatible MBIM devices")
> added a test for a CDC MBIM altsetting, implementing the cdc_ncm part of
> MBIM backward compatibility support.  This intentionally made the driver
> behave differently for CDC NCM devices with 2 alternate settings for the
> Communication interface, depending on whether or not CONFIG_USB_NET_CDC_MBIM
> was enabled.  This is correct iff alternate setting #1 really *is* a MBIM
> setting.  If not, then NCM probing will use a different altsetting than before,
> possibly causing probing failures depending on CONFIG_USB_NET_CDC_MBIM.
> 
> Fix by setting the altsetting back to default after the test, restoring the
> previous behaviour for non MBIM devices.
> 
> This bug causes probing of Huawei E3276 devices to fail when the MBIM driver
> is enabled, because these devices have a second alternate setting with no CDC
> functional descriptors.
> 
> Cc: Greg Suarez <gsuarez@smithmicro.com>
> Cc: Alexey Orishko <alexey.orishko@stericsson.com>
> Reported-and-tested-by: Jonathan A. <yo.natan@hotmail.com>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-02-14 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-13 22:09 [PATCH] net: cdc_ncm: fix probing of devices with multiple control interface altsettings Bjørn Mork
2013-02-14 18:15 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).