Skip to content

Commit

Permalink
Merge branch 'usb_cdc_fixes'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
davem330 committed Jan 21, 2013
2 parents 8141ed9 + 6b4ef60 commit f91f334
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/net/usb/cdc_mbim.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static int cdc_mbim_resume(struct usb_interface *intf)

static const struct driver_info cdc_mbim_info = {
.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,
.unbind = cdc_mbim_unbind,
.manage_power = cdc_mbim_manage_power,
Expand Down
30 changes: 29 additions & 1 deletion drivers/net/usb/cdc_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,23 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
.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)
{
struct cdc_ncm_ctx *ctx;
Expand Down Expand Up @@ -435,6 +452,16 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
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 */
if ((ctx->control == NULL) || (ctx->data == NULL) ||
((!ctx->mbim_desc) && ((ctx->ether_desc == NULL) || (ctx->control != intf))))
Expand Down Expand Up @@ -497,7 +524,8 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
error2:
usb_set_intfdata(ctx->control, 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:
cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
dev->data[0] = 0;
Expand Down

0 comments on commit f91f334

Please sign in to comment.