Commit f91f3345 authored by David S. Miller's avatar David S. Miller

Merge branch 'usb_cdc_fixes'

Bjørn Mork says:

====================
The 2 first patches in this series are required to make the Sierra
Wireless MC7710 card work in MBIM mode.  They may also be
required for other Qualcomm firmware based MBIM devices.

Patch #1 was previously posted as a standalone patch.  This version
is a replacement, removing a theoretical NULL pointer exception.

Patch #3 fixes a bug I introduced in v3.7
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8141ed9f 6b4ef602
...@@ -366,7 +366,7 @@ static int cdc_mbim_resume(struct usb_interface *intf) ...@@ -366,7 +366,7 @@ static int cdc_mbim_resume(struct usb_interface *intf)
static const struct driver_info cdc_mbim_info = { static const struct driver_info cdc_mbim_info = {
.description = "CDC MBIM", .description = "CDC MBIM",
.flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN, .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN | FLAG_SEND_ZLP,
.bind = cdc_mbim_bind, .bind = cdc_mbim_bind,
.unbind = cdc_mbim_unbind, .unbind = cdc_mbim_unbind,
.manage_power = cdc_mbim_manage_power, .manage_power = cdc_mbim_manage_power,
......
...@@ -344,6 +344,23 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = { ...@@ -344,6 +344,23 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
.nway_reset = usbnet_nway_reset, .nway_reset = usbnet_nway_reset,
}; };
/* return first slave interface if an IAD matches the given master */
static struct usb_interface *get_iad_slave(struct usb_device *udev,
struct usb_interface *master) {
int i;
struct usb_interface_assoc_descriptor *iad;
u8 mnum = master->cur_altsetting->desc.bInterfaceNumber;
for (i = 0; i < USB_MAXIADS; i++) {
iad = udev->actconfig->intf_assoc[i];
if (!iad)
break;
if (iad->bFirstInterface == mnum && iad->bInterfaceCount == 2)
return usb_ifnum_to_if(udev, mnum + 1);
}
return NULL;
}
int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting) int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
{ {
struct cdc_ncm_ctx *ctx; struct cdc_ncm_ctx *ctx;
...@@ -435,6 +452,16 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ ...@@ -435,6 +452,16 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
len -= temp; len -= temp;
} }
/* some buggy devices have an IAD but no CDC Union */
if (!ctx->union_desc) {
dev_dbg(&intf->dev, "missing CDC Union descriptor\n");
ctx->data = get_iad_slave(dev->udev, intf);
if (ctx->data) {
ctx->control = intf;
dev_dbg(&intf->dev, "got slave from IAD\n");
}
}
/* check if we got everything */ /* check if we got everything */
if ((ctx->control == NULL) || (ctx->data == NULL) || if ((ctx->control == NULL) || (ctx->data == NULL) ||
((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf)))) ((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
...@@ -497,7 +524,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ ...@@ -497,7 +524,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
error2: error2:
usb_set_intfdata(ctx->control, NULL); usb_set_intfdata(ctx->control, NULL);
usb_set_intfdata(ctx->data, NULL); usb_set_intfdata(ctx->data, NULL);
usb_driver_release_interface(driver, ctx->data); if (ctx->data != ctx->control)
usb_driver_release_interface(driver, ctx->data);
error: error:
cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]); cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
dev->data[0] = 0; dev->data[0] = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment